Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 24bcac4

Browse files
authored
provider/aws: Retry EIP association (hashicorp#7186)
1 parent 5fdcf5d commit 24bcac4

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

builtin/providers/aws/resource_aws_eip.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,20 @@ func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error {
208208
}
209209
}
210210

211-
log.Printf("[DEBUG] EIP associate configuration: %#v (domain: %v)", assocOpts, domain)
212-
_, err := ec2conn.AssociateAddress(assocOpts)
211+
log.Printf("[DEBUG] EIP associate configuration: %s (domain: %s)", assocOpts, domain)
212+
213+
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
214+
_, err := ec2conn.AssociateAddress(assocOpts)
215+
if err != nil {
216+
if awsErr, ok := err.(awserr.Error); ok {
217+
if awsErr.Code() == "InvalidAllocationID.NotFound" {
218+
return resource.RetryableError(awsErr)
219+
}
220+
}
221+
return resource.NonRetryableError(err)
222+
}
223+
return nil
224+
})
213225
if err != nil {
214226
// Prevent saving instance if association failed
215227
// e.g. missing internet gateway in VPC

0 commit comments

Comments
 (0)