The CDK Construct Library for AWS::Route53
Project description
Amazon Route53 Construct Library
---To add a public hosted zone:
# Example automatically generated without compilation. 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 automatically generated without compilation. 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 automatically generated without compilation. 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 automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_route53 as route53
route53.ARecord(self, "ARecord",
zone=my_zone,
target=route53.RecordTarget.from_ip_addresses("1.2.3.4", "5.6.7.8")
)
To add a AAAA record pointing to a CloudFront distribution:
# Example automatically generated without compilation. 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.RecordTarget.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.
Imports
If you don't know the ID of the Hosted Zone to import, you can use the
HostedZone.fromLookup
:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
HostedZone.from_lookup(self, "MyZone",
domain_name="example.com"
)
HostedZone.fromLookup
requires an environment to be configured. Check
out the documentation for more documentation and examples. CDK
automatically looks into your ~/.aws/config
file for the [default]
profile.
If you want to specify a different account run cdk deploy --profile [profile]
.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
MyDevStack(app, "dev",
env={
"account": process.env.CDK_DEFAULT_ACCOUNT,
"region": process.env.CDK_DEFAULT_REGION
}
)
If you know the ID and Name of a Hosted Zone, you can import it directly:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
zone = HostedZone.from_hosted_zone_attributes(self, "MyZone",
zone_name="example.com",
hosted_zone_id="ZOJJZC49E0EPZ"
)
Alternatively, use the HostedZone.fromHostedZoneId
to import hosted zones if
you know the ID and the retrieval for the zoneName
is undesirable.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
zone = HostedZone.from_hosted_zone_id(self, "MyZone",
hosted_zone_id="ZOJJZC49E0EPZ"
)
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.67.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68a8433a0b9b07253b93871466773492385734e06c1e0e3dc627b2704ae4e15d |
|
MD5 | ebb16d32e4b30e1961ad6dbdb00903c9 |
|
BLAKE2b-256 | ad1826bd1f5b59dc9b56f8a51e229452ed632b87030ba4c15ba5fe89e8b227b5 |
Hashes for aws_cdk.aws_route53-1.67.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63ecae3149dd3359600fd41372b9020008a8895c6d60312d116607966c9694cb |
|
MD5 | 11962942f8f2f4ebb61d97e03836b51e |
|
BLAKE2b-256 | ae386ab5e65f89c8db30b24ab2f2f0c09150a7e9aea9fbdf423395fab43315d9 |