Skip to content

Commit

Permalink
provider/aws: Handle deleted CloudFormation stack gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Mar 13, 2016
1 parent d361802 commit cb4c2a9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion builtin/providers/aws/resource_aws_cloudformation_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,20 @@ func resourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface{}
}
resp, err := conn.DescribeStacks(input)
if err != nil {
awsErr, ok := err.(awserr.Error)
// ValidationError: Stack with id % does not exist
if ok && awsErr.Code() == "ValidationError" {
log.Printf("[WARN] Removing CloudFormation stack %s as it's already gone", d.Id())
d.SetId("")
return nil
}

return err
}

stacks := resp.Stacks
if len(stacks) < 1 {
log.Printf("[DEBUG] Removing CloudFormation stack %s as it's already gone", d.Id())
log.Printf("[WARN] Removing CloudFormation stack %s as it's already gone", d.Id())
d.SetId("")
return nil
}
Expand Down Expand Up @@ -392,6 +400,7 @@ func resourceAwsCloudFormationStackDelete(d *schema.ResourceData, meta interface
log.Printf("[DEBUG] Error when deleting CloudFormation stack: %s: %s",
awsErr.Code(), awsErr.Message())

// ValidationError: Stack with id % does not exist
if awsErr.Code() == "ValidationError" {
return resp, "DELETE_COMPLETE", nil
}
Expand Down

0 comments on commit cb4c2a9

Please sign in to comment.