Skip to content

Commit

Permalink
resource/aws_ecs_service: Use Read after Create and retry on ServiceN…
Browse files Browse the repository at this point in the history
…otFound for new resources
  • Loading branch information
bflad committed Feb 8, 2018
1 parent e63a014 commit 7551f92
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions aws/resource_aws_ecs_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down

0 comments on commit 7551f92

Please sign in to comment.