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

resource/aws_eip_association: fix eventual consistency issue when associating EIP #16808

Merged
merged 2 commits into from
Dec 18, 2020
Merged
Changes from 1 commit
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
25 changes: 24 additions & 1 deletion aws/resource_aws_eip_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,30 @@ func resourceAwsEipAssociationRead(d *schema.ResourceData, meta interface{}) err
return err
}

response, err := conn.DescribeAddresses(request)
var response *ec2.DescribeAddressesOutput
err = resource.Retry(2*time.Minute, func() *resource.RetryError {
dohoangkhiem marked this conversation as resolved.
Show resolved Hide resolved
var err error
response, err = conn.DescribeAddresses(request)

if tfawserr.ErrCodeEquals(err, "InvalidAssociationID.NotFound") {
dohoangkhiem marked this conversation as resolved.
Show resolved Hide resolved
return resource.RetryableError(err)
}

if d.IsNewResource() && (response.Addresses == nil || len(response.Addresses) == 0) {
return resource.RetryableError(&resource.NotFoundError{})
}

if err != nil {
return resource.NonRetryableError(err)
}

return nil
})

if isResourceTimeoutError(err) {
response, err = conn.DescribeAddresses(request)
}
dohoangkhiem marked this conversation as resolved.
Show resolved Hide resolved

if err != nil {
return fmt.Errorf("Error reading EC2 Elastic IP %s: %#v", d.Get("allocation_id").(string), err)
}
Expand Down