Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_synapse_role_assignment: New parameter principal_type #24089

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions internal/services/synapse/synapse_role_assignment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ func resourceSynapseRoleAssignment() *pluginsdk.Resource {
ValidateFunc: validation.IsUUID,
},

"principal_type": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"User",
"Group",
"ServicePrincipal",
}, false),
},

"role_name": {
Type: pluginsdk.TypeString,
Required: true,
Expand Down Expand Up @@ -165,6 +176,12 @@ func resourceSynapseRoleAssignmentCreate(d *pluginsdk.ResourceData, meta interfa
PrincipalID: &principalID,
Scope: utils.String(scope),
}

if v, ok := d.GetOk("principal_type"); ok {
principalType := v.(string)
roleAssignment.PrincipalType = &principalType
}

resp, err := client.CreateRoleAssignment(ctx, roleAssignment, uuid)
if err != nil {
return fmt.Errorf("creating Synapse RoleAssignment %q: %+v", roleName, err)
Expand Down Expand Up @@ -225,6 +242,12 @@ func resourceSynapseRoleAssignmentRead(d *pluginsdk.ResourceData, meta interface
}
d.Set("principal_id", principalID)

principalType := ""
if resp.PrincipalType != nil {
principalType = *resp.PrincipalType
}
d.Set("principal_type", principalType)

synapseWorkspaceId := ""
synapseSparkPoolId := ""
if _, err := parse.WorkspaceIDInsensitively(id.Scope); err == nil {
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/synapse_role_assignment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ The following arguments are supported:

* `principal_id` - (Required) The ID of the Principal (User, Group or Service Principal) to assign the Synapse Role Definition to. Changing this forces a new resource to be created.

* `principal_type` (Optional) The Type of the Principal. One of `User`, `Group` or `ServicePrincipal`. Changing this forces a new resource to be created.

-> **NOTE:** While `principal_type` is optional, it's still recommended to set this value, as some Synapse use-cases may not work correctly if this is not specified. Service Principals for example can't run SQL statements using `Entra ID` authentication if `principal_type` is not set to `ServicePrincipal`.

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:
Expand Down
Loading