renamed region to vpc_region for clarity and made optional, updated tests

This commit is contained in:
Panagiotis Moustafellos 2015-05-08 10:16:24 +03:00 committed by John Engelman
parent 450c42f166
commit d02e247fc7
2 changed files with 23 additions and 17 deletions

View File

@ -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 {

View File

@ -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}"
}
`