Skip to content

Commit

Permalink
Upated Synapse Workspace module
Browse files Browse the repository at this point in the history
  • Loading branch information
krbar committed Nov 13, 2023
1 parent 0976d44 commit 2cf11a3
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 59 deletions.
69 changes: 44 additions & 25 deletions modules/synapse/workspace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
type: 'SelfHosted'
}
]
managedIdentities: {
userAssignedResourcesIds: [
'<managedIdentityResourceId>'
]
}
managedVirtualNetwork: true
privateEndpoints: [
{
Expand All @@ -402,9 +407,6 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
roleDefinitionIdOrName: 'Reader'
}
]
userAssignedIdentities: {
'<managedIdentityResourceId>': {}
}
}
}
```
Expand Down Expand Up @@ -468,6 +470,13 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
}
]
},
"managedIdentities": {
"value": {
"userAssignedResourcesIds": [
"<managedIdentityResourceId>"
]
}
},
"managedVirtualNetwork": {
"value": true
},
Expand Down Expand Up @@ -495,11 +504,6 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
"roleDefinitionIdOrName": "Reader"
}
]
},
"userAssignedIdentities": {
"value": {
"<managedIdentityResourceId>": {}
}
}
}
}
Expand Down Expand Up @@ -552,6 +556,11 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
type: 'SelfHosted'
}
]
managedIdentities: {
userAssignedResourcesIds: [
'<managedIdentityResourceId>'
]
}
managedVirtualNetwork: true
privateEndpoints: [
{
Expand All @@ -574,9 +583,6 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
roleDefinitionIdOrName: 'Reader'
}
]
userAssignedIdentities: {
'<managedIdentityResourceId>': {}
}
}
}
```
Expand Down Expand Up @@ -640,6 +646,13 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
}
]
},
"managedIdentities": {
"value": {
"userAssignedResourcesIds": [
"<managedIdentityResourceId>"
]
}
},
"managedVirtualNetwork": {
"value": true
},
Expand Down Expand Up @@ -667,11 +680,6 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
"roleDefinitionIdOrName": "Reader"
}
]
},
"userAssignedIdentities": {
"value": {
"<managedIdentityResourceId>": {}
}
}
}
}
Expand Down Expand Up @@ -708,6 +716,7 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
| [`linkedAccessCheckOnTargetResource`](#parameter-linkedaccesscheckontargetresource) | bool | Linked Access Check On Target Resource. |
| [`location`](#parameter-location) | string | The geo-location where the resource lives. |
| [`lock`](#parameter-lock) | object | The lock settings of the service. |
| [`managedIdentities`](#parameter-managedidentities) | object | The managed identity definition for this resource. |
| [`managedResourceGroupName`](#parameter-managedresourcegroupname) | string | Workspace managed resource group. The resource group name uniquely identifies the resource group within the user subscriptionId. The resource group name must be no longer than 90 characters long, and must be alphanumeric characters (Char.IsLetterOrDigit()) and '-', '_', '(', ')' and'.'. Note that the name cannot end with '.'. |
| [`managedVirtualNetwork`](#parameter-managedvirtualnetwork) | bool | Enable this to ensure that connection from your workspace to your data sources use Azure Private Links. You can create managed private endpoints to your data sources. |
| [`preventDataExfiltration`](#parameter-preventdataexfiltration) | bool | Prevent Data Exfiltration. |
Expand All @@ -717,7 +726,6 @@ module workspace 'br:bicep/modules/synapse.workspace:1.0.0' = {
| [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalId' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. |
| [`sqlAdministratorLoginPassword`](#parameter-sqladministratorloginpassword) | string | Password for administrator access to the workspace's SQL pools. If you don't provide a password, one will be automatically generated. You can change the password later. |
| [`tags`](#parameter-tags) | object | Tags of the resource. |
| [`userAssignedIdentities`](#parameter-userassignedidentities) | object | The ID(s) to assign to the resource. |
| [`workspaceRepositoryConfiguration`](#parameter-workspacerepositoryconfiguration) | object | Git integration settings. |

### Parameter: `allowedAadTenantIdsForLinking`
Expand Down Expand Up @@ -959,6 +967,24 @@ Optional. Specify the name of lock.
- Required: No
- Type: string

### Parameter: `managedIdentities`

The managed identity definition for this resource.
- Required: No
- Type: object


| Name | Required | Type | Description |
| :-- | :-- | :--| :-- |
| [`userAssignedResourcesIds`](#parameter-managedidentitiesuserassignedresourcesids) | Yes | array | Optional. The resource ID(s) to assign to the resource. |

### Parameter: `managedIdentities.userAssignedResourcesIds`

Optional. The resource ID(s) to assign to the resource.

- Required: Yes
- Type: array

### Parameter: `managedResourceGroupName`

Workspace managed resource group. The resource group name uniquely identifies the resource group within the user subscriptionId. The resource group name must be no longer than 90 characters long, and must be alphanumeric characters (Char.IsLetterOrDigit()) and '-', '_', '(', ')' and'.'. Note that the name cannot end with '.'.
Expand Down Expand Up @@ -1292,13 +1318,6 @@ Tags of the resource.
- Required: No
- Type: object

### Parameter: `userAssignedIdentities`

The ID(s) to assign to the resource.
- Required: No
- Type: object
- Default: `{}`

### Parameter: `workspaceRepositoryConfiguration`

Git integration settings.
Expand All @@ -1316,7 +1335,7 @@ Git integration settings.
| `name` | string | The name of the deployed Synapse Workspace. |
| `resourceGroupName` | string | The resource group of the deployed Synapse Workspace. |
| `resourceID` | string | The resource ID of the deployed Synapse Workspace. |
| `systemAssignedPrincipalId` | string | The principal ID of the system assigned identity. |
| `systemAssignedMIPrincipalId` | string | The principal ID of the system assigned identity. |

## Cross-referenced modules

Expand Down
24 changes: 15 additions & 9 deletions modules/synapse/workspace/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ param sqlAdministratorLoginPassword string = ''
@description('Optional. Git integration settings.')
param workspaceRepositoryConfiguration object = {}

@description('Optional. The ID(s) to assign to the resource.')
param userAssignedIdentities object = {}
@description('Optional. The managed identity definition for this resource.')
param managedIdentities managedIdentitiesType

@description('Optional. The lock settings of the service.')
param lock lockType
Expand All @@ -92,15 +92,16 @@ param privateEndpoints privateEndpointType
param diagnosticSettings diagnosticSettingType

// Variables
var userAssignedIdentitiesUnion = union(userAssignedIdentities, !empty(customerManagedKey.?userAssignedIdentityResourceId ?? []) ? {
'${customerManagedKey!.userAssignedIdentityResourceId}': {}
} : {})

var identityType = !empty(userAssignedIdentitiesUnion) ? 'SystemAssigned,UserAssigned' : 'SystemAssigned'
var cmkUserAssignedIdentityAsArray = !empty(customerManagedKey.?userAssignedIdentityResourceId ?? []) ? [ customerManagedKey.?userAssignedIdentityResourceId ] : []

var userAssignedIdentitiesUnion = !empty(managedIdentities) ? union(managedIdentities.?userAssignedResourcesIds ?? [], cmkUserAssignedIdentityAsArray) : cmkUserAssignedIdentityAsArray

var formattedUserAssignedIdentities = reduce(map((userAssignedIdentitiesUnion ?? []), (id) => { '${id}': {} }), {}, (cur, next) => union(cur, next)) // Converts the flat array to an object like { '${id1}': {}, '${id2}': {} }

var identity = {
type: identityType
userAssignedIdentities: !empty(userAssignedIdentitiesUnion) ? userAssignedIdentitiesUnion : null
type: !empty(userAssignedIdentitiesUnion) ? 'SystemAssigned,UserAssigned' : 'SystemAssigned'
userAssignedIdentities: !empty(formattedUserAssignedIdentities) ? formattedUserAssignedIdentities : null
}

var enableReferencedModulesTelemetry = false
Expand Down Expand Up @@ -312,7 +313,7 @@ output resourceGroupName string = resourceGroup().name
output connectivityEndpoints object = workspace.properties.connectivityEndpoints

@description('The principal ID of the system assigned identity.')
output systemAssignedPrincipalId string = contains(workspace.identity, 'principalId') ? workspace.identity.principalId : ''
output systemAssignedMIPrincipalId string = contains(workspace.identity, 'principalId') ? workspace.identity.principalId : ''

@description('The location the resource was deployed into.')
output location string = workspace.location
Expand All @@ -321,6 +322,11 @@ output location string = workspace.location
// Definitions //
// =============== //

type managedIdentitiesType = {
@description('Optional. The resource ID(s) to assign to the resource.')
userAssignedResourcesIds: string[]
}?

type lockType = {
@description('Optional. Specify the name of lock.')
name: string?
Expand Down
57 changes: 36 additions & 21 deletions modules/synapse/workspace/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,29 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.22.6.54827",
"templateHash": "2450269560530411916"
"version": "0.23.1.45101",
"templateHash": "17402441205082083392"
},
"name": "Synapse Workspaces",
"description": "This module deploys a Synapse Workspace.",
"owner": "Azure/module-maintainers"
},
"definitions": {
"managedIdentitiesType": {
"type": "object",
"properties": {
"userAssignedResourcesIds": {
"type": "array",
"items": {
"type": "string"
},
"metadata": {
"description": "Optional. The resource ID(s) to assign to the resource."
}
}
},
"nullable": true
},
"lockType": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -555,11 +570,10 @@
"description": "Optional. Git integration settings."
}
},
"userAssignedIdentities": {
"type": "object",
"defaultValue": {},
"managedIdentities": {
"$ref": "#/definitions/managedIdentitiesType",
"metadata": {
"description": "Optional. The ID(s) to assign to the resource."
"description": "Optional. The managed identity definition for this resource."
}
},
"lock": {
Expand Down Expand Up @@ -588,11 +602,12 @@
}
},
"variables": {
"userAssignedIdentitiesUnion": "[union(parameters('userAssignedIdentities'), if(not(empty(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), createArray()))), createObject(format('{0}', parameters('customerManagedKey').userAssignedIdentityResourceId), createObject()), createObject()))]",
"identityType": "[if(not(empty(variables('userAssignedIdentitiesUnion'))), 'SystemAssigned,UserAssigned', 'SystemAssigned')]",
"cmkUserAssignedIdentityAsArray": "[if(not(empty(coalesce(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId'), createArray()))), createArray(tryGet(parameters('customerManagedKey'), 'userAssignedIdentityResourceId')), createArray())]",
"userAssignedIdentitiesUnion": "[if(not(empty(parameters('managedIdentities'))), union(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourcesIds'), createArray()), variables('cmkUserAssignedIdentityAsArray')), variables('cmkUserAssignedIdentityAsArray'))]",
"formattedUserAssignedIdentities": "[reduce(map(coalesce(variables('userAssignedIdentitiesUnion'), createArray()), lambda('id', createObject(format('{0}', lambdaVariables('id')), createObject()))), createObject(), lambda('cur', 'next', union(lambdaVariables('cur'), lambdaVariables('next'))))]",
"identity": {
"type": "[variables('identityType')]",
"userAssignedIdentities": "[if(not(empty(variables('userAssignedIdentitiesUnion'))), variables('userAssignedIdentitiesUnion'), null())]"
"type": "[if(not(empty(variables('userAssignedIdentitiesUnion'))), 'SystemAssigned,UserAssigned', 'SystemAssigned')]",
"userAssignedIdentities": "[if(not(empty(variables('formattedUserAssignedIdentities'))), variables('formattedUserAssignedIdentities'), null())]"
},
"enableReferencedModulesTelemetry": false,
"builtInRoleNames": {
Expand Down Expand Up @@ -772,8 +787,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.22.6.54827",
"templateHash": "3121962670071772951"
"version": "0.23.1.45101",
"templateHash": "15433128731134325120"
},
"name": "Synapse Workspace Integration Runtimes",
"description": "This module deploys a Synapse Workspace Integration Runtime.",
Expand Down Expand Up @@ -891,8 +906,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.22.6.54827",
"templateHash": "7188161900918132964"
"version": "0.23.1.45101",
"templateHash": "1182711601328740781"
}
},
"parameters": {
Expand Down Expand Up @@ -979,8 +994,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.22.6.54827",
"templateHash": "5952844918734432483"
"version": "0.23.1.45101",
"templateHash": "17878422697036938783"
},
"name": "Synapse Workspaces Keys",
"description": "This module deploys a Synapse Workspaces Key.",
Expand Down Expand Up @@ -1154,8 +1169,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.22.6.54827",
"templateHash": "12078057657290521609"
"version": "0.23.1.45101",
"templateHash": "6873008238043407177"
},
"name": "Private Endpoints",
"description": "This module deploys a Private Endpoint.",
Expand Down Expand Up @@ -1557,8 +1572,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.22.6.54827",
"templateHash": "16391702514342252839"
"version": "0.23.1.45101",
"templateHash": "17578977753131828304"
},
"name": "Private Endpoint Private DNS Zone Groups",
"description": "This module deploys a Private Endpoint Private DNS Zone Group.",
Expand Down Expand Up @@ -1728,7 +1743,7 @@
},
"value": "[reference('workspace').connectivityEndpoints]"
},
"systemAssignedPrincipalId": {
"systemAssignedMIPrincipalId": {
"type": "string",
"metadata": {
"description": "The principal ID of the system assigned identity."
Expand Down
6 changes: 4 additions & 2 deletions modules/synapse/workspace/tests/e2e/max/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ module testDeployment '../../../main.bicep' = {
defaultDataLakeStorageFilesystem: nestedDependencies.outputs.storageContainerName
sqlAdministratorLogin: 'synwsadmin'
initialWorkspaceAdminObjectID: nestedDependencies.outputs.managedIdentityPrincipalId
userAssignedIdentities: {
'${nestedDependencies.outputs.managedIdentityResourceId}': {}
managedIdentities: {
userAssignedResourcesIds: [
nestedDependencies.outputs.managedIdentityResourceId
]
}
roleAssignments: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ module testDeployment '../../../main.bicep' = {
defaultDataLakeStorageFilesystem: nestedDependencies.outputs.storageContainerName
sqlAdministratorLogin: 'synwsadmin'
initialWorkspaceAdminObjectID: nestedDependencies.outputs.managedIdentityPrincipalId
userAssignedIdentities: {
'${nestedDependencies.outputs.managedIdentityResourceId}': {}
managedIdentities: {
userAssignedResourcesIds: [
nestedDependencies.outputs.managedIdentityResourceId
]
}
roleAssignments: [
{
Expand Down

0 comments on commit 2cf11a3

Please sign in to comment.