Skip to content

Commit

Permalink
Merge pull request #3914 from TimeIncOSS/b-aws-ecs-service-gone
Browse files Browse the repository at this point in the history
provider/aws: Prevent crashing when deleting ecs_service which is gone
  • Loading branch information
radeksimko committed Nov 16, 2015
2 parents 3158602 + 0822776 commit a8ceda1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions builtin/providers/aws/resource_aws_ecs_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error {
}

if len(out.Services) < 1 {
log.Printf("[DEBUG] Removing ECS service %q because it's gone", service.ServiceArn)
d.SetId("")
return nil
}

Expand Down Expand Up @@ -247,6 +249,12 @@ func resourceAwsEcsServiceDelete(d *schema.ResourceData, meta interface{}) error
if err != nil {
return err
}

if len(resp.Services) == 0 {
log.Printf("[DEBUG] ECS Service %q is already gone", d.Id())
return nil
}

log.Printf("[DEBUG] ECS service %s is currently %s", d.Id(), *resp.Services[0].Status)

if *resp.Services[0].Status == "INACTIVE" {
Expand Down

0 comments on commit a8ceda1

Please sign in to comment.