Package software.amazon.awscdk.services.route53.targets
Route53 Alias Record Targets for the CDK Route53 Library
---
AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2.
For more information on how to migrate, see the Migrating to AWS CDK v2 guide.
This library contains Route53 Alias Record targets for:
- API Gateway custom domains
import software.amazon.awscdk.services.apigateway.*; HostedZone zone; LambdaRestApi restApi; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new ApiGateway(restApi))) .build();
- API Gateway V2 custom domains
import software.amazon.awscdk.services.apigatewayv2.*; HostedZone zone; DomainName domainName; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new ApiGatewayv2DomainProperties(domainName.getRegionalDomainName(), domainName.getRegionalHostedZoneId()))) .build();
- CloudFront distributions
import software.amazon.awscdk.services.cloudfront.*; HostedZone zone; CloudFrontWebDistribution distribution; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new CloudFrontTarget(distribution))) .build();
- ELBv2 load balancers
import software.amazon.awscdk.services.elasticloadbalancingv2.*; HostedZone zone; ApplicationLoadBalancer lb; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new LoadBalancerTarget(lb))) .build();
- Classic load balancers
import software.amazon.awscdk.services.elasticloadbalancing.*; HostedZone zone; LoadBalancer lb; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new ClassicLoadBalancerTarget(lb))) .build();
Important: Based on AWS documentation, all alias record in Route 53 that points to a Elastic Load Balancer will always include dualstack for the DNSName to resolve IPv4/IPv6 addresses (without dualstack IPv6 will not resolve).
For example, if the Amazon-provided DNS for the load balancer is ALB-xxxxxxx.us-west-2.elb.amazonaws.com
, CDK will create alias target in Route 53 will be dualstack.ALB-xxxxxxx.us-west-2.elb.amazonaws.com
.
- GlobalAccelerator
import software.amazon.awscdk.services.globalaccelerator.*; HostedZone zone; Accelerator accelerator; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new GlobalAcceleratorTarget(accelerator))) .build();
Important: If you use GlobalAcceleratorDomainTarget, passing a string rather than an instance of IAccelerator, ensure that the string is a valid domain name of an existing Global Accelerator instance. See the documentation on DNS addressing with Global Accelerator for more info.
- InterfaceVpcEndpoints
Important: Based on the CFN docs for VPCEndpoints - see here - the attributes returned for DnsEntries in CloudFormation is a combination of the hosted zone ID and the DNS name. The entries are ordered as follows: regional public DNS, zonal public DNS, private DNS, and wildcard DNS. This order is not enforced for AWS Marketplace services, and therefore this CDK construct is ONLY guaranteed to work with non-marketplace services.
import software.amazon.awscdk.services.ec2.*; HostedZone zone; InterfaceVpcEndpoint interfaceVpcEndpoint; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new InterfaceVpcEndpointTarget(interfaceVpcEndpoint))) .build();
- S3 Bucket Website:
Important: The Bucket name must strictly match the full DNS name. See the Developer Guide for more info.
import software.amazon.awscdk.services.s3.*; String recordName = "www"; String domainName = "example.com"; Bucket bucketWebsite = Bucket.Builder.create(this, "BucketWebsite") .bucketName(List.of(recordName, domainName).join(".")) // www.example.com .publicReadAccess(true) .websiteIndexDocument("index.html") .build(); IHostedZone zone = HostedZone.fromLookup(this, "Zone", HostedZoneProviderProps.builder().domainName(domainName).build()); // example.com // example.com ARecord.Builder.create(this, "AliasRecord") .zone(zone) .recordName(recordName) // www .target(RecordTarget.fromAlias(new BucketWebsiteTarget(bucketWebsite))) .build();
- User pool domain
import software.amazon.awscdk.services.cognito.*; HostedZone zone; UserPoolDomain domain; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new UserPoolDomainTarget(domain))) .build();
- Route 53 record
HostedZone zone; ARecord record; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new Route53RecordTarget(record))) .build();
- Elastic Beanstalk environment:
Important: Only supports Elastic Beanstalk environments created after 2016 that have a regional endpoint.
HostedZone zone; String ebsEnvironmentUrl; ARecord.Builder.create(this, "AliasRecord") .zone(zone) .target(RecordTarget.fromAlias(new ElasticBeanstalkEnvironmentEndpointTarget(ebsEnvironmentUrl))) .build();
See the documentation of @aws-cdk/aws-route53
for more information.
Deprecated: AWS CDK v1 has reached End-of-Support on 2023-06-01.
This package is no longer being updated, and users should migrate to AWS CDK v2.
For more information on how to migrate, see https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html
-
ClassDescriptionDefines an API Gateway REST API as the alias target.Defines an API Gateway domain name as the alias target.Defines an API Gateway V2 domain name as the alias target.Use a S3 as an alias record target.Use a classic ELB as an alias record target.Use a CloudFront Distribution as an alias record target.Use an Elastic Beanstalk environment URL as an alias record target.Use a Global Accelerator domain name as an alias record target.Use a Global Accelerator instance domain name as an alias record target.Set an InterfaceVpcEndpoint as a target for an ARecord.Use an ELBv2 as an alias record target.Use another Route 53 record as an alias record target.Use a user pool domain as an alias record target.