Resource: aws_route53_zone

Manages a Route53 Hosted Zone. For managing Domain Name System Security Extensions (DNSSEC), see the aws_route53_key_signing_key and aws_route53_hosted_zone_dnssec resources.

Example Usage

Public Zone

resource "aws_route53_zone" "primary" {
  name = "example.com"
}

Public Subdomain Zone

For use in subdomains, note that you need to create a aws_route53_record of type NS as well as the subdomain zone.

resource "aws_route53_zone" "main" {
  name = "example.com"
}

resource "aws_route53_zone" "dev" {
  name = "dev.example.com"

  tags = {
    Environment = "dev"
  }
}

resource "aws_route53_record" "dev-ns" {
  zone_id = aws_route53_zone.main.zone_id
  name    = "dev.example.com"
  type    = "NS"
  ttl     = "30"
  records = aws_route53_zone.dev.name_servers
}

Private Zone

resource "aws_route53_zone" "private" {
  name = "example.com"

  vpc {
    vpc_id = aws_vpc.example.id
  }
}

Argument Reference

This resource supports the following arguments:

vpc Argument Reference

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import Route53 Zones using the zone id. For example:

import {
  to = aws_route53_zone.myzone
  id = "Z1D633PJN98FT9"
}

Using terraform import, import Route53 Zones using the zone id. For example:

% terraform import aws_route53_zone.myzone Z1D633PJN98FT9