class PublicHostedZone (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Route53.PublicHostedZone |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsroute53#PublicHostedZone |
Java | software.amazon.awscdk.services.route53.PublicHostedZone |
Python | aws_cdk.aws_route53.PublicHostedZone |
TypeScript (source) | aws-cdk-lib » aws_route53 » PublicHostedZone |
Implements
IConstruct
, IDependable
, IResource
, IHosted
, IPublic
Create a Route53 public hosted zone.
Example
const stack1 = new Stack(app, 'Stack1', {
env: {
region: 'us-east-1',
},
crossRegionReferences: true,
});
const cert = new acm.Certificate(stack1, 'Cert', {
domainName: '*.example.com',
validation: acm.CertificateValidation.fromDns(route53.PublicHostedZone.fromHostedZoneId(stack1, 'Zone', 'Z0329774B51CGXTDQV3X')),
});
const stack2 = new Stack(app, 'Stack2', {
env: {
region: 'us-east-2',
},
crossRegionReferences: true,
});
new cloudfront.Distribution(stack2, 'Distribution', {
defaultBehavior: {
origin: new origins.HttpOrigin('example.com'),
},
domainNames: ['dev.example.com'],
certificate: cert,
});
Initializer
new PublicHostedZone(scope: Construct, id: string, props: PublicHostedZoneProps)
Parameters
- scope
Construct
- id
string
- props
Public
Hosted Zone Props
Construct Props
Name | Type | Description |
---|---|---|
zone | string | The name of the domain. |
add | boolean | Whether to add a trailing dot to the zone name. |
caa | boolean | Whether to create a CAA record to restrict certificate authorities allowed to issue certificates for this domain to Amazon only. |
comment? | string | Any comments that you want to include about the hosted zone. |
cross | IPrincipal | A principal which is trusted to assume a role for zone delegation. |
cross | string | The name of the role created for cross account delegation. |
query | string | The Amazon Resource Name (ARN) for the log group that you want Amazon Route 53 to send query logs to. |
zoneName
Type:
string
The name of the domain.
For resource record types that include a domain name, specify a fully qualified domain name.
addTrailingDot?
Type:
boolean
(optional, default: true)
Whether to add a trailing dot to the zone name.
caaAmazon?
Type:
boolean
(optional, default: false)
Whether to create a CAA record to restrict certificate authorities allowed to issue certificates for this domain to Amazon only.
comment?
Type:
string
(optional, default: none)
Any comments that you want to include about the hosted zone.
crossAccountZoneDelegationPrincipal?
⚠️ Deprecated: Create the Role yourself and call hostedZone.grantDelegation()
.
Type:
IPrincipal
(optional, default: No delegation configuration)
A principal which is trusted to assume a role for zone delegation.
If supplied, this will create a Role in the same account as the Hosted
Zone, which can be assumed by the CrossAccountZoneDelegationRecord
to
create a delegation record to a zone in a different account.
Be sure to indicate the account(s) that you trust to create delegation
records, using either iam.AccountPrincipal
or iam.OrganizationPrincipal
.
If you are planning to use iam.ServicePrincipal
s here, be sure to include
region-specific service principals for every opt-in region you are going to
be delegating to; or don't use this feature and create separate roles
with appropriate permissions for every opt-in region instead.
crossAccountZoneDelegationRoleName?
⚠️ Deprecated: Create the Role yourself and call hostedZone.grantDelegation()
.
Type:
string
(optional, default: A role name is generated automatically)
The name of the role created for cross account delegation.
queryLogsLogGroupArn?
Type:
string
(optional, default: disabled)
The Amazon Resource Name (ARN) for the log group that you want Amazon Route 53 to send query logs to.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
hosted | string | ARN of this hosted zone, such as arn:${Partition}:route53:::hostedzone/${Id}. |
hosted | string | ID of this hosted zone, such as "Z23ABC4XYZL05B". |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
zone | string | FQDN of this hosted zone. |
cross | Role | Role for cross account zone delegation. |
hosted | string[] | Returns the set of name servers for the specific hosted zone. For example: ns1.example.com. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
hostedZoneArn
Type:
string
ARN of this hosted zone, such as arn:${Partition}:route53:::hostedzone/${Id}.
hostedZoneId
Type:
string
ID of this hosted zone, such as "Z23ABC4XYZL05B".
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
zoneName
Type:
string
FQDN of this hosted zone.
crossAccountZoneDelegationRole?
Type:
Role
(optional)
Role for cross account zone delegation.
hostedZoneNameServers?
Type:
string[]
(optional)
Returns the set of name servers for the specific hosted zone. For example: ns1.example.com.
This attribute will be undefined for private hosted zones or hosted zones imported from another stack.
Methods
Name | Description |
---|---|
add | Adds a delegation from this zone to a designated zone. |
add | Add another VPC to this private hosted zone. |
apply | Apply the given removal policy to this resource. |
enable | Enable DNSSEC for this hosted zone. |
grant | Grant permissions to add delegation records to this zone. |
to | Returns a string representation of this construct. |
static from | Imports a public hosted zone from another stack. |
static from | Import a Route 53 public hosted zone defined either outside the CDK, or in a different CDK stack. |
Delegation(delegate, opts?)
addpublic addDelegation(delegate: IPublicHostedZone, opts?: ZoneDelegationOptions): void
Parameters
- delegate
IPublic
— the zone being delegated to.Hosted Zone - opts
Zone
— options for creating the DNS record, if any.Delegation Options
Adds a delegation from this zone to a designated zone.
Vpc(_vpc)
addpublic addVpc(_vpc: IVpc): void
Parameters
- _vpc
IVpc
Add another VPC to this private hosted zone.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
Dnssec(options)
enablepublic enableDnssec(options: ZoneSigningOptions): IKeySigningKey
Parameters
- options
Zone
Signing Options
Returns
Enable DNSSEC for this hosted zone.
This will create a key signing key with the given options and enable DNSSEC signing for the hosted zone.
Delegation(grantee)
grantpublic grantDelegation(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant permissions to add delegation records to this zone.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
PublicHostedZoneAttributes(scope, id, attrs)
static frompublic static fromPublicHostedZoneAttributes(scope: Construct, id: string, attrs: PublicHostedZoneAttributes): IPublicHostedZone
Parameters
- scope
Construct
— the parent Construct for this Construct. - id
string
— the logical name of this Construct. - attrs
Public
— the PublicHostedZoneAttributes (hosted zone ID and hosted zone name).Hosted Zone Attributes
Returns
Imports a public hosted zone from another stack.
Use when both hosted zone ID and hosted zone name are known.
PublicHostedZoneId(scope, id, publicHostedZoneId)
static frompublic static fromPublicHostedZoneId(scope: Construct, id: string, publicHostedZoneId: string): IPublicHostedZone
Parameters
- scope
Construct
— the parent Construct for this Construct. - id
string
— the logical name of this Construct. - publicHostedZoneId
string
— the ID of the public hosted zone to import.
Returns
Import a Route 53 public hosted zone defined either outside the CDK, or in a different CDK stack.
Use when hosted zone ID is known. If a PublicHostedZone is imported with this method the zoneName cannot be referenced.
If the zoneName is needed then the PublicHostedZone should be imported with fromPublicHostedZoneAttributes()
.