class HostedZone (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Route53.HostedZone |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsroute53#HostedZone |
![]() | software.amazon.awscdk.services.route53.HostedZone |
![]() | aws_cdk.aws_route53.HostedZone |
![]() | aws-cdk-lib » aws_route53 » HostedZone |
Implements
IConstruct
, IDependable
, IResource
, IHosted
Container for records, and records contain information about how to route traffic for a specific domain, such as example.com and its subdomains (acme.example.com, zenith.example.com).
Example
const kmsKey = new kms.Key(this, 'KmsCMK', {
keySpec: kms.KeySpec.ECC_NIST_P256,
keyUsage: kms.KeyUsage.SIGN_VERIFY,
});
const hostedZone = new route53.HostedZone(this, 'HostedZone', {
zoneName: 'example.com',
});
// Enable DNSSEC signing for the zone
hostedZone.enableDnssec({ kmsKey });
Initializer
new HostedZone(scope: Construct, id: string, props: HostedZoneProps)
Parameters
- scope
Construct
- id
string
- props
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. |
comment? | string | Any comments that you want to include about the hosted zone. |
query | string | The Amazon Resource Name (ARN) for the log group that you want Amazon Route 53 to send query logs to. |
vpcs? | IVpc [] | A VPC that you want to associate with this hosted zone. |
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.
comment?
Type:
string
(optional, default: none)
Any comments that you want to include about the hosted zone.
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.
vpcs?
Type:
IVpc
[]
(optional, default: public (no VPCs associated))
A VPC that you want to associate with this hosted zone.
When you specify this property, a private hosted zone will be created.
You can associate additional VPCs to this private zone using addVpc(vpc)
.
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. |
vpcs | VPCProperty [] | VPCs to which this hosted zone will be added. |
zone | string | FQDN of this hosted zone. |
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.
vpcs
Type:
VPCProperty
[]
VPCs to which this hosted zone will be added.
zoneName
Type:
string
FQDN of this hosted zone.
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 | 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 hosted zone from another stack. |
static from | Import a Route 53 hosted zone defined either outside the CDK, or in a different CDK stack. |
static from | Lookup a hosted zone in the current account/region based on query parameters. |
addVpc(vpc)
public addVpc(vpc: IVpc): void
Parameters
- vpc
IVpc
— the other VPC to add.
Add another VPC to this private hosted zone.
applyRemovalPolicy(policy)
public 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
).
enableDnssec(options)
public 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.
grantDelegation(grantee)
public grantDelegation(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant permissions to add delegation records to this zone.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromHostedZoneAttributes(scope, id, attrs)
public static fromHostedZoneAttributes(scope: Construct, id: string, attrs: HostedZoneAttributes): IHostedZone
Parameters
- scope
Construct
— the parent Construct for this Construct. - id
string
— the logical name of this Construct. - attrs
Hosted
— the HostedZoneAttributes (hosted zone ID and hosted zone name).Zone Attributes
Returns
Imports a hosted zone from another stack.
Use when both hosted zone ID and hosted zone name are known.
static fromHostedZoneId(scope, id, hostedZoneId)
public static fromHostedZoneId(scope: Construct, id: string, hostedZoneId: string): IHostedZone
Parameters
- scope
Construct
— the parent Construct for this Construct. - id
string
— the logical name of this Construct. - hostedZoneId
string
— the ID of the hosted zone to import.
Returns
Import a Route 53 hosted zone defined either outside the CDK, or in a different CDK stack.
Use when hosted zone ID is known. If a HostedZone is imported with this method the zoneName cannot be referenced.
If the zoneName is needed then the HostedZone should be imported with fromHostedZoneAttributes()
or fromLookup()
static fromLookup(scope, id, query)
public static fromLookup(scope: Construct, id: string, query: HostedZoneProviderProps): IHostedZone
Parameters
- scope
Construct
- id
string
- query
Hosted
Zone Provider Props
Returns
Lookup a hosted zone in the current account/region based on query parameters.
Requires environment, you must specify env for the stack.
Use to easily query hosted zones.
See also: https://docs.aws.amazon.com/cdk/latest/guide/environments.html