aws: Treat CF stacks in DELETE_COMPLETE state as deleted
This commit is contained in:
parent
08ad2d2d7e
commit
f017d2d2d6
|
@ -190,8 +190,18 @@ func resourceAwsCloudFormationStackRead(d *schema.ResourceData, meta interface{}
|
|||
|
||||
stacks := resp.Stacks
|
||||
if len(stacks) < 1 {
|
||||
log.Printf("[DEBUG] Removing CloudFormation stack %s as it's already gone", d.Id())
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
for _, s := range stacks {
|
||||
if *s.StackId == d.Id() && *s.StackStatus == "DELETE_COMPLETE" {
|
||||
log.Printf("[DEBUG] Removing CloudFormation stack %s"+
|
||||
" as it has been already deleted", d.Id())
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
tInput := cloudformation.GetTemplateInput{
|
||||
StackName: aws.String(stackName),
|
||||
|
|
|
@ -101,9 +101,12 @@ func testAccCheckAWSCloudFormationDestroy(s *terraform.State) error {
|
|||
|
||||
resp, err := conn.DescribeStacks(¶ms)
|
||||
|
||||
if err == nil {
|
||||
if len(resp.Stacks) != 0 &&
|
||||
*resp.Stacks[0].StackId == rs.Primary.ID {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, s := range resp.Stacks {
|
||||
if *s.StackId == rs.Primary.ID && *s.StackStatus != "DELETE_COMPLETE" {
|
||||
return fmt.Errorf("CloudFormation stack still exists: %q", rs.Primary.ID)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue