diff --git a/builtin/providers/aws/resource_aws_route53_zone.go b/builtin/providers/aws/resource_aws_route53_zone.go index ad918884a..4cbd24d2d 100644 --- a/builtin/providers/aws/resource_aws_route53_zone.go +++ b/builtin/providers/aws/resource_aws_route53_zone.go @@ -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 {