provider/aws: fix CheckDestroy on placement_group tests

This commit is contained in:
Paul Hinze 2015-12-22 10:20:28 -06:00
parent b7e87bbf16
commit df0f65502f
1 changed files with 10 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
) )
@ -34,12 +35,19 @@ func testAccCheckAWSPlacementGroupDestroy(s *terraform.State) error {
if rs.Type != "aws_placement_group" { if rs.Type != "aws_placement_group" {
continue continue
} }
_, err := conn.DeletePlacementGroup(&ec2.DeletePlacementGroupInput{
GroupName: aws.String(rs.Primary.ID), _, err := conn.DescribePlacementGroups(&ec2.DescribePlacementGroupsInput{
GroupNames: []*string{aws.String(rs.Primary.Attributes["name"])},
}) })
if err != nil { if err != nil {
// Verify the error is what we want
if ae, ok := err.(awserr.Error); ok && ae.Code() == "InvalidPlacementGroup.Unknown" {
continue
}
return err return err
} }
return fmt.Errorf("still exists")
} }
return nil return nil
} }