Skip to content

Commit

Permalink
[AWS] Retry AttachInternetGateway and increase timeout (#7891)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossg authored and stack72 committed Aug 8, 2016
1 parent 23560ba commit e3b7760
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions builtin/providers/aws/resource_aws_internet_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,21 @@ func resourceAwsInternetGatewayAttach(d *schema.ResourceData, meta interface{})
d.Id(),
d.Get("vpc_id").(string))

_, err := conn.AttachInternetGateway(&ec2.AttachInternetGatewayInput{
InternetGatewayId: aws.String(d.Id()),
VpcId: aws.String(d.Get("vpc_id").(string)),
err := resource.Retry(2*time.Minute, func() *resource.RetryError {
_, err := conn.AttachInternetGateway(&ec2.AttachInternetGatewayInput{
InternetGatewayId: aws.String(d.Id()),
VpcId: aws.String(d.Get("vpc_id").(string)),
})
if err == nil {
return nil
}
if ec2err, ok := err.(awserr.Error); ok {
switch ec2err.Code() {
case "InvalidInternetGatewayID.NotFound":
return resource.RetryableError(err) // retry
}
}
return resource.NonRetryableError(err)
})
if err != nil {
return err
Expand All @@ -187,7 +199,7 @@ func resourceAwsInternetGatewayAttach(d *schema.ResourceData, meta interface{})
Pending: []string{"detached", "attaching"},
Target: []string{"available"},
Refresh: IGAttachStateRefreshFunc(conn, d.Id(), "available"),
Timeout: 1 * time.Minute,
Timeout: 4 * time.Minute,
}
if _, err := stateConf.WaitForState(); err != nil {
return fmt.Errorf(
Expand Down

0 comments on commit e3b7760

Please sign in to comment.