Skip to content

Commit

Permalink
Merge pull request #1899 from c4po/import-resource_okta_group_members…
Browse files Browse the repository at this point in the history
…hips

fix import okta_group_memberships
  • Loading branch information
duytiennguyen-okta authored Feb 21, 2024
2 parents 334a48e + 8acaaec commit b7055d1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions okta/resource_okta_group_memberships.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package okta

import (
"context"
"errors"
"fmt"
"strings"
"time"

"github.com/cenkalti/backoff/v4"
Expand All @@ -18,8 +20,22 @@ func resourceGroupMemberships() *schema.Resource {
ReadContext: resourceGroupMembershipsRead,
UpdateContext: resourceGroupMembershipsUpdate,
DeleteContext: resourceGroupMembershipsDelete,
Importer: createNestedResourceImporter([]string{"id", "track_all_users"}),
Description: "Resource to manage a set of group memberships for a specific group.",
Importer: &schema.ResourceImporter{
StateContext: func(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
importID := strings.Split(d.Id(), "/")
if len(importID) > 2 {
return nil, errors.New("invalid format used for import ID, format must be 'group_id' or 'group_id/true'")
}
if len(importID) == 2 {
d.Set("track_all_users", importID[1] == "true")
}
d.SetId(importID[0])
d.Set("group_id", importID[0])
return []*schema.ResourceData{d}, nil
},
},

Description: "Resource to manage a set of group memberships for a specific group.",
Schema: map[string]*schema.Schema{
"group_id": {
Type: schema.TypeString,
Expand Down

0 comments on commit b7055d1

Please sign in to comment.