From 0afc469116fab68d6ccf5114611bc3869efbddd5 Mon Sep 17 00:00:00 2001 From: Dominik Froehlich Date: Tue, 6 Mar 2018 10:47:31 +0100 Subject: [PATCH] Add configurable timeouts to aws_route --- aws/resource_aws_route.go | 13 +++++++++---- website/docs/r/route.html.markdown | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/aws/resource_aws_route.go b/aws/resource_aws_route.go index 9cabe1f3abc..dfb12652957 100644 --- a/aws/resource_aws_route.go +++ b/aws/resource_aws_route.go @@ -28,6 +28,11 @@ func resourceAwsRoute() *schema.Resource { Delete: resourceAwsRouteDelete, Exists: resourceAwsRouteExists, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(2 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "destination_cidr_block": { Type: schema.TypeString, @@ -207,7 +212,7 @@ func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error { // Create the route var err error - err = resource.Retry(2*time.Minute, func() *resource.RetryError { + err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { _, err = conn.CreateRoute(createOpts) if err != nil { @@ -232,7 +237,7 @@ func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error { var route *ec2.Route if v, ok := d.GetOk("destination_cidr_block"); ok { - err = resource.Retry(2*time.Minute, func() *resource.RetryError { + err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { route, err = findResourceRoute(conn, d.Get("route_table_id").(string), v.(string), "") return resource.RetryableError(err) }) @@ -242,7 +247,7 @@ func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error { } if v, ok := d.GetOk("destination_ipv6_cidr_block"); ok { - err = resource.Retry(2*time.Minute, func() *resource.RetryError { + err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { route, err = findResourceRoute(conn, d.Get("route_table_id").(string), "", v.(string)) return resource.RetryableError(err) }) @@ -394,7 +399,7 @@ func resourceAwsRouteDelete(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Route delete opts: %s", deleteOpts) var err error - err = resource.Retry(5*time.Minute, func() *resource.RetryError { + err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { log.Printf("[DEBUG] Trying to delete route with opts %s", deleteOpts) resp, err := conn.DeleteRoute(deleteOpts) log.Printf("[DEBUG] Route delete result: %s", resp) diff --git a/website/docs/r/route.html.markdown b/website/docs/r/route.html.markdown index 63bc45ba298..cc5e34272fe 100644 --- a/website/docs/r/route.html.markdown +++ b/website/docs/r/route.html.markdown @@ -81,3 +81,11 @@ will be exported as an attribute once the resource is created. * `nat_gateway_id` - An ID of a VPC NAT gateway. * `instance_id` - An ID of a NAT instance. * `network_interface_id` - An ID of a network interface. + +## Timeouts + +`aws_route` provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `create` - (Default `2 minutes`) Used for route creation +- `delete` - (Default `5 minutes`) Used for route deletion