[AWS] Retry AttachInternetGateway and increase timeout (#7891)
This commit is contained in:
parent
23560bab6f
commit
e3b7760af4
|
@ -168,9 +168,21 @@ func resourceAwsInternetGatewayAttach(d *schema.ResourceData, meta interface{})
|
||||||
d.Id(),
|
d.Id(),
|
||||||
d.Get("vpc_id").(string))
|
d.Get("vpc_id").(string))
|
||||||
|
|
||||||
_, err := conn.AttachInternetGateway(&ec2.AttachInternetGatewayInput{
|
err := resource.Retry(2*time.Minute, func() *resource.RetryError {
|
||||||
InternetGatewayId: aws.String(d.Id()),
|
_, err := conn.AttachInternetGateway(&ec2.AttachInternetGatewayInput{
|
||||||
VpcId: aws.String(d.Get("vpc_id").(string)),
|
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 {
|
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(
|
||||||
|
|
Loading…
Reference in New Issue