Merge pull request #1776 from TimeIncOSS/eip-without-igw
[bugfix] aws/eip: Don't save instance ID if association fails
This commit is contained in:
commit
9617761eb4
|
@ -140,7 +140,9 @@ func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
|
|||
address := describeAddresses.Addresses[0]
|
||||
|
||||
d.Set("association_id", address.AssociationID)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue