1. Packages
  2. AWS
  3. API Docs
  4. route53
  5. ZoneAssociation
AWS v6.73.0 published on Wednesday, Mar 19, 2025 by Pulumi

aws.route53.ZoneAssociation

Explore with Pulumi AI

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

NOTE: Unless explicit association ordering is required (e.g., a separate cross-account association authorization), usage of this resource is not recommended. Use the vpc configuration blocks available within the aws.route53.Zone resource instead.

NOTE: This provider provides both this standalone Zone VPC Association resource and exclusive VPC associations defined in-line in the aws.route53.Zone resource via vpc configuration blocks. At this time, you cannot use those in-line VPC associations in conjunction with this resource and the same zone ID otherwise it will cause a perpetual difference in plan output. You can optionally use ignoreChanges in the aws.route53.Zone resource to manage additional associations via this resource.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const primary = new aws.ec2.Vpc("primary", {
    cidrBlock: "10.6.0.0/16",
    enableDnsHostnames: true,
    enableDnsSupport: true,
});
const secondary = new aws.ec2.Vpc("secondary", {
    cidrBlock: "10.7.0.0/16",
    enableDnsHostnames: true,
    enableDnsSupport: true,
});
const example = new aws.route53.Zone("example", {
    name: "example.com",
    vpcs: [{
        vpcId: primary.id,
    }],
});
const secondaryZoneAssociation = new aws.route53.ZoneAssociation("secondary", {
    zoneId: example.zoneId,
    vpcId: secondary.id,
});
Copy
import pulumi
import pulumi_aws as aws

primary = aws.ec2.Vpc("primary",
    cidr_block="10.6.0.0/16",
    enable_dns_hostnames=True,
    enable_dns_support=True)
secondary = aws.ec2.Vpc("secondary",
    cidr_block="10.7.0.0/16",
    enable_dns_hostnames=True,
    enable_dns_support=True)
example = aws.route53.Zone("example",
    name="example.com",
    vpcs=[{
        "vpc_id": primary.id,
    }])
secondary_zone_association = aws.route53.ZoneAssociation("secondary",
    zone_id=example.zone_id,
    vpc_id=secondary.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		primary, err := ec2.NewVpc(ctx, "primary", &ec2.VpcArgs{
			CidrBlock:          pulumi.String("10.6.0.0/16"),
			EnableDnsHostnames: pulumi.Bool(true),
			EnableDnsSupport:   pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		secondary, err := ec2.NewVpc(ctx, "secondary", &ec2.VpcArgs{
			CidrBlock:          pulumi.String("10.7.0.0/16"),
			EnableDnsHostnames: pulumi.Bool(true),
			EnableDnsSupport:   pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		example, err := route53.NewZone(ctx, "example", &route53.ZoneArgs{
			Name: pulumi.String("example.com"),
			Vpcs: route53.ZoneVpcArray{
				&route53.ZoneVpcArgs{
					VpcId: primary.ID(),
				},
			},
		})
		if err != nil {
			return err
		}
		_, err = route53.NewZoneAssociation(ctx, "secondary", &route53.ZoneAssociationArgs{
			ZoneId: example.ZoneId,
			VpcId:  secondary.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var primary = new Aws.Ec2.Vpc("primary", new()
    {
        CidrBlock = "10.6.0.0/16",
        EnableDnsHostnames = true,
        EnableDnsSupport = true,
    });

    var secondary = new Aws.Ec2.Vpc("secondary", new()
    {
        CidrBlock = "10.7.0.0/16",
        EnableDnsHostnames = true,
        EnableDnsSupport = true,
    });

    var example = new Aws.Route53.Zone("example", new()
    {
        Name = "example.com",
        Vpcs = new[]
        {
            new Aws.Route53.Inputs.ZoneVpcArgs
            {
                VpcId = primary.Id,
            },
        },
    });

    var secondaryZoneAssociation = new Aws.Route53.ZoneAssociation("secondary", new()
    {
        ZoneId = example.ZoneId,
        VpcId = secondary.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Vpc;
import com.pulumi.aws.ec2.VpcArgs;
import com.pulumi.aws.route53.Zone;
import com.pulumi.aws.route53.ZoneArgs;
import com.pulumi.aws.route53.inputs.ZoneVpcArgs;
import com.pulumi.aws.route53.ZoneAssociation;
import com.pulumi.aws.route53.ZoneAssociationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var primary = new Vpc("primary", VpcArgs.builder()
            .cidrBlock("10.6.0.0/16")
            .enableDnsHostnames(true)
            .enableDnsSupport(true)
            .build());

        var secondary = new Vpc("secondary", VpcArgs.builder()
            .cidrBlock("10.7.0.0/16")
            .enableDnsHostnames(true)
            .enableDnsSupport(true)
            .build());

        var example = new Zone("example", ZoneArgs.builder()
            .name("example.com")
            .vpcs(ZoneVpcArgs.builder()
                .vpcId(primary.id())
                .build())
            .build());

        var secondaryZoneAssociation = new ZoneAssociation("secondaryZoneAssociation", ZoneAssociationArgs.builder()
            .zoneId(example.zoneId())
            .vpcId(secondary.id())
            .build());

    }
}
Copy
resources:
  primary:
    type: aws:ec2:Vpc
    properties:
      cidrBlock: 10.6.0.0/16
      enableDnsHostnames: true
      enableDnsSupport: true
  secondary:
    type: aws:ec2:Vpc
    properties:
      cidrBlock: 10.7.0.0/16
      enableDnsHostnames: true
      enableDnsSupport: true
  example:
    type: aws:route53:Zone
    properties:
      name: example.com
      vpcs:
        - vpcId: ${primary.id}
  secondaryZoneAssociation:
    type: aws:route53:ZoneAssociation
    name: secondary
    properties:
      zoneId: ${example.zoneId}
      vpcId: ${secondary.id}
Copy

Create ZoneAssociation Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new ZoneAssociation(name: string, args: ZoneAssociationArgs, opts?: CustomResourceOptions);
@overload
def ZoneAssociation(resource_name: str,
                    args: ZoneAssociationArgs,
                    opts: Optional[ResourceOptions] = None)

@overload
def ZoneAssociation(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    vpc_id: Optional[str] = None,
                    zone_id: Optional[str] = None,
                    vpc_region: Optional[str] = None)
func NewZoneAssociation(ctx *Context, name string, args ZoneAssociationArgs, opts ...ResourceOption) (*ZoneAssociation, error)
public ZoneAssociation(string name, ZoneAssociationArgs args, CustomResourceOptions? opts = null)
public ZoneAssociation(String name, ZoneAssociationArgs args)
public ZoneAssociation(String name, ZoneAssociationArgs args, CustomResourceOptions options)
type: aws:route53:ZoneAssociation
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ZoneAssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ZoneAssociationArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ZoneAssociationArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ZoneAssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ZoneAssociationArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var zoneAssociationResource = new Aws.Route53.ZoneAssociation("zoneAssociationResource", new()
{
    VpcId = "string",
    ZoneId = "string",
    VpcRegion = "string",
});
Copy
example, err := route53.NewZoneAssociation(ctx, "zoneAssociationResource", &route53.ZoneAssociationArgs{
	VpcId:     pulumi.String("string"),
	ZoneId:    pulumi.String("string"),
	VpcRegion: pulumi.String("string"),
})
Copy
var zoneAssociationResource = new ZoneAssociation("zoneAssociationResource", ZoneAssociationArgs.builder()
    .vpcId("string")
    .zoneId("string")
    .vpcRegion("string")
    .build());
Copy
zone_association_resource = aws.route53.ZoneAssociation("zoneAssociationResource",
    vpc_id="string",
    zone_id="string",
    vpc_region="string")
Copy
const zoneAssociationResource = new aws.route53.ZoneAssociation("zoneAssociationResource", {
    vpcId: "string",
    zoneId: "string",
    vpcRegion: "string",
});
Copy
type: aws:route53:ZoneAssociation
properties:
    vpcId: string
    vpcRegion: string
    zoneId: string
Copy

ZoneAssociation Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The ZoneAssociation resource accepts the following input properties:

VpcId
This property is required.
Changes to this property will trigger replacement.
string
The VPC to associate with the private hosted zone.
ZoneId
This property is required.
Changes to this property will trigger replacement.
string
The private hosted zone to associate.
VpcRegion Changes to this property will trigger replacement. string
The VPC's region. Defaults to the region of the AWS provider.
VpcId
This property is required.
Changes to this property will trigger replacement.
string
The VPC to associate with the private hosted zone.
ZoneId
This property is required.
Changes to this property will trigger replacement.
string
The private hosted zone to associate.
VpcRegion Changes to this property will trigger replacement. string
The VPC's region. Defaults to the region of the AWS provider.
vpcId
This property is required.
Changes to this property will trigger replacement.
String
The VPC to associate with the private hosted zone.
zoneId
This property is required.
Changes to this property will trigger replacement.
String
The private hosted zone to associate.
vpcRegion Changes to this property will trigger replacement. String
The VPC's region. Defaults to the region of the AWS provider.
vpcId
This property is required.
Changes to this property will trigger replacement.
string
The VPC to associate with the private hosted zone.
zoneId
This property is required.
Changes to this property will trigger replacement.
string
The private hosted zone to associate.
vpcRegion Changes to this property will trigger replacement. string
The VPC's region. Defaults to the region of the AWS provider.
vpc_id
This property is required.
Changes to this property will trigger replacement.
str
The VPC to associate with the private hosted zone.
zone_id
This property is required.
Changes to this property will trigger replacement.
str
The private hosted zone to associate.
vpc_region Changes to this property will trigger replacement. str
The VPC's region. Defaults to the region of the AWS provider.
vpcId
This property is required.
Changes to this property will trigger replacement.
String
The VPC to associate with the private hosted zone.
zoneId
This property is required.
Changes to this property will trigger replacement.
String
The private hosted zone to associate.
vpcRegion Changes to this property will trigger replacement. String
The VPC's region. Defaults to the region of the AWS provider.

Outputs

All input properties are implicitly available as output properties. Additionally, the ZoneAssociation resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
OwningAccount string
The account ID of the account that created the hosted zone.
Id string
The provider-assigned unique ID for this managed resource.
OwningAccount string
The account ID of the account that created the hosted zone.
id String
The provider-assigned unique ID for this managed resource.
owningAccount String
The account ID of the account that created the hosted zone.
id string
The provider-assigned unique ID for this managed resource.
owningAccount string
The account ID of the account that created the hosted zone.
id str
The provider-assigned unique ID for this managed resource.
owning_account str
The account ID of the account that created the hosted zone.
id String
The provider-assigned unique ID for this managed resource.
owningAccount String
The account ID of the account that created the hosted zone.

Look up Existing ZoneAssociation Resource

Get an existing ZoneAssociation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ZoneAssociationState, opts?: CustomResourceOptions): ZoneAssociation
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        owning_account: Optional[str] = None,
        vpc_id: Optional[str] = None,
        vpc_region: Optional[str] = None,
        zone_id: Optional[str] = None) -> ZoneAssociation
func GetZoneAssociation(ctx *Context, name string, id IDInput, state *ZoneAssociationState, opts ...ResourceOption) (*ZoneAssociation, error)
public static ZoneAssociation Get(string name, Input<string> id, ZoneAssociationState? state, CustomResourceOptions? opts = null)
public static ZoneAssociation get(String name, Output<String> id, ZoneAssociationState state, CustomResourceOptions options)
resources:  _:    type: aws:route53:ZoneAssociation    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
OwningAccount string
The account ID of the account that created the hosted zone.
VpcId Changes to this property will trigger replacement. string
The VPC to associate with the private hosted zone.
VpcRegion Changes to this property will trigger replacement. string
The VPC's region. Defaults to the region of the AWS provider.
ZoneId Changes to this property will trigger replacement. string
The private hosted zone to associate.
OwningAccount string
The account ID of the account that created the hosted zone.
VpcId Changes to this property will trigger replacement. string
The VPC to associate with the private hosted zone.
VpcRegion Changes to this property will trigger replacement. string
The VPC's region. Defaults to the region of the AWS provider.
ZoneId Changes to this property will trigger replacement. string
The private hosted zone to associate.
owningAccount String
The account ID of the account that created the hosted zone.
vpcId Changes to this property will trigger replacement. String
The VPC to associate with the private hosted zone.
vpcRegion Changes to this property will trigger replacement. String
The VPC's region. Defaults to the region of the AWS provider.
zoneId Changes to this property will trigger replacement. String
The private hosted zone to associate.
owningAccount string
The account ID of the account that created the hosted zone.
vpcId Changes to this property will trigger replacement. string
The VPC to associate with the private hosted zone.
vpcRegion Changes to this property will trigger replacement. string
The VPC's region. Defaults to the region of the AWS provider.
zoneId Changes to this property will trigger replacement. string
The private hosted zone to associate.
owning_account str
The account ID of the account that created the hosted zone.
vpc_id Changes to this property will trigger replacement. str
The VPC to associate with the private hosted zone.
vpc_region Changes to this property will trigger replacement. str
The VPC's region. Defaults to the region of the AWS provider.
zone_id Changes to this property will trigger replacement. str
The private hosted zone to associate.
owningAccount String
The account ID of the account that created the hosted zone.
vpcId Changes to this property will trigger replacement. String
The VPC to associate with the private hosted zone.
vpcRegion Changes to this property will trigger replacement. String
The VPC's region. Defaults to the region of the AWS provider.
zoneId Changes to this property will trigger replacement. String
The private hosted zone to associate.

Import

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

Using pulumi 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 AWS Provider:

$ pulumi import aws:route53/zoneAssociation:ZoneAssociation example Z123456ABCDEFG:vpc-12345678
Copy

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

$ pulumi import aws:route53/zoneAssociation:ZoneAssociation example Z123456ABCDEFG:vpc-12345678:us-east-2
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.