AWS CDK Route 53 Constructs (v1)

1.204.0 · maintenance · verified Thu Apr 16

The `aws-cdk-aws-route53` library is a part of AWS Cloud Development Kit (CDK) v1, providing higher-level constructs for Amazon Route 53. It enables developers to define Route 53 resources such as hosted zones and various record types using familiar programming languages. While still available, CDK v1 is in maintenance mode, with its end-of-support reached on June 1, 2023. The current version is 1.204.0, and it adheres to a release cadence that has slowed significantly since the release of CDK v2 (`aws-cdk-lib`).

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a public hosted zone and add A and CNAME records using `aws-cdk-aws-route53` within a CDK v1 application.

import os
from aws_cdk import core as cdk
from aws_cdk import aws_route53 as route53


class MyRoute53Stack(cdk.Stack):
    def __init__(self, scope: cdk.App, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        # Create a public hosted zone
        hosted_zone = route53.PublicHostedZone(
            self, "MyHostedZone",
            zone_name="example.com"
        )

        # Add an A record pointing to an IP address
        route53.ARecord(
            self, "MyARecord",
            zone=hosted_zone,
            target=route53.RecordTarget.from_ip_addresses("192.0.2.1", "198.51.100.1"),
            record_name="www"
        )

        # Add a CNAME record
        route53.CnameRecord(
            self, "MyCnameRecord",
            zone=hosted_zone,
            domain_name="www.example.com", # Must be a fully qualified domain name
            record_name="app"
        )

app = cdk.App()
MyRoute53Stack(app, "MyRoute53Stack",
               env=cdk.Environment(account=os.environ.get('CDK_DEFAULT_ACCOUNT', '123456789012'),
                                   region=os.environ.get('CDK_DEFAULT_REGION', 'us-east-1'))
               )
app.synth()

view raw JSON →