diff --git a/docs/resources/group.md b/docs/resources/group.md index 28a5a41..04d73b6 100644 --- a/docs/resources/group.md +++ b/docs/resources/group.md @@ -20,7 +20,8 @@ resource "fusionauth_group" "my_group" { ## Argument Reference +* `group_id` - (Optional) The Id to use for the new Group. If not specified a secure random UUID will be generated. * `data` - (Optional) An object that can hold any information about the Group that should be persisted. * `name` - (Required) The name of the Group. * `role_ids` - (Optional) The Application Roles to assign to this group. -* `tenant_id` - (Required) The unique Id of the tenant used to scope this API request. \ No newline at end of file +* `tenant_id` - (Required) The unique Id of the tenant used to scope this API request. diff --git a/fusionauth/resource_fusionauth_group.go b/fusionauth/resource_fusionauth_group.go index 2d96039..93f5316 100644 --- a/fusionauth/resource_fusionauth_group.go +++ b/fusionauth/resource_fusionauth_group.go @@ -17,6 +17,14 @@ func newGroup() *schema.Resource { UpdateContext: updateGroup, DeleteContext: deleteGroup, Schema: map[string]*schema.Schema{ + "group_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + Description: "The Id to use for the new Group. If not specified a secure random UUID will be generated.", + ValidateFunc: validation.IsUUID, + }, "data": { Type: schema.TypeMap, Optional: true, @@ -47,8 +55,14 @@ func newGroup() *schema.Resource { } func buildGroup(data *schema.ResourceData) fusionauth.GroupRequest { + var gid string + if gi, ok := data.Get("group_id").(string); ok { + gid = gi + } + g := fusionauth.GroupRequest{ Group: fusionauth.Group{ + Id: gid, Data: nil, Name: data.Get("name").(string), TenantId: data.Get("tenant_id").(string), @@ -67,7 +81,7 @@ func createGroup(_ context.Context, data *schema.ResourceData, i interface{}) di defer func() { client.FAClient.TenantId = oldTenantID }() - resp, faErrs, err := client.FAClient.CreateGroup("", g) + resp, faErrs, err := client.FAClient.CreateGroup(g.Group.Id, g) if err != nil { return diag.Errorf("CreateGroup err: %v", err) }