The CDK Construct Library for AWS Route53 Alias Targets
Project description
Route53 Alias Record Targets for the CDK Route53 Library
---This library contains Route53 Alias Record targets for:
-
API Gateway custom domains
import aws_cdk.aws_apigateway as apigw # zone is of type HostedZone # rest_api is of type LambdaRestApi route53.ARecord(self, "AliasRecord", zone=zone, target=route53.RecordTarget.from_alias(targets.ApiGateway(rest_api)) )
-
API Gateway V2 custom domains
import aws_cdk.aws_apigatewayv2 as apigwv2 # zone is of type HostedZone # domain_name is of type DomainName route53.ARecord(self, "AliasRecord", zone=zone, target=route53.RecordTarget.from_alias(targets.ApiGatewayv2DomainProperties(domain_name.regional_domain_name, domain_name.regional_hosted_zone_id)) )
-
CloudFront distributions
import aws_cdk.aws_cloudfront as cloudfront # zone is of type HostedZone # distribution is of type CloudFrontWebDistribution route53.ARecord(self, "AliasRecord", zone=zone, target=route53.RecordTarget.from_alias(targets.CloudFrontTarget(distribution)) )
-
ELBv2 load balancers
import aws_cdk.aws_elasticloadbalancingv2 as elbv2 # zone is of type HostedZone # lb is of type ApplicationLoadBalancer route53.ARecord(self, "AliasRecord", zone=zone, target=route53.RecordTarget.from_alias(targets.LoadBalancerTarget(lb)) )
-
Classic load balancers
import aws_cdk.aws_elasticloadbalancing as elb # zone is of type HostedZone # lb is of type LoadBalancer route53.ARecord(self, "AliasRecord", zone=zone, target=route53.RecordTarget.from_alias(targets.ClassicLoadBalancerTarget(lb)) )
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 aws_cdk.aws_globalaccelerator as globalaccelerator # zone is of type HostedZone # accelerator is of type Accelerator route53.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. 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 aws_cdk.aws_ec2 as ec2
# zone is of type HostedZone
# interface_vpc_endpoint is of type InterfaceVpcEndpoint
route53.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. See the Developer Guide for more info.
import aws_cdk.aws_s3 as s3
record_name = "www"
domain_name = "example.com"
bucket_website = s3.Bucket(self, "BucketWebsite",
bucket_name=[record_name, domain_name].join("."), # www.example.com
public_read_access=True,
website_index_document="index.html"
)
zone = route53.HostedZone.from_lookup(self, "Zone", domain_name=domain_name) # example.com
route53.ARecord(self, "AliasRecord",
zone=zone,
record_name=record_name, # www
target=route53.RecordTarget.from_alias(targets.BucketWebsiteTarget(bucket_website))
)
-
User pool domain
import aws_cdk.aws_cognito as cognito # zone is of type HostedZone # domain is of type UserPoolDomain route53.ARecord(self, "AliasRecord", zone=zone, target=route53.RecordTarget.from_alias(targets.UserPoolDomainTarget(domain)) )
-
Route 53 record
# zone is of type HostedZone # record is of type ARecord route53.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 is of type HostedZone
# ebs_environment_url is of type string
route53.ARecord(self, "AliasRecord",
zone=zone,
target=route53.RecordTarget.from_alias(targets.ElasticBeanstalkEnvironmentEndpointTarget(ebs_environment_url))
)
See the documentation of @aws-cdk/aws-route53
for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk.aws-route53-targets-1.139.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa73f6e361e620eecf3b2dd1ac4946f53f1a86f4197e36152e197110df223582 |
|
MD5 | f68db62b5b8d790b0772c33867009efa |
|
BLAKE2b-256 | 5e7f0e3f22866bb0109dce82d2c50fe55991a7225e348ece4227275cec176b6a |
Hashes for aws_cdk.aws_route53_targets-1.139.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0434c27bf1d6f0136dc2ee4bfb70082c7978ec6dfcdce514e00ce8e1e660cddf |
|
MD5 | 51bb31f3866bc5469b2922f158c2b3f2 |
|
BLAKE2b-256 | 3ded0b7a68bb403f4d9254e71687248d26f66612c524c121ccb8821b7f309aef |