provider/aws: Retry EIP association (#7186)

This commit is contained in:
Clint 2016-06-16 10:03:16 -05:00 committed by GitHub
parent 5fdcf5d16a
commit 24bcac42be
1 changed files with 14 additions and 2 deletions

View File

@ -208,8 +208,20 @@ func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error {
}
}
log.Printf("[DEBUG] EIP associate configuration: %#v (domain: %v)", assocOpts, domain)
_, err := ec2conn.AssociateAddress(assocOpts)
log.Printf("[DEBUG] EIP associate configuration: %s (domain: %s)", assocOpts, domain)
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := ec2conn.AssociateAddress(assocOpts)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == "InvalidAllocationID.NotFound" {
return resource.RetryableError(awsErr)
}
}
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
// Prevent saving instance if association failed
// e.g. missing internet gateway in VPC