From 24b6098f692f8f052dc1f1cee2ed8ab7dcd56db9 Mon Sep 17 00:00:00 2001 From: stack72 Date: Thu, 10 Oct 2019 15:06:41 +0200 Subject: [PATCH 1/2] resource/ecs_service: Add support for customTimeout on delete Deletes can take a long time depending on how long the drain of the service takes. This can lead to errors like: ``` timeout while waiting for state to become 'INACTIVE' (last state: 'DRAINING', timeout: 10m0s) ``` This provides the option for a user to override the delete timeout --- aws/resource_aws_ecs_service.go | 6 +++++- website/docs/r/ecs_service.html.markdown | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_ecs_service.go b/aws/resource_aws_ecs_service.go index ae10d1f38f67..977435116ff9 100644 --- a/aws/resource_aws_ecs_service.go +++ b/aws/resource_aws_ecs_service.go @@ -27,6 +27,10 @@ func resourceAwsEcsService() *schema.Resource { State: resourceAwsEcsServiceImport, }, + Timeouts: &schema.ResourceTimeout{ + Delete: schema.DefaultTimeout(20 * time.Minute), + }, + Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, @@ -950,7 +954,7 @@ func resourceAwsEcsServiceDelete(d *schema.ResourceData, meta interface{}) error Cluster: aws.String(d.Get("cluster").(string)), } // Wait until the ECS service is drained - 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 ECS service %s", input) _, err := conn.DeleteService(&input) if err != nil { diff --git a/website/docs/r/ecs_service.html.markdown b/website/docs/r/ecs_service.html.markdown index 650cad4b3e8e..f5ee470850de 100644 --- a/website/docs/r/ecs_service.html.markdown +++ b/website/docs/r/ecs_service.html.markdown @@ -166,6 +166,13 @@ In addition to all arguments above, the following attributes are exported: * `iam_role` - The ARN of IAM role used for ELB * `desired_count` - The number of instances of the task definition +## Timeouts + +`aws_ecs_service` provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `delete` - (Default `20 minutes`) + ## Import ECS services can be imported using the `name` together with ecs cluster `name`, e.g. From 0aac0b7752f64abb84e49e24a6cd5dd7372a7680 Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Tue, 30 Jun 2020 14:33:06 +0300 Subject: [PATCH 2/2] Update website/docs/r/ecs_service.html.markdown Co-authored-by: angie pinilla --- website/docs/r/ecs_service.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/ecs_service.html.markdown b/website/docs/r/ecs_service.html.markdown index f5ee470850de..bac87303f742 100644 --- a/website/docs/r/ecs_service.html.markdown +++ b/website/docs/r/ecs_service.html.markdown @@ -169,7 +169,7 @@ In addition to all arguments above, the following attributes are exported: ## Timeouts `aws_ecs_service` provides the following -[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: +[Timeouts](/docs/configuration/resources.html#operation-timeouts) configuration options: - `delete` - (Default `20 minutes`)