Registry /
aws / aws-cdk-aws-route53-targets
Install & Compatibility
Where this runs
tested against v1.204.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 74.2MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 8.9s · import 0.000s · 75MB
78MB installed
● package 78MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
S3BucketWebsiteTarget
✓ from aws_cdk.aws_route53_targets import S3BucketWebsiteTarget
✗ from aws_cdk.aws_route53_targets import S3BucketWebsiteTarget
This example demonstrates how to create an AWS CDK application (for CDK v1) that provisions an S3 static website and then creates an AWS Route53 A-alias record pointing to that S3 bucket. It utilizes the `S3BucketWebsiteTarget` from the `aws-cdk-aws-route53-targets` library to simplify the alias configuration. Remember to replace `myexampledomain.com` with your own registered domain name for actual deployment.
import os
from aws_cdk import App, Stack, Duration
from aws_cdk import aws_s3 as s3
from aws_cdk import aws_route53 as route53
from aws_cdk.aws_route53_targets import S3BucketWebsiteTarget # This is the key import for this library
class MyRoute53Stack(Stack):
def __init__(self, scope, id, **kwargs):
super().__init__(scope, id, **kwargs)
# In a real scenario, you'd import an existing Hosted Zone:
# hosted_zone = route53.HostedZone.from_lookup(self, "MyZone", domain_name="example.com")
# For a runnable example, we'll create a dummy one (will create a Route 53 zone).
# Replace 'myexampledomain.com' with your actual domain name.
hosted_zone = route53.HostedZone(self, "MyZone",
zone_name="myexampledomain.com"
)
# Create an S3 bucket configured for static website hosting
website_bucket = s3.Bucket(self, "WebsiteBucket",
bucket_name="www.myexampledomain.com", # Must match the domain for S3 website hosting
website_index_document="index.html",
public_read_access=True # Required for public website hosting
)
# Create an A record pointing to the S3 bucket website using S3BucketWebsiteTarget
route53.ARecord(self, "WebsiteAliasRecord",
zone=hosted_zone,
target=route53.RecordTarget.from_alias(S3BucketWebsiteTarget(website_bucket)),
record_name="www" # This will create 'www.myexampledomain.com'
)
app = App()
MyRoute53Stack(app, "MyRoute53Stack")
app.synth()
Debug
Known issues
breakingThis `aws-cdk-aws-route53-targets` package is for AWS CDK v1 ONLY. For AWS CDK v2, all alias targets are integrated directly into the `aws-cdk-lib.aws_route53` module. Do NOT install this package if you are using CDK v2 (`aws-cdk-lib`).fixMigrate to CDK v2 and use `from aws_cdk.aws_route53 import S3BucketWebsiteTarget` (or similar) directly, without installing `aws-cdk-aws-route53-targets`.
affects: CDK v2 (2.x.x) users
gotchaThe target resource (e.g., S3 bucket) must be configured correctly for the alias target to work. For `S3BucketWebsiteTarget`, the S3 bucket must have static website hosting enabled and be publicly accessible. For `CloudFrontTarget`, the distribution must be deployed.fixEnsure the underlying AWS resource referenced by the target is properly configured and provisioned according to its service's requirements (e.g., `website_index_document`, `public_read_access` for S3).
affects: All v1 versions
gotchaWhen creating records, always use `route53.RecordTarget.from_alias()` with a target from this library. Directly assigning a raw construct will likely result in an error or an incorrect record type.fixWrap your target object: `target=route53.RecordTarget.from_alias(MySpecificTarget(resource))`.
affects: All v1 versions
Upgrade
Version history
1.204.0latest on PyPI · released Jun 19, 2023
Audit
Dependencies
aws-cdk.corerequiredCore AWS CDK constructs and application lifecycle.
aws-cdk.aws-route53requiredBase constructs for AWS Route53 resources.
aws-cdk.aws-s3optionalRequired for S3BucketWebsiteTarget examples.
aws-cdk.aws-cloudfrontoptionalRequired for CloudFrontTarget examples.