Skip to content

Commit aa03eb4

Browse files
xhy8759Hangyu Xu
andauthored
feat: support shared key vault and create secrets in azlocal (#4716)
## Description <!-- >Thank you for your contribution ! > Please include a summary of the change and which issue is fixed. > Please also include the context. > List any dependencies that are required for this change. Fixes #123 Fixes #456 Closes #123 Closes #456 --> ## Pipeline Reference <!-- Insert your Pipeline Status Badge below --> | Pipeline | | -------- | | [![avm.res.azure-stack-hci.cluster](https://github.com/Infrastructure-as-code-Automation/bicep-registry-modules/actions/workflows/avm.res.azure-stack-hci.cluster.yml/badge.svg?branch=hangxu%2Fazlocal2)](https://github.com/Infrastructure-as-code-Automation/bicep-registry-modules/actions/workflows/avm.res.azure-stack-hci.cluster.yml) | ## Type of Change <!-- Use the checkboxes [x] on the options that are relevant. --> - [ ] Update to CI Environment or utilities (Non-module affecting changes) - [ ] Azure Verified Module updates: - [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in `version.json`: - [ ] Someone has opened a bug report issue, and I have included "Closes #{bug_report_issue_number}" in the PR description. - [ ] The bug was found by the module author, and no one has opened an issue to report it yet. - [ ] Feature update backwards compatible feature updates, and I have bumped the MINOR version in `version.json`. - [ ] Breaking changes and I have bumped the MAJOR version in `version.json`. - [ ] Update to documentation ## Checklist - [ ] I'm sure there are no other open Pull Requests for the same update/change - [ ] I have run `Set-AVMModule` locally to generate the supporting module files. - [ ] My corresponding pipelines / checks run clean and green without any errors or warnings <!-- Please keep up to date with the contribution guide at https://aka.ms/avm/contribute/bicep --> --------- Co-authored-by: Hangyu Xu <[email protected]>
1 parent d5c3fff commit aa03eb4

File tree

9 files changed

+801
-34
lines changed

9 files changed

+801
-34
lines changed

avm/res/azure-stack-hci/cluster/README.md

Lines changed: 182 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ This module deploys an Azure Stack HCI Cluster on the provided Arc Machines.
88
- [Usage examples](#Usage-examples)
99
- [Parameters](#Parameters)
1010
- [Outputs](#Outputs)
11-
- [Cross-referenced modules](#Cross-referenced-modules)
1211
- [Data Collection](#Data-Collection)
1312

1413
## Resource Types
@@ -18,6 +17,7 @@ This module deploys an Azure Stack HCI Cluster on the provided Arc Machines.
1817
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
1918
| `Microsoft.AzureStackHCI/clusters` | [2024-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.AzureStackHCI/clusters) |
2019
| `Microsoft.AzureStackHCI/clusters/deploymentSettings` | [2024-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.AzureStackHCI/clusters/deploymentSettings) |
20+
| `Microsoft.KeyVault/vaults/secrets` | [2023-07-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.KeyVault/2023-07-01/vaults/secrets) |
2121

2222
## Usage examples
2323

@@ -156,6 +156,12 @@ module cluster 'br/public:avm/res/azure-stack-hci/cluster:<version>' = {
156156
]
157157
subnetMask: '255.255.255.0'
158158
}
159+
deploymentUser: 'deployUser'
160+
deploymentUserPassword: '<deploymentUserPassword>'
161+
localAdminPassword: '<localAdminPassword>'
162+
localAdminUser: 'admin-hci'
163+
servicePrincipalId: '<servicePrincipalId>'
164+
servicePrincipalSecret: '<servicePrincipalSecret>'
159165
}
160166
}
161167
```
@@ -288,6 +294,24 @@ module cluster 'br/public:avm/res/azure-stack-hci/cluster:<version>' = {
288294
],
289295
"subnetMask": "255.255.255.0"
290296
}
297+
},
298+
"deploymentUser": {
299+
"value": "deployUser"
300+
},
301+
"deploymentUserPassword": {
302+
"value": "<deploymentUserPassword>"
303+
},
304+
"localAdminPassword": {
305+
"value": "<localAdminPassword>"
306+
},
307+
"localAdminUser": {
308+
"value": "admin-hci"
309+
},
310+
"servicePrincipalId": {
311+
"value": "<servicePrincipalId>"
312+
},
313+
"servicePrincipalSecret": {
314+
"value": "<servicePrincipalSecret>"
291315
}
292316
}
293317
}
@@ -416,6 +440,12 @@ param deploymentSettings = {
416440
]
417441
subnetMask: '255.255.255.0'
418442
}
443+
param deploymentUser = 'deployUser'
444+
param deploymentUserPassword = '<deploymentUserPassword>'
445+
param localAdminPassword = '<localAdminPassword>'
446+
param localAdminUser = 'admin-hci'
447+
param servicePrincipalId = '<servicePrincipalId>'
448+
param servicePrincipalSecret = '<servicePrincipalSecret>'
419449
```
420450

421451
</details>
@@ -553,6 +583,12 @@ module cluster 'br/public:avm/res/azure-stack-hci/cluster:<version>' = {
553583
]
554584
subnetMask: '255.255.255.0'
555585
}
586+
deploymentUser: 'deployUser'
587+
deploymentUserPassword: '<deploymentUserPassword>'
588+
localAdminPassword: '<localAdminPassword>'
589+
localAdminUser: 'admin-hci'
590+
servicePrincipalId: '<servicePrincipalId>'
591+
servicePrincipalSecret: '<servicePrincipalSecret>'
556592
tags: {
557593
Environment: 'Non-Prod'
558594
'hidden-title': 'This is visible in the resource name'
@@ -697,6 +733,24 @@ module cluster 'br/public:avm/res/azure-stack-hci/cluster:<version>' = {
697733
"subnetMask": "255.255.255.0"
698734
}
699735
},
736+
"deploymentUser": {
737+
"value": "deployUser"
738+
},
739+
"deploymentUserPassword": {
740+
"value": "<deploymentUserPassword>"
741+
},
742+
"localAdminPassword": {
743+
"value": "<localAdminPassword>"
744+
},
745+
"localAdminUser": {
746+
"value": "admin-hci"
747+
},
748+
"servicePrincipalId": {
749+
"value": "<servicePrincipalId>"
750+
},
751+
"servicePrincipalSecret": {
752+
"value": "<servicePrincipalSecret>"
753+
},
700754
"tags": {
701755
"value": {
702756
"Environment": "Non-Prod",
@@ -837,6 +891,12 @@ param deploymentSettings = {
837891
]
838892
subnetMask: '255.255.255.0'
839893
}
894+
param deploymentUser = 'deployUser'
895+
param deploymentUserPassword = '<deploymentUserPassword>'
896+
param localAdminPassword = '<localAdminPassword>'
897+
param localAdminUser = 'admin-hci'
898+
param servicePrincipalId = '<servicePrincipalId>'
899+
param servicePrincipalSecret = '<servicePrincipalSecret>'
840900
param tags = {
841901
Environment: 'Non-Prod'
842902
'hidden-title': 'This is visible in the resource name'
@@ -855,17 +915,36 @@ param tags = {
855915
| :-- | :-- | :-- |
856916
| [`name`](#parameter-name) | string | The name of the Azure Stack HCI cluster - this must be a valid Active Directory computer name and will be the name of your cluster in Azure. |
857917

918+
**Conditional parameters**
919+
920+
| Parameter | Type | Description |
921+
| :-- | :-- | :-- |
922+
| [`deploymentUser`](#parameter-deploymentuser) | string | The name of the deployment user. Required if useSharedKeyVault is true. |
923+
| [`deploymentUserPassword`](#parameter-deploymentuserpassword) | securestring | The password of the deployment user. Required if useSharedKeyVault is true. |
924+
| [`localAdminPassword`](#parameter-localadminpassword) | securestring | The password of the local admin user. Required if useSharedKeyVault is true. |
925+
| [`localAdminUser`](#parameter-localadminuser) | string | The name of the local admin user. Required if useSharedKeyVault is true. |
926+
| [`servicePrincipalId`](#parameter-serviceprincipalid) | string | The service principal ID for ARB. Required if useSharedKeyVault is true. |
927+
| [`servicePrincipalSecret`](#parameter-serviceprincipalsecret) | string | The service principal secret for ARB. Required if useSharedKeyVault is true. |
928+
858929
**Optional parameters**
859930

860931
| Parameter | Type | Description |
861932
| :-- | :-- | :-- |
933+
| [`azureStackLCMUserCredentialContentType`](#parameter-azurestacklcmusercredentialcontenttype) | string | Content type of the azure stack lcm user credential. |
934+
| [`azureStackLCMUserCredentialTags`](#parameter-azurestacklcmusercredentialtags) | object | Tags of azure stack LCM user credential. |
935+
| [`defaultARBApplicationContentType`](#parameter-defaultarbapplicationcontenttype) | string | Content type of the default ARB application. |
936+
| [`defaultARBApplicationTags`](#parameter-defaultarbapplicationtags) | object | Tags of the default ARB application. |
862937
| [`deploymentOperations`](#parameter-deploymentoperations) | array | The cluster deployment operations to execute. Defaults to "[Validate, Deploy]". |
863938
| [`deploymentSettings`](#parameter-deploymentsettings) | object | The deployment settings of the cluster. |
864939
| [`enableTelemetry`](#parameter-enabletelemetry) | bool | Enable/Disable usage telemetry for module. |
940+
| [`localAdminCredentialContentType`](#parameter-localadmincredentialcontenttype) | string | Content type of the local admin credential. |
941+
| [`localAdminCredentialTags`](#parameter-localadmincredentialtags) | object | Tags of the local admin credential. |
865942
| [`location`](#parameter-location) | string | Location for all resources. |
866943
| [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignments to create. |
867944
| [`tags`](#parameter-tags) | object | Tags of the resource. |
868945
| [`useSharedKeyVault`](#parameter-usesharedkeyvault) | bool | Specify whether to use the shared key vault for the HCI cluster. |
946+
| [`witnessStoragekeyContentType`](#parameter-witnessstoragekeycontenttype) | string | Content type of the witness storage key. |
947+
| [`witnessStoragekeyTags`](#parameter-witnessstoragekeytags) | object | Tags of the witness storage key. |
869948

870949
### Parameter: `name`
871950

@@ -874,6 +953,78 @@ The name of the Azure Stack HCI cluster - this must be a valid Active Directory
874953
- Required: Yes
875954
- Type: string
876955

956+
### Parameter: `deploymentUser`
957+
958+
The name of the deployment user. Required if useSharedKeyVault is true.
959+
960+
- Required: No
961+
- Type: string
962+
963+
### Parameter: `deploymentUserPassword`
964+
965+
The password of the deployment user. Required if useSharedKeyVault is true.
966+
967+
- Required: No
968+
- Type: securestring
969+
970+
### Parameter: `localAdminPassword`
971+
972+
The password of the local admin user. Required if useSharedKeyVault is true.
973+
974+
- Required: No
975+
- Type: securestring
976+
977+
### Parameter: `localAdminUser`
978+
979+
The name of the local admin user. Required if useSharedKeyVault is true.
980+
981+
- Required: No
982+
- Type: string
983+
984+
### Parameter: `servicePrincipalId`
985+
986+
The service principal ID for ARB. Required if useSharedKeyVault is true.
987+
988+
- Required: No
989+
- Type: string
990+
991+
### Parameter: `servicePrincipalSecret`
992+
993+
The service principal secret for ARB. Required if useSharedKeyVault is true.
994+
995+
- Required: No
996+
- Type: string
997+
998+
### Parameter: `azureStackLCMUserCredentialContentType`
999+
1000+
Content type of the azure stack lcm user credential.
1001+
1002+
- Required: No
1003+
- Type: string
1004+
- Default: `'Secret'`
1005+
1006+
### Parameter: `azureStackLCMUserCredentialTags`
1007+
1008+
Tags of azure stack LCM user credential.
1009+
1010+
- Required: No
1011+
- Type: object
1012+
1013+
### Parameter: `defaultARBApplicationContentType`
1014+
1015+
Content type of the default ARB application.
1016+
1017+
- Required: No
1018+
- Type: string
1019+
- Default: `'Secret'`
1020+
1021+
### Parameter: `defaultARBApplicationTags`
1022+
1023+
Tags of the default ARB application.
1024+
1025+
- Required: No
1026+
- Type: object
1027+
8771028
### Parameter: `deploymentOperations`
8781029

8791030
The cluster deployment operations to execute. Defaults to "[Validate, Deploy]".
@@ -1176,6 +1327,21 @@ Enable/Disable usage telemetry for module.
11761327
- Type: bool
11771328
- Default: `True`
11781329

1330+
### Parameter: `localAdminCredentialContentType`
1331+
1332+
Content type of the local admin credential.
1333+
1334+
- Required: No
1335+
- Type: string
1336+
- Default: `'Secret'`
1337+
1338+
### Parameter: `localAdminCredentialTags`
1339+
1340+
Tags of the local admin credential.
1341+
1342+
- Required: No
1343+
- Type: object
1344+
11791345
### Parameter: `location`
11801346

11811347
Location for all resources.
@@ -1304,6 +1470,21 @@ Specify whether to use the shared key vault for the HCI cluster.
13041470
- Type: bool
13051471
- Default: `True`
13061472

1473+
### Parameter: `witnessStoragekeyContentType`
1474+
1475+
Content type of the witness storage key.
1476+
1477+
- Required: No
1478+
- Type: string
1479+
- Default: `'Secret'`
1480+
1481+
### Parameter: `witnessStoragekeyTags`
1482+
1483+
Tags of the witness storage key.
1484+
1485+
- Required: No
1486+
- Type: object
1487+
13071488
## Outputs
13081489

13091490
| Output | Type | Description |
@@ -1314,14 +1495,6 @@ Specify whether to use the shared key vault for the HCI cluster.
13141495
| `resourceId` | string | The ID of the cluster. |
13151496
| `systemAssignedMIPrincipalId` | string | The managed identity of the cluster. |
13161497

1317-
## Cross-referenced modules
1318-
1319-
This section gives you an overview of all local-referenced module files (i.e., other modules that are referenced in this module) and all remote-referenced files (i.e., Bicep modules that are referenced from a Bicep Registry or Template Specs).
1320-
1321-
| Reference | Type |
1322-
| :-- | :-- |
1323-
| `br/public:avm/utl/types/avm-common-types:0.5.1` | Remote reference |
1324-
13251498
## Data Collection
13261499

13271500
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the [repository](https://aka.ms/avm/telemetry). There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

avm/res/azure-stack-hci/cluster/main.bicep

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,50 @@ param roleAssignments roleAssignmentType[]?
3636
@description('Optional. Specify whether to use the shared key vault for the HCI cluster.')
3737
param useSharedKeyVault bool = true
3838

39+
@description('Conditional. The name of the deployment user. Required if useSharedKeyVault is true.')
40+
param deploymentUser string?
41+
42+
@secure()
43+
@description('Conditional. The password of the deployment user. Required if useSharedKeyVault is true.')
44+
param deploymentUserPassword string?
45+
46+
@description('Conditional. The name of the local admin user. Required if useSharedKeyVault is true.')
47+
param localAdminUser string?
48+
49+
@secure()
50+
@description('Conditional. The password of the local admin user. Required if useSharedKeyVault is true.')
51+
param localAdminPassword string?
52+
53+
@description('Conditional. The service principal ID for ARB. Required if useSharedKeyVault is true.')
54+
param servicePrincipalId string?
55+
56+
@description('Conditional. The service principal secret for ARB. Required if useSharedKeyVault is true.')
57+
param servicePrincipalSecret string?
58+
59+
@description('Optional. Content type of the azure stack lcm user credential.')
60+
param azureStackLCMUserCredentialContentType string = 'Secret'
61+
62+
@description('Optional. Content type of the local admin credential.')
63+
param localAdminCredentialContentType string = 'Secret'
64+
65+
@description('Optional. Content type of the witness storage key.')
66+
param witnessStoragekeyContentType string = 'Secret'
67+
68+
@description('Optional. Content type of the default ARB application.')
69+
param defaultARBApplicationContentType string = 'Secret'
70+
71+
@description('Optional. Tags of azure stack LCM user credential.')
72+
param azureStackLCMUserCredentialTags object?
73+
74+
@description('Optional. Tags of the local admin credential.')
75+
param localAdminCredentialTags object?
76+
77+
@description('Optional. Tags of the witness storage key.')
78+
param witnessStoragekeyTags object?
79+
80+
@description('Optional. Tags of the default ARB application.')
81+
param defaultARBApplicationTags object?
82+
3983
// ============= //
4084
// Variables //
4185
// ============= //
@@ -113,6 +157,30 @@ resource cluster 'Microsoft.AzureStackHCI/clusters@2024-04-01' = {
113157
tags: tags
114158
}
115159

160+
module secrets './secrets.bicep' = if (useSharedKeyVault) {
161+
name: '${uniqueString(deployment().name, location)}-secrets'
162+
params: {
163+
clusterName: name
164+
cloudId: cluster.properties.cloudId
165+
keyVaultName: deploymentSettings!.keyVaultName
166+
storageAccountName: deploymentSettings!.clusterWitnessStorageAccountName
167+
deploymentUser: deploymentUser!
168+
deploymentUserPassword: deploymentUserPassword!
169+
localAdminUser: localAdminUser!
170+
localAdminPassword: localAdminPassword!
171+
servicePrincipalId: servicePrincipalId!
172+
servicePrincipalSecret: servicePrincipalSecret!
173+
azureStackLCMUserCredentialContentType: azureStackLCMUserCredentialContentType
174+
localAdminCredentialContentType: localAdminCredentialContentType
175+
witnessStoragekeyContentType: witnessStoragekeyContentType
176+
defaultARBApplicationContentType: defaultARBApplicationContentType
177+
azureStackLCMUserCredentialTags: azureStackLCMUserCredentialTags
178+
localAdminCredentialTags: localAdminCredentialTags
179+
witnessStoragekeyTags: witnessStoragekeyTags
180+
defaultARBApplicationTags: defaultARBApplicationTags
181+
}
182+
}
183+
116184
@batchSize(1)
117185
module deploymentSetting 'deployment-setting/main.bicep' = [
118186
for deploymentOperation in sortedDeploymentOperations: if (!empty(deploymentOperation) && !empty(deploymentSettings)) {
@@ -404,3 +472,16 @@ type deploymentSettingsType = {
404472
@description('Optional. If using a shared key vault or non-legacy secret naming, pass the properties.cloudId guid from the pre-created HCI cluster resource.')
405473
cloudId: string?
406474
}
475+
476+
@export()
477+
@description('Key vault secret names interface')
478+
type KeyVaultSecretNames = {
479+
@description('Required. The name of the Azure Stack HCI LCM user credential secret.')
480+
azureStackLCMUserCredential: string
481+
@description('Required. The name of the Azure Stack HCI local admin credential secret.')
482+
localAdminCredential: string
483+
@description('Required. The name of the Azure Stack HCI default ARB application secret.')
484+
defaultARBApplication: string
485+
@description('Required. The name of the Azure Stack HCI witness storage key secret.')
486+
witnessStorageKey: string
487+
}

0 commit comments

Comments
 (0)