From 2882fff7ed3d58d1b3f27ca11b4876e994ec86bd Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Wed, 14 Feb 2018 16:52:20 +0000 Subject: [PATCH] resource/aws_ecs_service: Retry DescribeServices after creation --- aws/resource_aws_ecs_service.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_ecs_service.go b/aws/resource_aws_ecs_service.go index 44f7ee092f0..5af2fcfc62f 100644 --- a/aws/resource_aws_ecs_service.go +++ b/aws/resource_aws_ecs_service.go @@ -356,6 +356,16 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { } return resource.NonRetryableError(err) } + + if d.IsNewResource() && len(out.Services) < 1 { + return resource.RetryableError(fmt.Errorf("No ECS service found: %q", d.Id())) + } + + service := out.Services[0] + if d.IsNewResource() && *service.Status == "INACTIVE" { + return resource.RetryableError(fmt.Errorf("ECS service currently INACTIVE: %q", d.Id())) + } + return nil }) if err != nil { @@ -363,7 +373,7 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { } if len(out.Services) < 1 { - log.Printf("[DEBUG] Removing ECS service %s (%s) because it's gone", d.Get("name").(string), d.Id()) + log.Printf("[WARN] Removing ECS service %s (%s) because it's gone", d.Get("name").(string), d.Id()) d.SetId("") return nil } @@ -372,7 +382,7 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { // Status==INACTIVE means deleted service if *service.Status == "INACTIVE" { - log.Printf("[DEBUG] Removing ECS service %q because it's INACTIVE", *service.ServiceArn) + log.Printf("[WARN] Removing ECS service %q because it's INACTIVE", *service.ServiceArn) d.SetId("") return nil }