How to create an alias record on Route 53 using TypeScript and AWS CDK.

3 min readJan 3, 2024

Using AWS CDK instead of CloudFormation.

AWS DNS record

Maybe you have two or more domains registered and to change DNS is more difficult or not an option. Alias records will map a DNS name to a particular AWS resource, such as an Elastic Load Balancer, an S3 bucket or a Cloudfront distribution. Using an alias record to route traffic to an AWS resource, Route 53 will automatically recognize changes in the resource

Alias record is an Amazon Route 53-specific virtual record.

Amazon Route 53 alias records provide a Route 53–specific extension to DNS functionality. Alias records let you route traffic to selected AWS resources, such as CloudFront distributions and Amazon S3 buckets. They also let you route traffic from one record in a hosted zone to another record.

Let’s do it.

Step 1: Set up your development environment

Install Node.js and npm on your machine if you haven’t already.
Install the AWS CLI by running npm install -g aws-cli.
Set up your AWS credentials by running aws configure and following the prompts.

Step 2: Create a new CDK project

Open a terminal and navigate to the directory where you want to create your project.
Run cdk init — language typescript to create a new CDK project with TypeScript.

Step 3: Install the required dependencies

Inside your project directory, run npm install @aws-cdk/aws-route53 to install the AWS CDK Route 53 module.

Step 4: Write the CDK code

Open the lib/<stack-name>.ts file in your project directory and remove the default CDK code.
Import the required AWS CDK modules at the top of the file:

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

Declare a class for your CDK stack and extend from cdk.Stack:

export class MyAliasRecordStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {…




DevOps Lead @evinova, former Dynatrace Solutions Engineer. Cheerleader in Chief for KMMX, Technical Writer & International Speaker, Dad & 2 cats.