Skip to content

Data Source: awsRoute53Zone

awsRoute53Zone provides details about a specific Route 53 Hosted Zone.

This data source allows to find a Hosted Zone ID given Hosted Zone name and certain search criteria.

Example Usage

The following example shows how to get a Hosted Zone from its name and from this data how to create a Record Set.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const dataAwsRoute53ZoneSelected =
  new aws.dataAwsRoute53Zone.DataAwsRoute53Zone(this, "selected", {
    name: "test.com.",
    privateZone: true,
  });
new aws.route53Record.Route53Record(this, "www", {
  name: `www.\${${dataAwsRoute53ZoneSelected.name}}`,
  records: ["10.0.0.1"],
  ttl: "300",
  type: "A",
  zoneId: dataAwsRoute53ZoneSelected.zoneId,
});

Argument Reference

The arguments of this data source act as filters for querying the available Hosted Zone. You have to use zoneId or name, not both of them. The given filter must match exactly one Hosted Zone. If you use name field for private Hosted Zone, you need to add privateZone field to true

  • zoneId - (Optional) Hosted Zone id of the desired Hosted Zone.

  • name - (Optional) Hosted Zone name of the desired Hosted Zone.

  • privateZone - (Optional) Used with name field to get a private Hosted Zone.

  • vpcId - (Optional) Used with name field to get a private Hosted Zone associated with the vpc_id (in this case, private_zone is not mandatory).

  • tags - (Optional) Used with name field. A map of tags, each pair of which must exactly match a pair on the desired Hosted Zone.

Attributes Reference

All of the argument attributes are also exported as result attributes. This data source will complete the data by populating any fields that are not included in the configuration with the data for the selected Hosted Zone.

The following attribute is additionally exported:

  • arn - ARN of the Hosted Zone.
  • callerReference - Caller Reference of the Hosted Zone.
  • comment - Comment field of the Hosted Zone.
  • nameServers - List of DNS name servers for the Hosted Zone.
  • primaryNameServer - The Route 53 name server that created the SOA record.
  • resourceRecordSetCount - The number of Record Set in the Hosted Zone.
  • linkedServicePrincipal - The service that created the Hosted Zone (e.g., servicediscoveryAmazonawsCom).
  • linkedServiceDescription - The description provided by the service that created the Hosted Zone (e.g., arn:aws:servicediscovery:usEast1:1234567890:namespace/nsXxxxxxxxxxxxxxxx).