Package: aws-cdk.aws-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 theMigrating to AWS CDK v2guide.This library contains Route53 Alias Record targets for:API Gateway custom domainsimportaws_cdk.aws_apigatewayasapigw# zone: route53.HostedZone# rest_api: apigw.LambdaRestApiroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.ApiGateway(rest_api)))API Gateway V2 custom domainsimportaws_cdk.aws_apigatewayv2asapigwv2# zone: route53.HostedZone# domain_name: apigwv2.DomainNameroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.ApiGatewayv2DomainProperties(domain_name.regional_domain_name,domain_name.regional_hosted_zone_id)))CloudFront distributionsimportaws_cdk.aws_cloudfrontascloudfront# zone: route53.HostedZone# distribution: cloudfront.CloudFrontWebDistributionroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.CloudFrontTarget(distribution)))ELBv2 load balancersimportaws_cdk.aws_elasticloadbalancingv2aselbv2# zone: route53.HostedZone# lb: elbv2.ApplicationLoadBalancerroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.LoadBalancerTarget(lb)))Classic load balancersimportaws_cdk.aws_elasticloadbalancingaselb# zone: route53.HostedZone# lb: elb.LoadBalancerroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.ClassicLoadBalancerTarget(lb)))Important:Based onAWS documentation, all alias record in Route 53 that points to a Elastic Load Balancer will always includedualstackfor the DNSName to resolve IPv4/IPv6 addresses (withoutdualstackIPv6 will not resolve).For example, if the Amazon-provided DNS for the load balancer isALB-xxxxxxx.us-west-2.elb.amazonaws.com, CDK will create alias target in Route 53 will bedualstack.ALB-xxxxxxx.us-west-2.elb.amazonaws.com.GlobalAcceleratorimportaws_cdk.aws_globalacceleratorasglobalaccelerator# zone: route53.HostedZone# accelerator: globalaccelerator.Acceleratorroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.GlobalAcceleratorTarget(accelerator)))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.
Seethe documentation on DNS addressingwith Global Accelerator for more info.InterfaceVpcEndpointsImportant: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.importaws_cdk.aws_ec2asec2# zone: route53.HostedZone# interface_vpc_endpoint: ec2.InterfaceVpcEndpointroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.InterfaceVpcEndpointTarget(interface_vpc_endpoint)))S3 Bucket Website:Important:The Bucket name must strictly match the full DNS name.
Seethe Developer Guidefor more info.importaws_cdk.aws_s3ass3record_name="www"domain_name="example.com"bucket_website=s3.Bucket(self,"BucketWebsite",bucket_name=[record_name,domain_name].join("."),# www.example.compublic_read_access=True,website_index_document="index.html")zone=route53.HostedZone.from_lookup(self,"Zone",domain_name=domain_name)# example.comroute53.ARecord(self,"AliasRecord",zone=zone,record_name=record_name,# wwwtarget=route53.RecordTarget.from_alias(targets.BucketWebsiteTarget(bucket_website)))User pool domainimportaws_cdk.aws_cognitoascognito# zone: route53.HostedZone# domain: cognito.UserPoolDomainroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.UserPoolDomainTarget(domain)))Route 53 record# zone: route53.HostedZone# record: route53.ARecordroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.Route53RecordTarget(record)))Elastic Beanstalk environment:Important:Only supports Elastic Beanstalk environments created after 2016 that have a regional endpoint.# zone: route53.HostedZone# ebs_environment_url: strroute53.ARecord(self,"AliasRecord",zone=zone,target=route53.RecordTarget.from_alias(targets.ElasticBeanstalkEnvironmentEndpointTarget(ebs_environment_url)))See the documentation of@aws-cdk/aws-route53for more information.