Skip to content
v2.275.0

HostedZoneProviderProps Struct ​

Zone properties for looking up the Hosted Zone.

Example ​

ts
import * as s3 from 'aws-cdk-lib/aws-s3';

const recordName = 'www';
const domainName = 'example.com';

const bucketWebsite = new s3.Bucket(this, 'BucketWebsite', {
  bucketName: [recordName, domainName].join('.'), // www.example.com
  publicReadAccess: true,
  websiteIndexDocument: 'index.html',
});

const zone = route53.HostedZone.fromLookup(this, 'Zone', { domainName }); // example.com

new route53.ARecord(this, 'AliasRecord', {
  zone,
  recordName, // www
  target: route53.RecordTarget.fromAlias(
    new targets.BucketWebsiteTarget(bucketWebsite, {
      evaluateTargetHealth: true,
    }),
  ),
});

Properties ​

domainNamestringdomain_namestrdomainNameStringDomainNamestringDomainName*stringrequired#
The zone domain e.g. example.com.
privateZoneoptionalbooleanprivate_zoneoptionalboolprivateZoneoptionalBooleanPrivateZoneoptionalboolPrivateZoneoptional*bool= false#
Whether the zone that is being looked up is a private hosted zone.
vpcIdoptionalstringvpc_idoptionalstrvpcIdoptionalStringVpcIdoptionalstringVpcIdoptional*string#
Specifies the ID of the VPC associated with a private hosted zone.

Default: No VPC ID

If a VPC ID is provided and privateZone is false, no results will be returned and an error will be raised