Skip to content

Commit

Permalink
[bugfix] Don't save instance ID if association fails
Browse files Browse the repository at this point in the history
 - typically happens when no internet GW is available in VPC
  • Loading branch information
Radek Simko committed Apr 20, 2015
1 parent 46a400d commit b052eca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion builtin/providers/aws/resource_aws_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,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)

Expand Down Expand Up @@ -165,6 +167,7 @@ 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 {
d.Set("instance", "")
return fmt.Errorf("Failure associating instances: %s", err)
}
}
Expand Down

0 comments on commit b052eca

Please sign in to comment.