From 7551f9293f5f92b57e506cefe7ee8968347feb72 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Thu, 8 Feb 2018 14:57:11 -0500 Subject: [PATCH] resource/aws_ecs_service: Use Read after Create and retry on ServiceNotFound for new resources --- aws/resource_aws_ecs_service.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_ecs_service.go b/aws/resource_aws_ecs_service.go index 0bc7b2e3c21..9f4fb374152 100644 --- a/aws/resource_aws_ecs_service.go +++ b/aws/resource_aws_ecs_service.go @@ -311,7 +311,7 @@ func resourceAwsEcsServiceCreate(d *schema.ResourceData, meta interface{}) error log.Printf("[DEBUG] ECS service created: %s", *service.ServiceArn) d.SetId(*service.ServiceArn) - return resourceAwsEcsServiceUpdate(d, meta) + return resourceAwsEcsServiceRead(d, meta) } func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { @@ -323,7 +323,18 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error { Cluster: aws.String(d.Get("cluster").(string)), } - out, err := conn.DescribeServices(&input) + var out *ecs.DescribeServicesOutput + err := resource.Retry(2*time.Minute, func() *resource.RetryError { + var err error + out, err = conn.DescribeServices(&input) + if err != nil { + if d.IsNewResource() && isAWSErr(err, ecs.ErrCodeServiceNotFoundException, "") { + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) if err != nil { return err }