Handle public zones correctly. Check for associate when reading.

This commit is contained in:
John Engelman 2015-05-08 10:06:27 -05:00
parent 8e62a14f29
commit 052ff83670
2 changed files with 11 additions and 3 deletions

View File

@ -65,7 +65,7 @@ func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) erro
HostedZoneConfig: comment, HostedZoneConfig: comment,
CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)), CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)),
} }
if v := d.Get("vpc_id"); v != nil { if v := d.Get("vpc_id"); v != "" {
req.VPC = &route53.VPC{ req.VPC = &route53.VPC{
VPCID: aws.String(v.(string)), VPCID: aws.String(v.(string)),
VPCRegion: aws.String(meta.(*AWSClient).region), VPCRegion: aws.String(meta.(*AWSClient).region),
@ -130,7 +130,15 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
} }
} else { } else {
d.Set("name_servers", nil); d.Set("name_servers", nil);
//TODO Verify that the configure VPC is still associated var associatedVPC *route53.VPC
for _, vpc := range zone.VPCs {
if (*vpc.VPCID == d.Get("vpc_id")) {
associatedVPC = vpc
}
}
if associatedVPC == nil {
return fmt.Errorf("[DEBUG] VPC: %v is not associated with Zone: %v", d.Get("vpc_id"), d.Id())
}
} }
// get tags // get tags

View File

@ -173,7 +173,7 @@ func testAccCheckRoute53ZoneAssociationExists(n string, zone *route53.GetHostedZ
} }
} }
if associatedVPC == nil { if associatedVPC == nil {
return fmt.Errorf("VPC: %v is not associated to Zone: %v") return fmt.Errorf("VPC: %v is not associated to Zone: %v", n, cleanZoneID(*zone.HostedZone.ID))
} }
return nil return nil
} }