@@ -112,8 +112,18 @@ module ccwBastion './bastion.bicep' = if (deploy_bastion) {
112112 }
113113}
114114
115- param cyclecloudBaseImage string = 'azurecyclecloud:azure-cyclecloud:cyclecloud8-gen2:8.7.220250630'
115+ var vmMiName = 'ccwCycleCloudVirtualMachineManagedIdentity'
116+ module ccwVirtualMachineManagedIdentity './vmManagedIdentity.bicep' = if (!infrastructureOnly && storageAccount .type == 'new' ) {
117+ name : vmMiName
118+ params : {
119+ name : vmMiName
120+ location : location
121+ tags : getTags ('Microsoft.ManagedIdentity/userAssignedIdentities' , tags )
122+ }
123+ }
116124
125+ param cyclecloudBaseImage string = 'azurecyclecloud:azure-cyclecloud:cyclecloud8-gen2:8.7.220250630'
126+ var ccwVirtualMachineManagedIdentityId = !infrastructureOnly ? ( storageAccount .type == 'new' ? ccwVirtualMachineManagedIdentity !.outputs .managedIdentityId : storageAccount .vmManagedIdentityId ) : ''
117127module ccwVM './vm.bicep' = if (!infrastructureOnly ) {
118128 name : 'ccwVM-cyclecloud'
119129 params : {
@@ -151,49 +161,60 @@ module ccwVM './vm.bicep' = if (!infrastructureOnly) {
151161 createOption : split (cyclecloudBaseImage , ':' )[0 ] == 'azurecyclecloud' ? 'FromImage' : 'Empty'
152162 }
153163 ]
164+ managedIdentityId : ccwVirtualMachineManagedIdentityId
154165 }
155166 dependsOn : [
156167 ccwNetwork
157168 ]
158169}
159170
160- var miName = 'ccwLockerManagedIdentity'
161- module ccwManagedIdentity 'mi.bicep' = if (!infrastructureOnly ) {
162- name : miName
171+ module ccwNewStorageAccount './storage-new.bicep' = if (storageAccount .type == 'new' ) {
172+ name : 'ccwNewStorageAccount'
163173 params : {
164- name : miName
165174 location : location
166- storageAccountName : ccwStorage .outputs .storageAccountName
167- tags : getTags ('Microsoft.ManagedIdentity/userAssignedIdentities' , tags )
175+ tags : getTags ('Microsoft.Storage/storageAccounts' , tags )
168176 }
169177}
178+ var storageAccountName = storageAccount .type == 'existing' ? split (storageAccount .storageAccountId , '/' )[8 ] : ccwNewStorageAccount !.outputs .storageAccountName
170179
171- module ccwRoleAssignments './vmRoleAssignments.bicep' = if (!infrastructureOnly ) {
172- name : 'ccwRoleFor-${ccVMName }-${location }'
173- scope : subscription ()
180+ module ccwStorageNetworking './storage-networking.bicep' = {
181+ name : 'ccwStorageAccountNetworking'
174182 params : {
175- roles : [
176- 'Contributor'
177- 'Storage Account Contributor'
178- 'Storage Blob Data Contributor'
179- ]
180- principalId : ccwVM .outputs .principalId
183+ location : location
184+ saName : storageAccountName
185+ tags : getTags ('Microsoft.Storage/storageAccounts' , tags )
186+ subnetId : subnets .cyclecloud .id
187+ storagePrivateDnsZone : storagePrivateDnsZone
181188 }
182- dependsOn : [
183- ccwVM
184- ]
185189}
186190
187- module ccwStorage './storage.bicep' = {
188- name : 'ccwStorage'
191+ var vmssMiName = 'ccwLockerManagedIdentity'
192+ module ccwVMSSManagedIdentity 'vmssManagedIdentity.bicep' = if (!infrastructureOnly && storageAccount .type == 'new' ) {
193+ name : vmssMiName
189194 params : {
195+ name : vmssMiName
190196 location : location
191- tags : getTags ('Microsoft.Storage/storageAccounts' , tags )
192- saName : 'ccwstorage${uniqueString (az .resourceGroup ().id )}'
193- subnetId : subnets .cyclecloud .id
194- storagePrivateDnsZone : storagePrivateDnsZone
197+ storageAccountName : storageAccountName
198+ tags : getTags ('Microsoft.ManagedIdentity/userAssignedIdentities' , tags )
195199 }
196200}
201+ var vmssManagedIdentityId = !infrastructureOnly ? ( storageAccount .type == 'new' ? ccwVMSSManagedIdentity !.outputs .managedIdentityId : storageAccount .vmssManagedIdentityId ) : ''
202+
203+ // module ccwRoleAssignments './vmRoleAssignments.bicep' = if (!infrastructureOnly) {
204+ // name: 'ccwRoleFor-${ccVMName}-${location}'
205+ // scope: subscription()
206+ // params: {
207+ // roles: [
208+ // 'Contributor'
209+ // 'Storage Account Contributor'
210+ // 'Storage Blob Data Contributor'
211+ // ]
212+ // principalId: ccwVM.outputs.principalId
213+ // }
214+ // dependsOn: [
215+ // ccwVM
216+ // ]
217+ // }
197218
198219var create_database = contains (slurmSettings , 'databaseAdminPassword' )
199220var db_name = 'ccw-mysqldb-${uniqueString (az .resourceGroup ().id )}'
@@ -313,9 +334,10 @@ output filerInfoFinal types.filerInfo_t = {
313334 }
314335}
315336
316- output cyclecloudPrincipalId string = infrastructureOnly ? '' : ccwVM .outputs .principalId
337+ output cyclecloudPrincipalId string = infrastructureOnly ? '' : ccwVM ! .outputs .principalId
317338
318- output managedIdentityId string = infrastructureOnly ? '' : ccwManagedIdentity .outputs .managedIdentityId
339+ // MI for VMSS
340+ output managedIdentityId string = vmssManagedIdentityId
319341
320342// Automatically inject the ccw and pyxis cluster init specs
321343
@@ -369,7 +391,7 @@ var clusterNameCleaned = join(clusterNameArrCleaned,'')
369391
370392output resourceGroup string = resourceGroup
371393output location string = location
372- output storageAccountName string = ccwStorage . outputs . storageAccountName
394+ output storageAccountName string = storageAccountName
373395output clusterName string = clusterNameCleaned
374396output publicKey string = publicKey
375397output adminUsername string = adminUsername
0 commit comments