[AWS] Retry AttachInternetGateway and increase timeout (#7891)

This commit is contained in:
Carlos Sanchez 2016-08-08 03:30:14 +02:00 committed by Paul Stack
parent 23560bab6f
commit e3b7760af4
1 changed files with 16 additions and 4 deletions

View File

@ -168,10 +168,22 @@ func resourceAwsInternetGatewayAttach(d *schema.ResourceData, meta interface{})
d.Id(), d.Id(),
d.Get("vpc_id").(string)) d.Get("vpc_id").(string))
err := resource.Retry(2*time.Minute, func() *resource.RetryError {
_, err := conn.AttachInternetGateway(&ec2.AttachInternetGatewayInput{ _, err := conn.AttachInternetGateway(&ec2.AttachInternetGatewayInput{
InternetGatewayId: aws.String(d.Id()), InternetGatewayId: aws.String(d.Id()),
VpcId: aws.String(d.Get("vpc_id").(string)), 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 { if err != nil {
return err return err
} }
@ -187,7 +199,7 @@ func resourceAwsInternetGatewayAttach(d *schema.ResourceData, meta interface{})
Pending: []string{"detached", "attaching"}, Pending: []string{"detached", "attaching"},
Target: []string{"available"}, Target: []string{"available"},
Refresh: IGAttachStateRefreshFunc(conn, d.Id(), "available"), Refresh: IGAttachStateRefreshFunc(conn, d.Id(), "available"),
Timeout: 1 * time.Minute, Timeout: 4 * time.Minute,
} }
if _, err := stateConf.WaitForState(); err != nil { if _, err := stateConf.WaitForState(); err != nil {
return fmt.Errorf( return fmt.Errorf(