Resource: aws_route53_zone_association

Manages a Route53 Hosted Zone VPC association. VPC associations can only be made on private zones. See the aws_route53_vpc_association_authorization resource for setting up cross-account associations.

Example Usage

resource "aws_vpc" "primary" {
  cidr_block           = "10.6.0.0/16"
  enable_dns_hostnames = true
  enable_dns_support   = true
}

resource "aws_vpc" "secondary" {
  cidr_block           = "10.7.0.0/16"
  enable_dns_hostnames = true
  enable_dns_support   = true
}

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

  # NOTE: The aws_route53_zone vpc argument accepts multiple configuration
  #       blocks. The below usage of the single vpc configuration, the
  #       lifecycle configuration, and the aws_route53_zone_association
  #       resource is for illustrative purposes (e.g., for a separate
  #       cross-account authorization process, which is not shown here).
  vpc {
    vpc_id = aws_vpc.primary.id
  }

  lifecycle {
    ignore_changes = [vpc]
  }
}

resource "aws_route53_zone_association" "secondary" {
  zone_id = aws_route53_zone.example.zone_id
  vpc_id  = aws_vpc.secondary.id
}

Argument Reference

This resource supports the following arguments:

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 Route 53 Hosted Zone Associations using the Hosted Zone ID and VPC ID, separated by a colon (:). For example:

The VPC is in the same region where you have configured the Terraform AWS Provider:

import {
  to = aws_route53_zone_association.example
  id = "Z123456ABCDEFG:vpc-12345678"
}

The VPC is _not_ in the same region where you have configured the Terraform AWS Provider:

import {
  to = aws_route53_zone_association.example
  id = "Z123456ABCDEFG:vpc-12345678:us-east-2"
}

Using terraform import to import Route 53 Hosted Zone Associations using the Hosted Zone ID and VPC ID, separated by a colon (:). For example:

The VPC is in the same region where you have configured the Terraform AWS Provider:

% terraform import aws_route53_zone_association.example Z123456ABCDEFG:vpc-12345678

The VPC is _not_ in the same region where you have configured the Terraform AWS Provider:

% terraform import aws_route53_zone_association.example Z123456ABCDEFG:vpc-12345678:us-east-2