Skip to content

Commit

Permalink
Issue hashicorp#2174 Check that InternetGateway exists before returni…
Browse files Browse the repository at this point in the history
…ng from creation

Fix some random InvalidInternetGatewayID.NotFound errors
  • Loading branch information
carlossg committed Apr 9, 2016
1 parent c7e5b24 commit 77da95b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions builtin/providers/aws/resource_aws_internet_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,27 @@ func resourceAwsInternetGatewayCreate(d *schema.ResourceData, meta interface{})
return err
}

resource.Retry(5*time.Minute, func() *resource.RetryError {
_, err := conn.DescribeInternetGateways(&ec2.DescribeInternetGatewaysInput{
InternetGatewayIds: []*string{aws.String(d.Id())},
})
if err == nil {
return nil
}

ec2err, ok := err.(awserr.Error)
if !ok {
return resource.RetryableError(err)
}

switch ec2err.Code() {
case "InvalidInternetGatewayID.NotFound":
return resource.RetryableError(err) // retry
}

return resource.NonRetryableError(err)
})

// Attach the new gateway to the correct vpc
return resourceAwsInternetGatewayAttach(d, meta)
}
Expand Down

0 comments on commit 77da95b

Please sign in to comment.