providers/aws: route53_zone fix importing id-only private zone

This commit is contained in:
Mitchell Hashimoto 2016-04-21 09:05:58 -07:00
parent b684ec69a6
commit 6f091efd9b
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 14 additions and 0 deletions

View File

@ -164,10 +164,24 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("[DEBUG] Error setting name servers for: %s, error: %#v", d.Id(), err)
}
// In the import case we just associate it with the first VPC
if _, ok := d.GetOk("vpc_id"); !ok {
if len(zone.VPCs) > 1 {
return fmt.Errorf(
"Can't import a route53_zone with more than one VPC attachment")
}
if len(zone.VPCs) > 0 {
d.Set("vpc_id", zone.VPCs[0].VPCId)
d.Set("vpc_region", zone.VPCs[0].VPCRegion)
}
}
var associatedVPC *route53.VPC
for _, vpc := range zone.VPCs {
if *vpc.VPCId == d.Get("vpc_id") {
associatedVPC = vpc
break
}
}
if associatedVPC == nil {