[bugfix] Don't save instance ID if association fails
- typically happens when no internet GW is available in VPC
This commit is contained in:
parent
15c75c501f
commit
795d53e706
|
@ -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