@@ -95,9 +95,7 @@ func testSweepCloudflareAccountMembers(r string) error {
9595 for _ , resourceGroup := range resourceGroups .Result {
9696 // Only sweep test resource groups with names matching test patterns
9797 if utils .ShouldSweepResource (resourceGroup .Name ) {
98- _ , err := client2 .IAM .ResourceGroups .Delete (ctx , resourceGroup .ID , iam.ResourceGroupDeleteParams {
99- AccountID : cloudflarev6 .String (accountID ),
100- })
98+ err = deleteDomainGroup (accountID , resourceGroup .ID )
10199 if err != nil {
102100 tflog .Error (ctx , fmt .Sprintf ("Failed to delete resource group %s: %s" , resourceGroup .ID , err ))
103101 continue
@@ -429,6 +427,10 @@ func TestAccCloudflareAccountMember_PoliciesAddResourceGroup(t *testing.T) {
429427 },
430428 },
431429 })
430+
431+ //cleanup
432+ deleteDomainGroup (accountID , domainGroupID1 )
433+ deleteDomainGroup (accountID , domainGroupID2 )
432434}
433435
434436func testCloudflareAccountMemberPoliciesConfig (accountID , emailAddress , permgroupId string ) string {
@@ -527,3 +529,12 @@ func createDomainGroup(t *testing.T, rnd, accountID, domainID string) string {
527529 }
528530 return response .Result .ID
529531}
532+
533+ func deleteDomainGroup (accountID , domainID string ) error {
534+ ctx := context .Background ()
535+ client := acctest .SharedClient ()
536+ _ , err := client .IAM .ResourceGroups .Delete (ctx , domainID , iam.ResourceGroupDeleteParams {
537+ AccountID : cloudflarev6 .String (accountID ),
538+ })
539+ return err
540+ }
0 commit comments