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

[Modules] Updated NetApp Module to support User Assigned Identities #3347

Merged
merged 4 commits into from
Jun 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ output subnetResourceId string = virtualNetwork.properties.subnets[0].id

@description('The principal ID of the created Managed Identity.')
output managedIdentityPrincipalId string = managedIdentity.properties.principalId

@description('The resource ID of the created Managed Identity.')
output managedIdentityResourceId string = managedIdentity.id
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,8 @@ module testDeployment '../../main.bicep' = {
Role: 'DeploymentValidation'
ServiceName: 'DeploymentValidation'
}
userAssignedIdentities: {
'${nestedDependencies.outputs.managedIdentityResourceId}': {}
}
}
}
42 changes: 42 additions & 0 deletions modules/net-app/net-app-accounts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This module deploys an Azure NetApp File.
| `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'. |
| `smbServerNamePrefix` | string | `''` | | Required if domainName is specified. NetBIOS name of the SMB server. A computer account with this prefix will be registered in the AD and used to mount volumes. |
| `tags` | object | `{object}` | | Tags for all resources. |
| `userAssignedIdentities` | object | `{object}` | | The ID(s) to assign to the resource. |


### Parameter Usage: `roleAssignments`
Expand Down Expand Up @@ -146,6 +147,39 @@ tags: {
</details>
<p>

### Parameter Usage: `userAssignedIdentities`

You can specify multiple user assigned identities to a resource by providing additional resource IDs using the following format:

<details>

<summary>Parameter JSON format</summary>

```json
"userAssignedIdentities": {
"value": {
"/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001": {},
"/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002": {}
}
}
```

</details>

<details>

<summary>Bicep format</summary>

```bicep
userAssignedIdentities: {
'/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001': {}
'/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002': {}
}
```

</details>
<p>

## Outputs

| Output Name | Type | Description |
Expand Down Expand Up @@ -545,6 +579,9 @@ module netAppAccounts './net-app/net-app-accounts/main.bicep' = {
Role: 'DeploymentValidation'
ServiceName: 'DeploymentValidation'
}
userAssignedIdentities: {
'<managedIdentityResourceId>': {}
}
}
}
```
Expand Down Expand Up @@ -669,6 +706,11 @@ module netAppAccounts './net-app/net-app-accounts/main.bicep' = {
"Role": "DeploymentValidation",
"ServiceName": "DeploymentValidation"
}
},
"userAssignedIdentities": {
"value": {
"<managedIdentityResourceId>": {}
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions modules/net-app/net-app-accounts/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ param smbServerNamePrefix string = ''
@description('Optional. Capacity pools to create.')
param capacityPools array = []

@description('Optional. The ID(s) to assign to the resource.')
param userAssignedIdentities object = {}

@description('Optional. 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\'.')
param roleAssignments array = []

Expand Down Expand Up @@ -56,6 +59,13 @@ var activeDirectoryConnectionProperties = [
}
]

var identityType = !empty(userAssignedIdentities) ? 'UserAssigned' : 'None'

var identity = identityType != 'None' ? {
type: identityType
userAssignedIdentities: !empty(userAssignedIdentities) ? userAssignedIdentities : null
} : null

resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) {
name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name)}'
properties: {
Expand All @@ -71,6 +81,7 @@ resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (ena
resource netAppAccount 'Microsoft.NetApp/netAppAccounts@2022-09-01' = {
name: name
tags: tags
identity: identity
location: location
properties: {
activeDirectories: !empty(domainName) ? activeDirectoryConnectionProperties : null
Expand Down