Skip to content

Commit

Permalink
fix access group resource: recreate ag when it is deleted outside ter…
Browse files Browse the repository at this point in the history
…raform
  • Loading branch information
kavya498 committed Apr 25, 2024
1 parent 8cb683b commit 0fe17bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ibm/service/iamaccessgroup/resource_ibm_iam_access_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ package iamaccessgroup
import (
"context"
"fmt"
"time"

"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
"github.com/IBM/go-sdk-core/v5/core"
"github.com/IBM/platform-services-go-sdk/iamaccessgroupsv2"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"time"
)

func ResourceIBMIAMAccessGroup() *schema.Resource {
Expand Down Expand Up @@ -101,7 +102,11 @@ func resourceIBMIAMAccessGroupRead(context context.Context, d *schema.ResourceDa
if conns.IsResourceTimeoutError(err) {
agrp, detailedResponse, err = iamAccessGroupsClient.GetAccessGroup(getAccessGroupOptions)
}
if err != nil || agrp == nil || detailedResponse == nil {
if err != nil || agrp == nil {
if detailedResponse != nil && detailedResponse.StatusCode == 404 {
d.SetId("")
return nil
}
return diag.FromErr(fmt.Errorf("[ERROR] Error retrieving access group: %s. API Response: %s", err, detailedResponse))
}
version := detailedResponse.GetHeaders().Get("etag")
Expand Down

0 comments on commit 0fe17bb

Please sign in to comment.