1.204.0 • Published 9 months ago

@aws-cdk/aws-route53-targets v1.204.0

Weekly downloads
253,233
License
Apache-2.0
Repository
github
Last release
9 months ago

Route53 Alias Record Targets for the CDK Route53 Library


End-of-Support

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.

doc: https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html


This library contains Route53 Alias Record targets for:

  • API Gateway custom domains

    import * as apigw from '@aws-cdk/aws-apigateway';
    
    declare const zone: route53.HostedZone;
    declare const restApi: apigw.LambdaRestApi;
    
    new route53.ARecord(this, 'AliasRecord', {
      zone,
      target: route53.RecordTarget.fromAlias(new targets.ApiGateway(restApi)),
      // or - route53.RecordTarget.fromAlias(new alias.ApiGatewayDomain(domainName)),
    });
  • API Gateway V2 custom domains

    import * as apigwv2 from '@aws-cdk/aws-apigatewayv2';
    
    declare const zone: route53.HostedZone;
    declare const domainName: apigwv2.DomainName;
    
    new route53.ARecord(this, 'AliasRecord', {
      zone,
      target: route53.RecordTarget.fromAlias(new targets.ApiGatewayv2DomainProperties(domainName.regionalDomainName, domainName.regionalHostedZoneId)),
    });
  • CloudFront distributions

    import * as cloudfront from '@aws-cdk/aws-cloudfront';
    
    declare const zone: route53.HostedZone;
    declare const distribution: cloudfront.CloudFrontWebDistribution;
    
    new route53.ARecord(this, 'AliasRecord', {
      zone,
      target: route53.RecordTarget.fromAlias(new targets.CloudFrontTarget(distribution)),
    });
  • ELBv2 load balancers

    import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2';
    
    declare const zone: route53.HostedZone;
    declare const lb: elbv2.ApplicationLoadBalancer;
    
    new route53.ARecord(this, 'AliasRecord', {
      zone,
      target: route53.RecordTarget.fromAlias(new targets.LoadBalancerTarget(lb)),
      // or - route53.RecordTarget.fromAlias(new targets.ApiGatewayDomain(domainName)),
    });
  • Classic load balancers

    import * as elb from '@aws-cdk/aws-elasticloadbalancing';
    
    declare const zone: route53.HostedZone;
    declare const lb: elb.LoadBalancer;
    
    new route53.ARecord(this, 'AliasRecord', {
      zone,
      target: route53.RecordTarget.fromAlias(new targets.ClassicLoadBalancerTarget(lb)),
      // or - route53.RecordTarget.fromAlias(new alias.ApiGatewayDomain(domainName)),
    });

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 * as globalaccelerator from '@aws-cdk/aws-globalaccelerator';
    
    declare const zone: route53.HostedZone;
    declare const accelerator: globalaccelerator.Accelerator;
    
    new route53.ARecord(this, 'AliasRecord', {
      zone,
      target: route53.RecordTarget.fromAlias(new targets.GlobalAcceleratorTarget(accelerator)),
      // or - route53.RecordTarget.fromAlias(new targets.GlobalAcceleratorDomainTarget('xyz.awsglobalaccelerator.com')),
    });

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 * as ec2 from '@aws-cdk/aws-ec2';

declare const zone: route53.HostedZone;
declare const interfaceVpcEndpoint: ec2.InterfaceVpcEndpoint;

new route53.ARecord(this, "AliasRecord", {
  zone,
  target: route53.RecordTarget.fromAlias(new targets.InterfaceVpcEndpointTarget(interfaceVpcEndpoint)),
});
  • S3 Bucket Website:

Important: The Bucket name must strictly match the full DNS name. See the Developer Guide for more info.

import * as s3 from '@aws-cdk/aws-s3';

const recordName = 'www';
const domainName = 'example.com';

const bucketWebsite = new s3.Bucket(this, 'BucketWebsite', {
  bucketName: [recordName, domainName].join('.'), // www.example.com
  publicReadAccess: true,
  websiteIndexDocument: 'index.html',
});

const zone = route53.HostedZone.fromLookup(this, 'Zone', {domainName}); // example.com

new route53.ARecord(this, 'AliasRecord', {
  zone,
  recordName, // www
  target: route53.RecordTarget.fromAlias(new targets.BucketWebsiteTarget(bucketWebsite)),
});
  • User pool domain

    import * as cognito from '@aws-cdk/aws-cognito';
    
    declare const zone: route53.HostedZone;
    declare const domain: cognito.UserPoolDomain;
    new route53.ARecord(this, 'AliasRecord', {
      zone,
      target: route53.RecordTarget.fromAlias(new targets.UserPoolDomainTarget(domain)),
    });
  • Route 53 record

    declare const zone: route53.HostedZone;
    declare const record: route53.ARecord;
    new route53.ARecord(this, 'AliasRecord', {
      zone,
      target: route53.RecordTarget.fromAlias(new targets.Route53RecordTarget(record)),
    });
  • Elastic Beanstalk environment:

Important: Only supports Elastic Beanstalk environments created after 2016 that have a regional endpoint.

declare const zone: route53.HostedZone;
declare const ebsEnvironmentUrl: string;

new route53.ARecord(this, 'AliasRecord', {
  zone,
  target: route53.RecordTarget.fromAlias(new targets.ElasticBeanstalkEnvironmentEndpointTarget(ebsEnvironmentUrl)),
});

See the documentation of @aws-cdk/aws-route53 for more information.

cdk-infra@joelcox22/boilerplate@joelcox22/boilerplate-cdkcicd_spa_websiteaws-infrastructure@myhelix-cdk/static-site@autoguru/cdkcalendar-serverless-api@yippiecloud/cdk-stack-static@yippiecloud/cdk-stack-sveltekitcdk-patterns@serverless-toolkit/coredjango-cdk@infinitebrahmanuniverse/nolb-_aws-c@pinecodes/cdk-shared@everything-registry/sub-chunk-101hiii-aws-cdk-utilshiii-construct-utilseasycdn@aws/aws-domain-redirectorplatform-constructs@247studios/delivery@aligent/aws-cdk-static-hosting-stack@aligent/cdk-static-hostingpenseur-cdk@cdk-constructs-zone/super-ec2cdk-cdn-constructcdk-cloudfront-deploycdk-route53-recordcdk-websitecdk-serverless-php-mpacdk-static-webcdk-shoestring-docker-ecs-appcdk-fargate-patterns@cpmech/az-cdk@ef-class/cli@jakepartusch/notlify@jakepartusch/notlify-construct@jbt/cliverdaccio-service-construct@mittonface/resourceswolox-core-infravcs-cdk@neweracode/cdk-static-sitecicd-spa-websitespa-websitecrpm@c3l/static-cdnro-cdk-patterns@cloudmod/simple-web-ui@aws-cdk/aws-ecs@aws-cdk/aws-ecs-patterns@aws-cdk/aws-route53-patterns@devacour/cdk-base@devacour/cdk-webservice@devacour/auth-cdk@damc-dev/cdk-static-siteserverless-stack-mt-resources@creativepenguin/cdk-static-siteaws-cdk-modulesaws-cdk-pure-hocaws-cdk-stack-buildersaws-cdk-static-https-siteaws-cdk-static-site@badatt/infra-libaws-scudaws-web-pub@ljagis/aws-constructs@onhand/iac-aws@planes/cdk-construct@launchtray/hatch-cdk@serverlessui/construct@qest/aws-cdk-utils@shipula/static@rayou/cdk-url-shortener@smorken/cdk-pipeline@rnbw/aws-cdk-s3-website@rnbw/aws-cdk-static-website@updraft/aws-api-gw-lambdas@updraft/aws-static-site@updraft/aws-static-site-https@swymbase/cdk@taimos/cdk-construct-hostingamplify-category-api
1.203.0

10 months ago

1.204.0

9 months ago

1.201.0

11 months ago

1.199.0

11 months ago

1.200.0

11 months ago

1.202.0

10 months ago

1.198.1

12 months ago

1.198.0

1 year ago

1.193.0

1 year ago

1.192.0

1 year ago

1.195.0

1 year ago

1.194.0

1 year ago

1.197.0

1 year ago

1.196.0

1 year ago

1.187.0

1 year ago

1.191.0

1 year ago

1.186.0

1 year ago

1.186.1

1 year ago

1.190.0

1 year ago

1.189.0

1 year ago

1.188.0

1 year ago

1.185.0

1 year ago

1.181.0

1 year ago

1.181.1

1 year ago

1.178.0

1 year ago

1.180.0

1 year ago

1.177.0

1 year ago

1.183.0

1 year ago

1.182.0

1 year ago

1.179.0

1 year ago

1.184.0

1 year ago

1.184.1

1 year ago

1.176.0

1 year ago

1.175.0

1 year ago

1.170.0

2 years ago

1.170.1

2 years ago

1.172.0

2 years ago

1.171.0

2 years ago

1.174.0

2 years ago

1.169.0

2 years ago

1.173.0

2 years ago

1.164.0

2 years ago

1.163.0

2 years ago

1.163.2

2 years ago

1.163.1

2 years ago

1.166.1

2 years ago

1.165.0

2 years ago

1.160.0

2 years ago

1.168.0

2 years ago

1.167.0

2 years ago

1.162.0

2 years ago

1.159.0

2 years ago

1.161.0

2 years ago

1.158.0

2 years ago

1.155.0

2 years ago

1.154.0

2 years ago

1.157.0

2 years ago

1.156.0

2 years ago

1.156.1

2 years ago

1.149.0

2 years ago

1.153.0

2 years ago

1.153.1

2 years ago

1.148.0

2 years ago

1.152.0

2 years ago

1.151.0

2 years ago

1.150.0

2 years ago

1.147.0

2 years ago

1.146.0

2 years ago

1.145.0

2 years ago

1.141.0

2 years ago

1.138.2

2 years ago

1.138.1

2 years ago

1.138.0

2 years ago

1.144.0

2 years ago

1.140.0

2 years ago

1.137.0

2 years ago

1.143.0

2 years ago

1.136.0

2 years ago

1.142.0

2 years ago

1.139.0

2 years ago

1.135.0

2 years ago

1.134.0

2 years ago

1.133.0

2 years ago

1.132.0

2 years ago

1.131.0

2 years ago

1.130.0

2 years ago

1.129.0

2 years ago

1.126.0

2 years ago

1.128.0

2 years ago

1.127.0

2 years ago

1.125.0

2 years ago

1.124.0

3 years ago

1.123.0

3 years ago

1.122.0

3 years ago

1.121.0

3 years ago

1.120.0

3 years ago

1.119.0

3 years ago

1.118.0

3 years ago

1.117.0

3 years ago

1.116.0

3 years ago

1.115.0

3 years ago

1.114.0

3 years ago

1.113.0

3 years ago

1.112.0

3 years ago

1.111.0

3 years ago

1.110.1

3 years ago

1.110.0

3 years ago

1.109.0

3 years ago

1.108.0

3 years ago

1.108.1

3 years ago

1.107.0

3 years ago

1.106.1

3 years ago

1.106.0

3 years ago

1.103.0

3 years ago

1.102.0

3 years ago

1.101.0

3 years ago

1.105.0

3 years ago

1.104.0

3 years ago

1.100.0

3 years ago

1.99.0

3 years ago

1.98.0

3 years ago

1.97.0

3 years ago

1.96.0

3 years ago

1.95.2

3 years ago

1.95.1

3 years ago

1.95.0

3 years ago

1.94.1

3 years ago

1.94.0

3 years ago

1.93.0

3 years ago

1.92.0

3 years ago

1.91.0

3 years ago

1.90.1

3 years ago

1.90.0

3 years ago

1.89.0

3 years ago

1.88.0

3 years ago

1.87.1

3 years ago

1.87.0

3 years ago

1.86.0

3 years ago

1.85.0

3 years ago

1.84.0

3 years ago

1.83.0

3 years ago

1.82.0

3 years ago

1.81.0

3 years ago

1.80.0

3 years ago

1.79.0

3 years ago

1.78.0

3 years ago

1.77.0

3 years ago

1.76.0

3 years ago

1.75.0

3 years ago

1.74.0

3 years ago

1.73.0

3 years ago

1.72.0

3 years ago

1.71.0

3 years ago

1.70.0

3 years ago

1.69.0

3 years ago

1.68.0

3 years ago

1.67.0

3 years ago

1.66.0

3 years ago

1.65.0

3 years ago

1.64.1

4 years ago

1.64.0

4 years ago

1.63.0

4 years ago

1.62.0

4 years ago

1.61.1

4 years ago

1.61.0

4 years ago

1.60.0

4 years ago

1.59.0

4 years ago

1.58.0

4 years ago

1.57.0

4 years ago

1.56.0

4 years ago

1.55.0

4 years ago

1.54.0

4 years ago

1.53.0

4 years ago

1.52.0

4 years ago

1.51.0

4 years ago

1.50.0

4 years ago

1.49.1

4 years ago

1.49.0

4 years ago

1.48.0

4 years ago

1.47.1

4 years ago

1.47.0

4 years ago

1.46.0

4 years ago

1.45.0

4 years ago

1.44.0

4 years ago

1.43.0

4 years ago

1.42.1

4 years ago

1.42.0

4 years ago

1.41.0

4 years ago

1.40.0

4 years ago

1.39.0

4 years ago

1.38.0

4 years ago

1.37.0

4 years ago

1.36.1

4 years ago

1.36.0

4 years ago

1.35.0

4 years ago

1.34.1

4 years ago

1.34.0

4 years ago

1.33.1

4 years ago

1.33.0

4 years ago

1.32.2

4 years ago

1.32.1

4 years ago

1.32.0

4 years ago

1.31.0

4 years ago

1.29.0

4 years ago

1.30.0

4 years ago

1.28.0

4 years ago

1.27.0

4 years ago

1.26.0

4 years ago

1.25.0

4 years ago

1.24.0

4 years ago

1.23.0

4 years ago

1.22.0

4 years ago

1.21.1

4 years ago

1.21.0

4 years ago

1.20.0

4 years ago

1.19.0

4 years ago

1.18.0

4 years ago

1.17.1

4 years ago

1.17.0

4 years ago

1.16.3

4 years ago

1.16.2

4 years ago

1.16.1

4 years ago

1.16.0

4 years ago

1.15.0

4 years ago

1.14.0

4 years ago

1.13.1

4 years ago

1.13.0

4 years ago

1.12.0

4 years ago

1.11.0

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.39.0

5 years ago

0.38.0

5 years ago

0.37.0

5 years ago

0.36.2

5 years ago

0.36.1

5 years ago

0.36.0

5 years ago

0.35.0

5 years ago

0.34.0

5 years ago

0.33.0

5 years ago

0.32.0

5 years ago

0.31.0

5 years ago