HostedZone L2 construct
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 exampleCom = new route53.HostedZone(this, 'ExampleCom', {
zoneName: 'example.com',
});
const exampleNet = new route53.HostedZone(this, 'ExampleNet', {
zoneName: 'example.net',
});
const cert = new acm.Certificate(this, 'Certificate', {
domainName: 'test.example.com',
subjectAlternativeNames: ['cool.example.com', 'test.example.net'],
validation: acm.CertificateValidation.fromDnsMultiZone({
'test.example.com': exampleCom,
'cool.example.com': exampleCom,
'test.example.net': exampleNet,
}),
});
example_com = route53.HostedZone(self, "ExampleCom",
zone_name="example.com"
)
example_net = route53.HostedZone(self, "ExampleNet",
zone_name="example.net"
)
cert = acm.Certificate(self, "Certificate",
domain_name="test.example.com",
subject_alternative_names=["cool.example.com", "test.example.net"],
validation=acm.CertificateValidation.from_dns_multi_zone({
"test.example.com": example_com,
"cool.example.com": example_com,
"test.example.net": example_net
})
)
HostedZone exampleCom = HostedZone.Builder.create(this, "ExampleCom")
.zoneName("example.com")
.build();
HostedZone exampleNet = HostedZone.Builder.create(this, "ExampleNet")
.zoneName("example.net")
.build();
Certificate cert = Certificate.Builder.create(this, "Certificate")
.domainName("test.example.com")
.subjectAlternativeNames(List.of("cool.example.com", "test.example.net"))
.validation(CertificateValidation.fromDnsMultiZone(Map.of(
"test.example.com", exampleCom,
"cool.example.com", exampleCom,
"test.example.net", exampleNet)))
.build();
// Install: dotnet add package Amazon.CDK.Lib
var exampleCom = new HostedZone(this, "ExampleCom", new HostedZoneProps {
ZoneName = "example.com"
});
var exampleNet = new HostedZone(this, "ExampleNet", new HostedZoneProps {
ZoneName = "example.net"
});
var cert = new Certificate(this, "Certificate", new CertificateProps {
DomainName = "test.example.com",
SubjectAlternativeNames = new [] { "cool.example.com", "test.example.net" },
Validation = CertificateValidation.FromDnsMultiZone(new Dictionary<string, IHostedZone> {
{ "test.example.com", exampleCom },
{ "cool.example.com", exampleCom },
{ "test.example.net", exampleNet }
})
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
exampleCom := route53.NewHostedZone(this, jsii.String("ExampleCom"), &HostedZoneProps{
ZoneName: jsii.String("example.com"),
})
exampleNet := route53.NewHostedZone(this, jsii.String("ExampleNet"), &HostedZoneProps{
ZoneName: jsii.String("example.net"),
})
cert := acm.NewCertificate(this, jsii.String("Certificate"), &CertificateProps{
DomainName: jsii.String("test.example.com"),
SubjectAlternativeNames: []*string{
jsii.String("cool.example.com"),
jsii.String("test.example.net"),
},
Validation: acm.CertificateValidation_FromDnsMultiZone(map[string]IHostedZone{
"test.example.com": exampleCom,
"cool.example.com": exampleCom,
"test.example.net": exampleNet,
}),
})
Initializer
new HostedZone(scope: Construct, id: string, props: HostedZoneProps)
HostedZone(scope: Construct, id: str, props: HostedZoneProps)
new HostedZone(Construct scope, String id, HostedZoneProps props)
new HostedZone(Construct scope, string id, HostedZoneProps props)
NewHostedZone(Scope Construct, Id *string, Props HostedZoneProps)
Construct Props
addTrailingDotoptionalbooleanadd_trailing_dotoptionalbooladdTrailingDotoptionalBooleanAddTrailingDotoptionalboolAddTrailingDotoptional*bool= true#commentoptionalstringcommentoptionalstrcommentoptionalStringCommentoptionalstringCommentoptional*string= none#queryLogsLogGroupArnoptionalstringquery_logs_log_group_arnoptionalstrqueryLogsLogGroupArnoptionalStringQueryLogsLogGroupArnoptionalstringQueryLogsLogGroupArnoptional*string= disabled#vpcsoptionalIVpc[]vpcsoptionaltyping.List[IVpc]vpcsoptionalList<IVpc>VpcsoptionalIVpc[]Vpcsoptional*[]IVpc#Default: public (no VPCs associated)
When you specify this property, a private hosted zone will be created.
You can associate additional VPCs to this private zone using addVpc(vpc).
For resource record types that include a domain name, specify a fully qualified domain name.
Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironment#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.
grantsHostedZoneGrantsgrantsHostedZoneGrantsgrantsHostedZoneGrantsGrantsHostedZoneGrantsGrantsHostedZoneGrants#hostedZoneNameServersmay be undefinedstring[]hosted_zone_name_serversmay be undefinedtyping.List[str]hostedZoneNameServersmay be undefinedList<String>HostedZoneNameServersmay be undefinedstring[]HostedZoneNameServersmay be undefined*[]*string#This attribute will be undefined for private hosted zones or hosted zones imported from another stack.
hostedZoneRefHostedZoneReferencehosted_zone_refHostedZoneReferencehostedZoneRefHostedZoneReferenceHostedZoneRefHostedZoneReferenceHostedZoneRefHostedZoneReference#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#Methods
addVpc(vpc: IVpc): voiddef add_vpc(self, vpc: IVpc) -> Nonepublic void addVpc(IVpc vpc)public void AddVpc(IVpc vpc)func AddVpc(Vpc IVpc)#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)#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)#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#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#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#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#Requires environment, you must specify env for the stack.
Use to easily query hosted zones.
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#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#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#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#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#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.