From 24bcac42be0e2fbac621baf8f753ef2e6c1eb68d Mon Sep 17 00:00:00 2001 From: Clint Date: Thu, 16 Jun 2016 10:03:16 -0500 Subject: [PATCH] provider/aws: Retry EIP association (#7186) --- builtin/providers/aws/resource_aws_eip.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_eip.go b/builtin/providers/aws/resource_aws_eip.go index 89b0094fd..eb38f6124 100644 --- a/builtin/providers/aws/resource_aws_eip.go +++ b/builtin/providers/aws/resource_aws_eip.go @@ -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