Skip to content

azurermSynapseRoleAssignment

Manages a Synapse Role Assignment.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermStorageAccountExample = new azurerm.storageAccount.StorageAccount(
  this,
  "example_1",
  {
    account_kind: "StorageV2",
    account_replication_type: "LRS",
    account_tier: "Standard",
    is_hns_enabled: "true",
    location: azurermResourceGroupExample.location,
    name: "examplestorageacc",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageAccountExample.overrideLogicalId("example");
const azurermStorageDataLakeGen2FilesystemExample =
  new azurerm.storageDataLakeGen2Filesystem.StorageDataLakeGen2Filesystem(
    this,
    "example_2",
    {
      name: "example",
      storage_account_id: azurermStorageAccountExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageDataLakeGen2FilesystemExample.overrideLogicalId("example");
const azurermSynapseWorkspaceExample =
  new azurerm.synapseWorkspace.SynapseWorkspace(this, "example_3", {
    identity: [
      {
        type: "SystemAssigned",
      },
    ],
    location: azurermResourceGroupExample.location,
    name: "example",
    resource_group_name: azurermResourceGroupExample.name,
    sql_administrator_login: "sqladminuser",
    sql_administrator_login_password: "H@Sh1CoR3!",
    storage_data_lake_gen2_filesystem_id:
      azurermStorageDataLakeGen2FilesystemExample.id,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSynapseWorkspaceExample.overrideLogicalId("example");
const dataAzurermClientConfigCurrent =
  new azurerm.dataAzurermClientConfig.DataAzurermClientConfig(
    this,
    "current",
    {}
  );
const azurermSynapseFirewallRuleExample =
  new azurerm.synapseFirewallRule.SynapseFirewallRule(this, "example_5", {
    end_ip_address: "255.255.255.255",
    name: "AllowAll",
    start_ip_address: "0.0.0.0",
    synapse_workspace_id: azurermSynapseWorkspaceExample.id,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSynapseFirewallRuleExample.overrideLogicalId("example");
const azurermSynapseRoleAssignmentExample =
  new azurerm.synapseRoleAssignment.SynapseRoleAssignment(this, "example_6", {
    depends_on: [`\${${azurermSynapseFirewallRuleExample.fqn}}`],
    principal_id: dataAzurermClientConfigCurrent.objectId,
    role_name: "Synapse SQL Administrator",
    synapse_workspace_id: azurermSynapseWorkspaceExample.id,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSynapseRoleAssignmentExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • synapseWorkspaceId - (Optional) The Synapse Workspace which the Synapse Role Assignment applies to. Changing this forces a new resource to be created.

  • synapseSparkPoolId - (Optional) The Synapse Spark Pool which the Synapse Role Assignment applies to. Changing this forces a new resource to be created.

-> NOTE: A Synapse firewall rule including local IP is needed to allow access. Only one of synapseWorkspaceId, synapseSparkPoolId must be set.

  • roleName - (Required) The Role Name of the Synapse Built-In Role. Changing this forces a new resource to be created.

-> NOTE: Currently, the Synapse built-in roles are apacheSparkAdministrator, synapseAdministrator, synapseArtifactPublisher, synapseArtifactUser, synapseComputeOperator, synapseContributor, synapseCredentialUser, synapseLinkedDataManager, synapseMonitoringOperator, synapseSqlAdministrator and synapseUser.

-> NOTE: Old roles are still supported: workspaceAdmin, apacheSparkAdmin, sqlAdmin. These values will be removed in the next Major Version 3.0.

  • principalId - (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.

Attributes Reference

The following attributes are exported:

  • id - The Synapse Role Assignment ID.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Synapse Role Assignment.
  • read - (Defaults to 5 minutes) Used when retrieving the Synapse Role Assignment.
  • delete - (Defaults to 30 minutes) Used when deleting the Synapse Role Assignment.

Import

Synapse Role Assignment can be imported using the resourceId, e.g.

terraform import azurerm_synapse_role_assignment.example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Synapse/workspaces/workspace1|000000000000"

-> NOTE: This ID is specific to Terraform - and is of the format {synapseScope}|{synapseRoleAssignmentId}.