Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] aws/eip: Don't save instance ID if association fails #1776

Merged
merged 1 commit into from
May 4, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion builtin/providers/aws/resource_aws_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
}
}
Expand Down