mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/aws: fix CheckDestroy for iam_group_policy tests
This commit is contained in:
parent
c8e88ed1b4
commit
fd528df002
@ -5,6 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"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/iam"
|
"github.com/aws/aws-sdk-go/service/iam"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
@ -39,8 +40,30 @@ func TestAccAWSIAMGroupPolicy_basic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckIAMGroupPolicyDestroy(s *terraform.State) error {
|
func testAccCheckIAMGroupPolicyDestroy(s *terraform.State) error {
|
||||||
if len(s.RootModule().Resources) > 0 {
|
conn := testAccProvider.Meta().(*AWSClient).iamconn
|
||||||
return fmt.Errorf("Expected all resources to be gone, but found: %#v", s.RootModule().Resources)
|
|
||||||
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
if rs.Type != "aws_iam_group_policy" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
group, name := resourceAwsIamGroupPolicyParseId(rs.Primary.ID)
|
||||||
|
|
||||||
|
request := &iam.GetGroupPolicyInput{
|
||||||
|
PolicyName: aws.String(name),
|
||||||
|
GroupName: aws.String(group),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := conn.GetGroupPolicy(request)
|
||||||
|
if err != nil {
|
||||||
|
// Verify the error is what we want
|
||||||
|
if ae, ok := err.(awserr.Error); ok && ae.Code() == "NoSuchEntity" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("still exists")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user