Skip to content

Commit

Permalink
Issue hashicorp#2174 Reuse IGStateRefreshFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossg committed Apr 11, 2016
1 parent 77da95b commit 1b4e828
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions builtin/providers/aws/resource_aws_internet_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,15 @@ func resourceAwsInternetGatewayCreate(d *schema.ResourceData, meta interface{})
}

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

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

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

return resource.NonRetryableError(err)
})

// Attach the new gateway to the correct vpc
Expand Down

0 comments on commit 1b4e828

Please sign in to comment.