npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aws-cdk/aws-route53-targets

v1.204.0

Published

The CDK Construct Library for AWS Route53 Alias Targets

Downloads

384,402

Readme

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.


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.