diff --git a/builtin/providers/aws/resource_aws_eip.go b/builtin/providers/aws/resource_aws_eip.go index f871e764d..d8e802704 100644 --- a/builtin/providers/aws/resource_aws_eip.go +++ b/builtin/providers/aws/resource_aws_eip.go @@ -140,7 +140,9 @@ func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error { address := describeAddresses.Addresses[0] d.Set("association_id", address.AssociationID) - d.Set("instance", address.InstanceID) + if address.InstanceID != nil { + d.Set("instance", address.InstanceID) + } d.Set("private_ip", address.PrivateIPAddress) d.Set("public_ip", address.PublicIP) @@ -173,6 +175,9 @@ func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] EIP associate configuration: %#v (domain: %v)", assocOpts, domain) _, err := ec2conn.AssociateAddress(assocOpts) if err != nil { + // Prevent saving instance if association failed + // e.g. missing internet gateway in VPC + d.Set("instance", "") return fmt.Errorf("Failure associating instances: %s", err) } }