diff --git a/internal/sdkprovider/service/organization/organization_user_group.go b/internal/sdkprovider/service/organization/organization_user_group.go index 1d9fdddbc..595eab430 100644 --- a/internal/sdkprovider/service/organization/organization_user_group.go +++ b/internal/sdkprovider/service/organization/organization_user_group.go @@ -72,12 +72,15 @@ func resourceOrganizationUserGroupCreate(ctx context.Context, d *schema.Resource req usergroup.UserGroupCreateIn ) - if err := schemautil.ResourceDataGet(d, &req); err != nil { + // replace the key in terraform with the correct key in the API + if err := schemautil.ResourceDataGet( + d, + &req, + schemautil.RenameAliases(map[string]string{"name": "user_group_name"}), + ); err != nil { return err } - req.UserGroupName = d.Get("name").(string) - resp, err := client.UserGroupCreate(ctx, orgID, &req) if err != nil { return err @@ -99,19 +102,15 @@ func resourceOrganizationUserGroupReadGen(ctx context.Context, d *schema.Resourc return err } - if err = d.Set("name", resp.UserGroupName); err != nil { - return err - } - if err = d.Set("description", resp.Description); err != nil { - return err - } - if err = d.Set("create_time", resp.CreateTime.String()); err != nil { - return err - } - if err = d.Set("update_time", resp.UpdateTime.String()); err != nil { - return err - } - if err = d.Set("group_id", resp.UserGroupId); err != nil { + if err = schemautil.ResourceDataSet( + aivenOrganizationUserGroupSchema, + d, + resp, + schemautil.RenameAliases(map[string]string{ + "user_group_name": "name", + "user_group_id": "group_id", + }), + ); err != nil { return err }