Skip to content
v2.274.0

PrivateHostedZone L2 construct ​

Create a Route53 private hosted zone for use in one or more VPCs.

Note that enableDnsHostnames and enableDnsSupport must have been enabled for the VPC you're configuring for private hosted zones.

Example ​

ts
const privateZoneFromAttributes = route53.PrivateHostedZone.fromPrivateHostedZoneAttributes(this, 'MyPrivateZone', {
  zoneName: 'example.local',
  hostedZoneId: 'ZOJJZC49E0EPZ',
});

// Does not know zoneName
const privateZoneFromId = route53.PrivateHostedZone.fromPrivateHostedZoneId(this, 'MyPrivateZone', 'ZOJJZC49E0EPZ');
python
private_zone_from_attributes = route53.PrivateHostedZone.from_private_hosted_zone_attributes(self, "MyPrivateZone",
    zone_name="example.local",
    hosted_zone_id="ZOJJZC49E0EPZ"
)

# Does not know zoneName
private_zone_from_id = route53.PrivateHostedZone.from_private_hosted_zone_id(self, "MyPrivateZone", "ZOJJZC49E0EPZ")
java
IPrivateHostedZone privateZoneFromAttributes = PrivateHostedZone.fromPrivateHostedZoneAttributes(this, "MyPrivateZone", PrivateHostedZoneAttributes.builder()
        .zoneName("example.local")
        .hostedZoneId("ZOJJZC49E0EPZ")
        .build());

// Does not know zoneName
IPrivateHostedZone privateZoneFromId = PrivateHostedZone.fromPrivateHostedZoneId(this, "MyPrivateZone", "ZOJJZC49E0EPZ");
csharp
// Install: dotnet add package Amazon.CDK.Lib
var privateZoneFromAttributes = PrivateHostedZone.FromPrivateHostedZoneAttributes(this, "MyPrivateZone", new PrivateHostedZoneAttributes {
    ZoneName = "example.local",
    HostedZoneId = "ZOJJZC49E0EPZ"
});

// Does not know zoneName
var privateZoneFromId = PrivateHostedZone.FromPrivateHostedZoneId(this, "MyPrivateZone", "ZOJJZC49E0EPZ");
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
privateZoneFromAttributes := route53.PrivateHostedZone_FromPrivateHostedZoneAttributes(this, jsii.String("MyPrivateZone"), &PrivateHostedZoneAttributes{
	ZoneName: jsii.String("example.local"),
	HostedZoneId: jsii.String("ZOJJZC49E0EPZ"),
})

// Does not know zoneName
privateZoneFromId := route53.PrivateHostedZone_FromPrivateHostedZoneId(this, jsii.String("MyPrivateZone"), jsii.String("ZOJJZC49E0EPZ"))

Initializer ​

ts
new PrivateHostedZone(scope: Construct, id: string, props: PrivateHostedZoneProps)
python
PrivateHostedZone(scope: Construct, id: str, props: PrivateHostedZoneProps)
java
new PrivateHostedZone(Construct scope, String id, PrivateHostedZoneProps props)
csharp
new PrivateHostedZone(Construct scope, string id, PrivateHostedZoneProps props)
go
NewPrivateHostedZone(Scope Construct, Id *string, Props PrivateHostedZoneProps)

Construct Props ​

addTrailingDotoptionalbooleanadd_trailing_dotoptionalbooladdTrailingDotoptionalBooleanAddTrailingDotoptionalboolAddTrailingDotoptional*bool= true#
Whether to add a trailing dot to the zone name.
commentoptionalstringcommentoptionalstrcommentoptionalStringCommentoptionalstringCommentoptional*string= none#
Any comments that you want to include about the hosted zone.
queryLogsLogGroupArnoptionalstringquery_logs_log_group_arnoptionalstrqueryLogsLogGroupArnoptionalStringQueryLogsLogGroupArnoptionalstringQueryLogsLogGroupArnoptional*string= disabled#
The Amazon Resource Name (ARN) for the log group that you want Amazon Route 53 to send query logs to.
vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpcrequired#
A VPC that you want to associate with this hosted zone.

Private hosted zones must be associated with at least one VPC. You can associated additional VPCs using addVpc(vpc).

zoneNamestringzone_namestrzoneNameStringZoneNamestringZoneName*stringrequired#
The name of the domain.

For resource record types that include a domain name, specify a fully qualified domain name.

Properties ​

The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

Grants helper for this hosted zone.
hostedZoneArnstringhosted_zone_arnstrhostedZoneArnStringHostedZoneArnstringHostedZoneArn*stringrequired#
ARN of this hosted zone, such as arn:${Partition}:route53:::hostedzone/${Id}.
hostedZoneIdstringhosted_zone_idstrhostedZoneIdStringHostedZoneIdstringHostedZoneId*stringrequired#
ID of this hosted zone, such as "Z23ABC4XYZL05B".
hostedZoneNameServersmay be undefinedstring[]hosted_zone_name_serversmay be undefinedtyping.List[str]hostedZoneNameServersmay be undefinedList<String>HostedZoneNameServersmay be undefinedstring[]HostedZoneNameServersmay be undefined*[]*string#
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.

hostedZoneRefHostedZoneReferencehosted_zone_refHostedZoneReferencehostedZoneRefHostedZoneReferenceHostedZoneRefHostedZoneReferenceHostedZoneRefHostedZoneReferencerequired#
A reference to a HostedZone resource.
namestringnamestrnameStringNamestringName*stringrequired#
FQDN of this hosted zone.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.
zoneNamestringzone_namestrzoneNameStringZoneNamestringZoneName*stringrequired#
FQDN of this hosted zone.

Methods ​

addVpc(vpc: IVpc): voiddef add_vpc(self, vpc: IVpc) -> Nonepublic void addVpc(IVpc vpc)public void AddVpc(IVpc vpc)func AddVpc(Vpc IVpc)#
Add another VPC to this private hosted zone.
1 parameter

Parameters

  • vpcvpcvpcvpcVpc — the other VPC to add.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

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: ZoneSigningOptions): IKeySigningKeydef enable_dnssec(self, options: ZoneSigningOptions) -> IKeySigningKeypublic IKeySigningKey enableDnssec(ZoneSigningOptions options)public IKeySigningKey EnableDnssec(ZoneSigningOptions options)func EnableDnssec(Options ZoneSigningOptions) IKeySigningKey#
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.

fromHostedZoneAttributes(scope: Construct, id: string, attrs: HostedZoneAttributes): IHostedZone@staticmethod def from_hosted_zone_attributes(scope: Construct, id: str, attrs: HostedZoneAttributes) -> IHostedZonepublic static IHostedZone fromHostedZoneAttributes(Construct scope, String id, HostedZoneAttributes attrs)public static IHostedZone FromHostedZoneAttributes(Construct scope, string id, HostedZoneAttributes attrs)func FromHostedZoneAttributes(Scope Construct, Id *string, Attrs HostedZoneAttributes) IHostedZonestatic#
Imports a hosted zone from another stack.

Use when both hosted zone ID and hosted zone name are known.

3 parameters

Parameters

  • scopescopescopescopeScope — the parent Construct for this Construct.
  • ididididId — the logical name of this Construct.
  • attrsattrsattrsattrsAttrs — the HostedZoneAttributes (hosted zone ID and hosted zone name).
fromHostedZoneId(scope: Construct, id: string, hostedZoneId: string): IHostedZone@staticmethod def from_hosted_zone_id(scope: Construct, id: str, hosted_zone_id: str) -> IHostedZonepublic static IHostedZone fromHostedZoneId(Construct scope, String id, String hostedZoneId)public static IHostedZone FromHostedZoneId(Construct scope, string id, string hostedZoneId)func FromHostedZoneId(Scope Construct, Id *string, HostedZoneId *string) IHostedZonestatic#
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()

3 parameters

Parameters

  • scopescopescopescopeScope — the parent Construct for this Construct.
  • ididididId — the logical name of this Construct.
  • hostedZoneIdhosted_zone_idhostedZoneIdhostedZoneIdHostedZoneId — the ID of the hosted zone to import.
fromLookup(scope: Construct, id: string, query: HostedZoneProviderProps): IHostedZone@staticmethod def from_lookup(scope: Construct, id: str, query: HostedZoneProviderProps) -> IHostedZonepublic static IHostedZone fromLookup(Construct scope, String id, HostedZoneProviderProps query)public static IHostedZone FromLookup(Construct scope, string id, HostedZoneProviderProps query)func FromLookup(Scope Construct, Id *string, Query HostedZoneProviderProps) IHostedZonestatic#
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.

fromPrivateHostedZoneAttributes(scope: Construct, id: string, attrs: PrivateHostedZoneAttributes): IPrivateHostedZone@staticmethod def from_private_hosted_zone_attributes(scope: Construct, id: str, attrs: PrivateHostedZoneAttributes) -> IPrivateHostedZonepublic static IPrivateHostedZone fromPrivateHostedZoneAttributes(Construct scope, String id, PrivateHostedZoneAttributes attrs)public static IPrivateHostedZone FromPrivateHostedZoneAttributes(Construct scope, string id, PrivateHostedZoneAttributes attrs)func FromPrivateHostedZoneAttributes(Scope Construct, Id *string, Attrs PrivateHostedZoneAttributes) IPrivateHostedZonestatic#
Imports a private hosted zone from another stack.

Use when both hosted zone ID and hosted zone name are known.

3 parameters

Parameters

  • scopescopescopescopeScope — the parent Construct for this Construct.
  • ididididId — the logical name of this Construct.
  • attrsattrsattrsattrsAttrs — the PrivateHostedZoneAttributes (hosted zone ID and hosted zone name).
fromPrivateHostedZoneId(scope: Construct, id: string, privateHostedZoneId: string): IPrivateHostedZone@staticmethod def from_private_hosted_zone_id(scope: Construct, id: str, private_hosted_zone_id: str) -> IPrivateHostedZonepublic static IPrivateHostedZone fromPrivateHostedZoneId(Construct scope, String id, String privateHostedZoneId)public static IPrivateHostedZone FromPrivateHostedZoneId(Construct scope, string id, string privateHostedZoneId)func FromPrivateHostedZoneId(Scope Construct, Id *string, PrivateHostedZoneId *string) IPrivateHostedZonestatic#
Import a Route 53 private 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 you cannot import a PrivateHostedZone.

3 parameters

Parameters

  • scopescopescopescopeScope — the parent Construct for this Construct.
  • ididididId — the logical name of this Construct.
  • privateHostedZoneIdprivate_hosted_zone_idprivateHostedZoneIdprivateHostedZoneIdPrivateHostedZoneId — the ID of the private hosted zone to import.
grantDelegation(grantee: IGrantable, options?: GrantDelegationOptions): Grantdef grant_delegation(self, grantee: IGrantable, options: typing.Optional[GrantDelegationOptions] = None) -> Grantpublic Grant grantDelegation(IGrantable grantee, GrantDelegationOptions options)public Grant GrantDelegation(IGrantable grantee, GrantDelegationOptions? options = null)func GrantDelegation(Grantee IGrantable, Options GrantDelegationOptions) Grant#
[disable-awslint:no-grants].
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.