provider/aws: fix CheckDestroy on glacier vault

This commit is contained in:
Paul Hinze 2015-12-22 07:17:35 -06:00
parent 7d6b98060a
commit 02f14ae34a
1 changed files with 19 additions and 4 deletions

View File

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