# @aws-cdk/aws-route53-targets

> The CDK Construct Library for AWS Route53 Alias Targets

Latest version **1.204.0** (published 2023-06-19) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @aws-cdk/aws-route53-targets
pnpm add @aws-cdk/aws-route53-targets
yarn add @aws-cdk/aws-route53-targets
bun add @aws-cdk/aws-route53-targets
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.204.0 |
| Published | 2023-06-19 |
| First published | 2019-05-23 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 14.15.0 |
| Dependencies | 13 |
| Unpacked size | 227.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12894 |
| Author | Amazon Web Services |
| Maintainers | romainmuller, amzn-oss, rix0rrr, aws-cdk-team |
| Keywords | aws, cdk, constructs, route53 |

## Links

- npm: https://www.npmjs.com/package/@aws-cdk/aws-route53-targets
- Repository: https://github.com/aws/aws-cdk
- Issues: https://github.com/aws/aws-cdk/issues
- npm.io page: https://npm.io/package/@aws-cdk/aws-route53-targets

## Dependencies (13)

- [constructs](https://npm.io/package/constructs.md) ^3.3.69
- [@aws-cdk/core](https://npm.io/package/@aws-cdk/core.md) 1.204.0
- [@aws-cdk/aws-s3](https://npm.io/package/@aws-cdk/aws-s3.md) 1.204.0
- [@aws-cdk/aws-ec2](https://npm.io/package/@aws-cdk/aws-ec2.md) 1.204.0
- [@aws-cdk/aws-iam](https://npm.io/package/@aws-cdk/aws-iam.md) 1.204.0
- [@aws-cdk/aws-cognito](https://npm.io/package/@aws-cdk/aws-cognito.md) 1.204.0
- [@aws-cdk/aws-route53](https://npm.io/package/@aws-cdk/aws-route53.md) 1.204.0
- [@aws-cdk/region-info](https://npm.io/package/@aws-cdk/region-info.md) 1.204.0
- [@aws-cdk/aws-apigateway](https://npm.io/package/@aws-cdk/aws-apigateway.md) 1.204.0
- [@aws-cdk/aws-cloudfront](https://npm.io/package/@aws-cdk/aws-cloudfront.md) 1.204.0
- [@aws-cdk/aws-globalaccelerator](https://npm.io/package/@aws-cdk/aws-globalaccelerator.md) 1.204.0
- [@aws-cdk/aws-elasticloadbalancing](https://npm.io/package/@aws-cdk/aws-elasticloadbalancing.md) 1.204.0
- [@aws-cdk/aws-elasticloadbalancingv2](https://npm.io/package/@aws-cdk/aws-elasticloadbalancingv2.md) 1.204.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.204.0 (latest) — 2023-06-19
- 1.203.0 — 2023-05-31
- 1.202.0 — 2023-05-22
- 1.201.0 — 2023-05-10
- 1.200.0 — 2023-04-26
- 1.199.0 — 2023-04-20
- 1.198.1 — 2023-03-31
- 1.198.0 — 2023-03-22
- 1.197.0 — 2023-03-14
- 1.196.0 — 2023-03-08
- 1.195.0 — 2023-03-02
- 1.194.0 — 2023-02-21
- 1.193.0 — 2023-02-15
- 1.192.0 — 2023-02-09
- 1.191.0 — 2023-01-31
- … 238 more at https://npm.io/package/@aws-cdk/aws-route53-targets/versions

## README

# Route53 Alias Record Targets for the CDK Route53 Library
<!--BEGIN STABILITY BANNER-->

---

![End-of-Support](https://img.shields.io/badge/End--of--Support-critical.svg?style=for-the-badge)

> 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].
>
> [doc]: https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html

---

<!--END STABILITY BANNER-->

This library contains Route53 Alias Record targets for:

* API Gateway custom domains

  ```ts
  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

  ```ts
  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

  ```ts
  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

  ```ts
  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

  ```ts
  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](https://aws.amazon.com/de/premiumsupport/knowledge-center/alias-resource-record-set-route53-cli/), 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

  ```ts
  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](https://docs.aws.amazon.com/global-accelerator/latest/dg/dns-addressing-custom-domains.dns-addressing.html) with Global Accelerator for more info.

* InterfaceVpcEndpoints

**Important:** Based on the CFN docs for VPCEndpoints - [see here](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html#aws-resource-ec2-vpcendpoint-return-values) - 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.

  ```ts
  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](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/getting-started.html) for more info.

  ```ts
  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

  ```ts
  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

  ```ts
  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.

```ts
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.

---
_Source: https://npm.io/package/@aws-cdk/aws-route53-targets · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
