Skip to main content

The CDK Construct Library for AWS Route53 Alias Targets

Project description

Route53 Alias Record Targets for the CDK Route53 Library

---

cdk-constructs: Stable


This library contains Route53 Alias Record targets for:

  • API Gateway custom domains

    import aws_cdk.aws_apigateway as apigw
    
    # zone: route53.HostedZone
    # rest_api: apigw.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: route53.HostedZone
    # domain_name: apigwv2.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: route53.HostedZone
    # distribution: cloudfront.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: route53.HostedZone
    # lb: elbv2.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: route53.HostedZone
    # lb: elb.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: route53.HostedZone
    # accelerator: globalaccelerator.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: route53.HostedZone
# interface_vpc_endpoint: ec2.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: route53.HostedZone
    # domain: cognito.UserPoolDomain
    
    route53.ARecord(self, "AliasRecord",
        zone=zone,
        target=route53.RecordTarget.from_alias(targets.UserPoolDomainTarget(domain))
    )
    
  • Route 53 record

    # zone: route53.HostedZone
    # record: route53.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: route53.HostedZone
# ebs_environment_url: str


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

aws-cdk.aws-route53-targets-1.156.1.tar.gz (50.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_cdk.aws_route53_targets-1.156.1-py3-none-any.whl (48.9 kB view details)

Uploaded Python 3

File details

Details for the file aws-cdk.aws-route53-targets-1.156.1.tar.gz.

File metadata

  • Download URL: aws-cdk.aws-route53-targets-1.156.1.tar.gz
  • Upload date:
  • Size: 50.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.5

File hashes

Hashes for aws-cdk.aws-route53-targets-1.156.1.tar.gz
Algorithm Hash digest
SHA256 050047a805a89c5f9ec474bd97890fa56c11a8d0bb7bd0a01ea2fc9defb8a165
MD5 ab4aee510528b0f85793a673075abb4d
BLAKE2b-256 b5fdab109ea3b145af5055dc7016acae59a44304fc9265047d7578630529cee2

See more details on using hashes here.

File details

Details for the file aws_cdk.aws_route53_targets-1.156.1-py3-none-any.whl.

File metadata

  • Download URL: aws_cdk.aws_route53_targets-1.156.1-py3-none-any.whl
  • Upload date:
  • Size: 48.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.5

File hashes

Hashes for aws_cdk.aws_route53_targets-1.156.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3687e94ee182b8d0a12447e7a61d21bb291c1e1b86e3c67c109768b96e1b8868
MD5 9ba78cdfa6fbb040fbb88098df32c115
BLAKE2b-256 38340f43727f6f1bdf82ac1ac1355f8b6ec0b23cc4ac9ad632b0588100e380b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page