CDK Constructs for AWS Route53
Project description
Amazon Route53 Construct Library
---To add a public hosted zone:
# Example may have issues. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_route53 as route53
route53.PublicHostedZone(self, "HostedZone",
zone_name="fully.qualified.domain.com"
)
To add a private hosted zone, use PrivateHostedZone
. Note that
enableDnsHostnames
and enableDnsSupport
must have been enabled for the
VPC you're configuring for private hosted zones.
# Example may have issues. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_ec2 as ec2
import aws_cdk.aws_route53 as route53
vpc = ec2.Vpc(self, "VPC")
zone = route53.PrivateHostedZone(self, "HostedZone",
zone_name="fully.qualified.domain.com",
vpc=vpc
)
Additional VPCs can be added with zone.addVpc()
.
Adding Records
To add a TXT record to your zone:
# Example may have issues. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_route53 as route53
route53.TxtRecord(self, "TXTRecord",
zone=my_zone,
record_name="_foo", # If the name ends with a ".", it will be used as-is;
# if it ends with a "." followed by the zone name, a trailing "." will be added automatically;
# otherwise, a ".", the zone name, and a trailing "." will be added automatically.
# Defaults to zone root if not specified.
values=["Bar!", "Baz?"],
ttl=Duration.minutes(90)
)
To add a A record to your zone:
# Example may have issues. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_route53 as route53
route53.ARecord(self, "ARecord",
zone=my_zone,
target=route53.AddressRecordTarget.from_ip_addresses("1.2.3.4", "5.6.7.8")
)
To add a AAAA record pointing to a CloudFront distribution:
# Example may have issues. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_route53 as route53
import aws_cdk.aws_route53_targets as targets
route53.AaaaRecord(self, "Alias",
zone=my_zone,
target=route53.AddressRecordTarget.from_alias(targets.CloudFrontTarget(distribution))
)
Constructs are available for A, AAAA, CAA, CNAME, MX, NS, SRV and TXT records.
Use the CaaAmazonRecord
construct to easily restrict certificate authorities
allowed to issue certificates for a domain to Amazon only.
Adding records to existing hosted zones
If you know the ID and Name of a Hosted Zone, you can import it directly:
# Example may have issues. See https://github.com/aws/jsii/issues/826
zone = HostedZone.import(self, "MyZone",
zone_name="example.com",
hosted_zone_id="ZOJJZC49E0EPZ"
)
If you don't know the ID of a Hosted Zone, you can use the HostedZone.fromLookup
to discover and import it:
# Example may have issues. See https://github.com/aws/jsii/issues/826
HostedZone.from_lookup(self, "MyZone",
domain_name="example.com"
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk.aws-route53-1.13.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfeda1c19a53220346f787f5cfa87f170d93adb6641c920de2faadbe82c72bf8 |
|
MD5 | bcb2fceaf0d043fbf5effd915c24e483 |
|
BLAKE2b-256 | 5fc5ac9aa874a9ca41ba705e4555e745a74e650548a086f099eb26fa6cc76da1 |
Hashes for aws_cdk.aws_route53-1.13.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5872db747fa8cdbf555f664dbdfa8ed15c94fab04880022b5c39fd293b4fff7d |
|
MD5 | 76fcae6a62a8b91f3af8d26a8b00edb2 |
|
BLAKE2b-256 | a6f6345fac8ab2e99d6506d1f2f69ab716bd66d014061e08bfdaf22b63370bd6 |