Merge pull request #3914 from TimeIncOSS/b-aws-ecs-service-gone

provider/aws: Prevent crashing when deleting ecs_service which is gone
This commit is contained in:
Radek Simko 2015-11-16 21:46:06 +00:00
commit a8ceda1b15
1 changed files with 8 additions and 0 deletions

View File

@ -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
}
@ -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" {