diff --git a/builtin/providers/aws/resource_aws_route53_zone_association.go b/builtin/providers/aws/resource_aws_route53_zone_association.go index ab8b5ad76..084246b75 100644 --- a/builtin/providers/aws/resource_aws_route53_zone_association.go +++ b/builtin/providers/aws/resource_aws_route53_zone_association.go @@ -27,9 +27,9 @@ func resourceAwsRoute53ZoneAssociation() *schema.Resource { Required: true, }, - "region": &schema.Schema{ + "vpc_region": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, }, "association_id": &schema.Schema{ @@ -47,10 +47,13 @@ func resourceAwsRoute53ZoneAssociationCreate(d *schema.ResourceData, meta interf HostedZoneID: aws.String(d.Get("zone_id").(string)), VPC: &route53.VPC{ VPCID: aws.String(d.Get("vpc_id").(string)), - VPCRegion: aws.String(d.Get("region").(string)), + VPCRegion: aws.String(meta.(*AWSClient).region), }, Comment: aws.String("Managed by Terraform"), } + if w := d.Get("vpc_region"); w != nil { + req.VPC.VPCRegion = aws.String(w.(string)) + } log.Printf("[DEBUG] Associating Route53 Private Zone %s with VPC %s", *req.HostedZoneID, *req.VPC.VPCID) resp, err := r53.AssociateVPCWithHostedZone(req) @@ -106,10 +109,13 @@ func resourceAwsRoute53ZoneAssociationDelete(d *schema.ResourceData, meta interf HostedZoneID: aws.String(d.Get("zone_id").(string)), VPC: &route53.VPC{ VPCID: aws.String(d.Get("vpc_id").(string)), - VPCRegion: aws.String(d.Get("region").(string)), + VPCRegion: aws.String(meta.(*AWSClient).region), }, Comment: aws.String("Managed by Terraform"), } + if w := d.Get("vpc_region"); w != nil { + req.VPC.VPCRegion = aws.String(w.(string)) + } _, err := r53.DisassociateVPCFromHostedZone(req) if err != nil { diff --git a/builtin/providers/aws/resource_aws_route53_zone_association_test.go b/builtin/providers/aws/resource_aws_route53_zone_association_test.go index f9f1d8ff1..691e2cb92 100644 --- a/builtin/providers/aws/resource_aws_route53_zone_association_test.go +++ b/builtin/providers/aws/resource_aws_route53_zone_association_test.go @@ -77,25 +77,25 @@ func testAccCheckRoute53ZoneAssociationExists(n string, zone *route53.HostedZone } const testAccRoute53ZoneAssociationConfig = ` -resource "aws_vpc" "mosakos" { +resource "aws_vpc" "foo" { cidr_block = "10.6.0.0/16" - enable_dns_hostnames = true enable_dns_support = true } -resource "aws_route53_zone" "main" { - name = "mosakos.com" - - tags { - foo = "bar" - Name = "tf-route53-tag-test" - } +resource "aws_vpc" "bar" { + cidr_block = "10.7.0.0/16" + enable_dns_hostnames = true + enable_dns_support = true } -resource "aws_route53_zone_association" "main" { - vpc_id = "${aws_vpc.mosakos.id}" - zone_id = "${aws_route53_zone.main.id}" - region = "us-west-2" +resource "aws_route53_zone" "foo" { + name = "foo.com" + vpc_id = "${aws_vpc.foo.id}" +} + +resource "aws_route53_zone_association" "foobar" { + zone_id = "${aws_route53_zone.foo.id}" + vpc_id = "${aws_vpc.bar.id}" } `