From 02f14ae34aabd6cf25b521c7993602e21d9923d1 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Tue, 22 Dec 2015 07:17:35 -0600 Subject: [PATCH] provider/aws: fix CheckDestroy on glacier vault --- .../aws/resource_aws_glacier_vault_test.go | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_glacier_vault_test.go b/builtin/providers/aws/resource_aws_glacier_vault_test.go index 4f5c26bf2..009cfb03d 100644 --- a/builtin/providers/aws/resource_aws_glacier_vault_test.go +++ b/builtin/providers/aws/resource_aws_glacier_vault_test.go @@ -182,11 +182,26 @@ func testAccCheckVaultNotificationsMissing(name string) resource.TestCheckFunc { } func testAccCheckGlacierVaultDestroy(s *terraform.State) error { - if len(s.RootModule().Resources) > 0 { - return fmt.Errorf("Expected all resources to be gone, but found: %#v", - s.RootModule().Resources) - } + conn := testAccProvider.Meta().(*AWSClient).glacierconn + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_glacier_vault" { + continue + } + + input := &glacier.DescribeVaultInput{ + VaultName: aws.String(rs.Primary.ID), + } + if _, err := conn.DescribeVault(input); err != nil { + // Verify the error is what we want + if ae, ok := err.(awserr.Error); ok && ae.Code() == "ResourceNotFoundException" { + continue + } + + return err + } + return fmt.Errorf("still exists") + } return nil }