providers/aws: route53_zone fix importing id-only private zone
This commit is contained in:
parent
b684ec69a6
commit
6f091efd9b
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue