provider/aws: Retry RouteTable Route/Assocation creation (#7156)
* provider/aws: Retry RouteTable Assocation creation * provider/aws: retry route creation * remove extra string check
This commit is contained in:
parent
4796e27d1a
commit
627efa21f4
|
@ -301,7 +301,19 @@ func resourceAwsRouteTableUpdate(d *schema.ResourceData, meta interface{}) error
|
|||
}
|
||||
|
||||
log.Printf("[INFO] Creating route for %s: %#v", d.Id(), opts)
|
||||
if _, err := conn.CreateRoute(&opts); err != nil {
|
||||
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
|
||||
_, err := conn.CreateRoute(&opts)
|
||||
if err != nil {
|
||||
if awsErr, ok := err.(awserr.Error); ok {
|
||||
if awsErr.Code() == "InvalidRouteTableID.NotFound" {
|
||||
return resource.RetryableError(awsErr)
|
||||
}
|
||||
}
|
||||
return resource.NonRetryableError(err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,12 @@ package aws
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -40,11 +42,25 @@ func resourceAwsRouteTableAssociationCreate(d *schema.ResourceData, meta interfa
|
|||
d.Get("subnet_id").(string),
|
||||
d.Get("route_table_id").(string))
|
||||
|
||||
resp, err := conn.AssociateRouteTable(&ec2.AssociateRouteTableInput{
|
||||
associationOpts := ec2.AssociateRouteTableInput{
|
||||
RouteTableId: aws.String(d.Get("route_table_id").(string)),
|
||||
SubnetId: aws.String(d.Get("subnet_id").(string)),
|
||||
})
|
||||
}
|
||||
|
||||
var resp *ec2.AssociateRouteTableOutput
|
||||
var err error
|
||||
err = resource.Retry(2*time.Minute, func() *resource.RetryError {
|
||||
resp, err = conn.AssociateRouteTable(&associationOpts)
|
||||
if err != nil {
|
||||
if awsErr, ok := err.(awserr.Error); ok {
|
||||
if awsErr.Code() == "InvalidRouteTableID.NotFound" {
|
||||
return resource.RetryableError(awsErr)
|
||||
}
|
||||
}
|
||||
return resource.NonRetryableError(err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue