From 4c226e8688b281988302c619b2eaa26ca9823148 Mon Sep 17 00:00:00 2001 From: Adam Tyler Date: Thu, 29 Oct 2020 22:33:32 -0400 Subject: [PATCH] Check for ClusterNotFoundException and remove service from state --- aws/resource_aws_ecs_service.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aws/resource_aws_ecs_service.go b/aws/resource_aws_ecs_service.go index c141056c8f8..e564361f34e 100644 --- a/aws/resource_aws_ecs_service.go +++ b/aws/resource_aws_ecs_service.go @@ -584,6 +584,13 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { if isResourceTimeoutError(err) { out, err = conn.DescribeServices(&input) } + + if isAWSErr(err, ecs.ErrCodeClusterNotFoundException, "") { + log.Printf("[WARN] ECS Service %s parent cluster %s not found, removing from state.", d.Id(), d.Get("cluster").(string)) + d.SetId("") + return nil + } + if err != nil { return fmt.Errorf("Error reading ECS service: %s", err) }