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

Refactor of outputs to simplify bicep deployments #123

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0a07d3a
Modified stored key output object, updated bicep accordingly
abatallas Oct 1, 2024
fa96ec8
Modified vnet peering output object, updated bicep accordingly
abatallas Oct 1, 2024
45afec5
Modified existing vnet output object, updated bicep accordingly
abatallas Oct 1, 2024
4894022
Modified database output object, updated bicep accordingly
abatallas Oct 2, 2024
abfffcb
Fixed bug with storedKeyId input parameter types in mainTemplate.bice…
abatallas Oct 2, 2024
82f0fc6
Fix empty string error for split() calls with empty resource ID in Bicep
abatallas Oct 2, 2024
978a99d
Remove export path from existing AML UI
abatallas Oct 2, 2024
636152d
Removed prompts to select subnets for existing filers in BYOVnet scen…
abatallas Oct 2, 2024
1f4d1a8
Changed references to ANF service tiers with those of ANF service lev…
abatallas Oct 2, 2024
81d8d24
Fixed small typos in Slurm Settings UI
abatallas Oct 2, 2024
51ff353
Added approved placeholder resource IDs
abatallas Dec 9, 2024
bd8767a
Used safe access operator for bastion rsc ID in ccw.bicep
abatallas Dec 9, 2024
1d078af
Remove dependency on rsc_t type in bicep files
abatallas Dec 18, 2024
2c52eba
Simplify create_cc_param.py and reflect changes to bicep files
abatallas Dec 18, 2024
0af94b9
Bug fix: attempting to use access ID language element that no longer …
abatallas Dec 18, 2024
6a205ea
Merge branch 'main' into abatallas/simplify_outputs
abatallas Dec 18, 2024
27f19ba
Merge branch 'main' into abatallas/simplify_outputs
abatallas Jan 31, 2025
1591e01
Merge branch 'main' into abatallas/simplify_outputs
abatallas Feb 24, 2025
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
14 changes: 8 additions & 6 deletions bicep/ccw.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ param adminUsername string
@secure()
param adminPassword string
param adminSshPublicKey string
param storedKey types.storedKey_t
param storedKeyId string
param ccVMSize string
param resourceGroup string
param sharedFilesystem types.sharedFilesystem_t
Expand All @@ -38,7 +38,7 @@ var useEnteredKey = adminSshPublicKey != ''
module ccwPublicKey './publicKey.bicep' = if (!useEnteredKey && !infrastructureOnly) {
name: 'ccwPublicKey'
params: {
storedKey: storedKey
storedKeyId: storedKeyId
}
}
var publicKey = infrastructureOnly ? '' : (useEnteredKey ? adminSshPublicKey : ccwPublicKey.outputs.publicKey)
Expand Down Expand Up @@ -78,13 +78,15 @@ var subnets = create_new_vnet
additional: { id: join([network.?id, 'subnets', network.?additionalFilerSubnet ?? 'null'], '/') }
}

var existingNetworkId = network.?id ?? 'q/w/e/r/t/y/u/i/o'

output vnet types.networkOutput_t = union(
create_new_vnet
? ccwNetwork.outputs.vnetCCW
: {
id: network.?id ?? ''
name: network.?name
rg: split(network.?id ?? '////', '/')[4]
id: existingNetworkId
name: split(existingNetworkId, '/')[8]
rg: split(existingNetworkId, '/')[4]
},
{
type: network.type
Expand Down Expand Up @@ -225,7 +227,7 @@ module ccwANF 'anf.bicep' = [
tags: getTags('Microsoft.NetApp/netAppAccounts', tags)
name: filer.key
subnetId: subnets[filer.key].id
serviceLevel: filer.value.anfServiceTier
serviceLevel: filer.value.anfServiceLevel
sizeTiB: filer.value.anfCapacityInTiB
defaultMountOptions: anfDefaultMountOptions
infrastructureOnly: infrastructureOnly
Expand Down
4 changes: 2 additions & 2 deletions bicep/mainTemplate.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ param adminUsername string
@secure()
param adminPassword string
param adminSshPublicKey string = ''
param storedKey types.storedKey_t = {id: 'foo', location: 'foo', name:'foo'}
param storedKeyId string = ''
param ccVMSize string
param resourceGroup string
param sharedFilesystem types.sharedFilesystem_t
Expand Down Expand Up @@ -59,7 +59,7 @@ module makeCCWresources 'ccw.bicep' = {
htc: htc
hpc: hpc
gpu: gpu
storedKey: storedKey
storedKeyId: storedKeyId
ccVMSize: ccVMSize
resourceGroup: resourceGroup
databaseAdminPassword: databaseAdminPassword
Expand Down
17 changes: 9 additions & 8 deletions bicep/network-new.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,7 @@ var securityRules = [ for rule in nsgRules : {
rule.value[7] == 'ips' ? { destinationAddressPrefixes: rule.value[8] } : {}
)
}]
//var asgNames = []

var peeringEnabled = contains(network,'vnetToPeer')
var peeredVnetName = peeringEnabled ? network.?vnetToPeer.name : 'foo'
var peeredVnetResourceGroup = peeringEnabled ? split(network.?vnetToPeer.id,'/')[4] : 'foo'
var peeredVnetId = peeringEnabled ? network.?vnetToPeer.id : 'foo'

resource ccwCommonNsg 'Microsoft.Network/networkSecurityGroups@2023-11-01' = {
name: 'nsg-ccw-common'
Expand Down Expand Up @@ -327,13 +322,18 @@ resource ccwVirtualNetwork 'Microsoft.Network/virtualNetworks@2023-11-01' = {
}
}

var peeringEnabled = contains(network,'vnetToPeer')
var peeredVnetId = network.?vnetToPeer.?id ?? 'q/w/e/r/t/y/u/i/o'
var peeredVnetName = split(peeredVnetId,'/')[8]
var peeredVnetResourceGroup = split(peeredVnetId,'/')[4]

resource ccw_to_peer 'Microsoft.Network/virtualNetworks/virtualNetworkPeerings@2023-11-01' = if (peeringEnabled) {
name: '${ccwVirtualNetwork.name}-to-${peeredVnetName}-${uniqueString(resourceGroup().id)}'
parent: ccwVirtualNetwork
properties: {
allowVirtualNetworkAccess: true
allowForwardedTraffic: false
useRemoteGateways: network.?peeringAllowGatewayTransit
useRemoteGateways: network.?vnetToPeer.?allowGatewayTransit
remoteVirtualNetwork: {
id: peeredVnetId
}
Expand Down Expand Up @@ -413,9 +413,10 @@ var subnets = union(
create_database ? { database: subnet_database } : {}
)

var dbID = databaseConfig.?dbId ?? 'q/w/e/r/t/y/u/i/o'
resource ccwDatabase 'Microsoft.DBforMySQL/flexibleServers@2023-10-01-preview' existing = if (create_private_endpoint && databaseConfig.type != 'disabled') {
name: databaseConfig.?dbInfo.?name ?? 'disabled'
scope: resourceGroup(split(databaseConfig.?dbInfo.?id ?? '////','/')[4])
name: split(dbID,'/')[8]
scope: resourceGroup(split(dbID,'/')[4])
}

var privateEndpointName = 'ccw-mysql-pe'
Expand Down
23 changes: 7 additions & 16 deletions bicep/publicKey.bicep
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import {storedKey_t} from './types.bicep'
param storedKey storedKey_t
param storedKeyId string

//TODO: Add autogenerate public key logic via REST API call in uidefinition file
/*
resource autogenerate_publickey 'Microsoft.Compute/sshPublicKeys@2023-09-01' = if (autogenerateSecrets) {
name: 'autoGeneratedKey'
location: location
resource storedPublicKey 'Microsoft.Compute/sshPublicKeys@2024-03-01' existing = {
name: split(storedKeyId,'/')[8]
scope: resourceGroup(split(storedKeyId,'/')[4])
}
*/
resource stored_publickey 'Microsoft.Compute/sshPublicKeys@2024-03-01' existing = {
name: storedKey.name
scope: resourceGroup(split(storedKey.id,'/')[4])
}
//var public_key = autogenerateSecrets ? autogenerate_publickey.properties.generateKey : stored_publickey.properties.publicKey
var public_key = stored_publickey.properties.publicKey
output publicKey string = public_key
//output useStoredKey bool = useStoredKey //satisfy arm-ttk

var publicKey = storedPublicKey.properties.publicKey
output publicKey string = publicKey
27 changes: 7 additions & 20 deletions bicep/types.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type shared_nfs_existing_t = {

type shared_anf_new_t = {
type: 'anf-new'
anfServiceTier: string
anfServiceLevel: string
anfCapacityInTiB: int
}

Expand All @@ -22,7 +22,7 @@ type sharedFilesystem_t = shared_nfs_new_t | shared_nfs_existing_t | shared_anf_

type additional_anf_new_t = {
type: 'anf-new'
anfServiceTier: string
anfServiceLevel: string
anfCapacityInTiB: int
mountPath: string
}
Expand Down Expand Up @@ -81,8 +81,7 @@ type filerInfo_t = {

type peered_vnet_t = {
id: string
location: string
name: string
allowGatewayTransit: bool
}

type vnet_autocreate_t = {
Expand All @@ -96,12 +95,10 @@ type vnet_autocreate_t = {
bastion: bool?
createNatGateway: bool?
vnetToPeer: peered_vnet_t?
peeringAllowGatewayTransit: bool?
}

type vnet_existing_t = {
type: 'existing'
name: string
id: string
cyclecloudSubnet: string
computeSubnet: string
Expand Down Expand Up @@ -200,36 +197,26 @@ type partitions_t = {
gpu: hpc_t //if any property becomes optional, create a *_output_t type
}

@export()
type storedKey_t = {
id: string
location: string
name: string
}

type db_none_t = {
type: 'disabled'
}

type db_fqdn_t = {
type: 'fqdn'
databaseUser: string
fqdn: string
}

type db_privateIp_t = {
type: 'privateIp'
databaseUser: string
privateIp: string
}

type dbInfo_t = {
id: string
location: string
name: string
}

type db_privateEndpoint_t = {
type: 'privateEndpoint'
dbInfo: dbInfo_t
databaseUser: string
dbId: string
}

@export()
Expand Down
38 changes: 18 additions & 20 deletions uidefinitions/createUiDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"visible": true
},
{
"name": "autogeneratePasswordsAndKeys",
"name": "publicKeySource",
"type": "Microsoft.Common.DropDown",
"label": "SSH public key source",
"defaultValue": "Use existing public key",
Expand All @@ -145,11 +145,11 @@
"label": "Admin SSH Public Key",
"toolTip": "SSH-RSA Public Key for the Virtual Machines",
"constraints": {
"required": "[equals(basics('autogeneratePasswordsAndKeys'),'entered')]",
"required": "[equals(basics('publicKeySource'),'entered')]",
"regex": "^ssh-rsa AAAAB3NzaC1yc2[0-9A-Za-z+/]+[=]{0,3}(\\s.*)?$",
"validationMessage": "Invalid ssh-rsa public key"
},
"visible": "[equals(basics('autogeneratePasswordsAndKeys'),'entered')]"
"visible": "[equals(basics('publicKeySource'),'entered')]"
},
{
"name": "keySelector",
Expand All @@ -166,7 +166,7 @@
"required": true,
"validationMessage": "Please select a stored SSH key."
},
"visible": "[equals(basics('autogeneratePasswordsAndKeys'),'stored')]"
"visible": "[equals(basics('publicKeySource'),'stored')]"
},
{
"name": "nullValue",
Expand Down Expand Up @@ -263,7 +263,7 @@
}
},
{
"name": "anftier",
"name": "anfLevel",
"type": "Microsoft.Common.DropDown",
"label": "Service Level",
"defaultValue": "Premium",
Expand Down Expand Up @@ -454,7 +454,7 @@
}
},
{
"name": "anftier",
"name": "anfLevel",
"type": "Microsoft.Common.DropDown",
"label": "Service Level",
"defaultValue": "Premium",
Expand Down Expand Up @@ -592,7 +592,7 @@
"regex": "^\/(?:[\\w-.]+\/)*[\\w-.]+$",
"validationMessage": "Must be an absolute path"
},
"visible": "[equals(steps('filesystem').additional.newexisting, 'existing')]"
"visible": "[and(equals(steps('filesystem').additional.filertype,'nfs'),equals(steps('filesystem').additional.newexisting,'existing'))]"
},
{
"name": "mountOptions",
Expand Down Expand Up @@ -772,7 +772,7 @@
"allowedValues": "[map(steps('networking').networkSettings.subNetProvidersApi.value, (item) => parse(concat('{\"label\":\"', item.name,' - ',item.properties.addressPrefix, '\",\"value\":\"', item.name, '\"}')))]",
"required": true
},
"visible": "[and(not(equals(steps('filesystem').shared.filertype, 'nfs')), equals(steps('networking').newexisting,'existing'))]"
"visible": "[and(equals(steps('networking').newexisting,'existing'),not(equals(steps('filesystem').shared.filertype, 'nfs')),equals(steps('filesystem').shared.newexisting,'new'))]"
},
{
"name": "filersubnet2",
Expand All @@ -783,7 +783,7 @@
"allowedValues": "[map(steps('networking').networkSettings.subNetProvidersApi.value, (item) => parse(concat('{\"label\":\"', item.name,' - ',item.properties.addressPrefix, '\",\"value\":\"', item.name, '\"}')))]",
"required": true
},
"visible": "[and(equals(steps('networking').newexisting,'existing'),steps('filesystem').additionalCheck.checkbox)]"
"visible": "[and(equals(steps('networking').newexisting,'existing'),steps('filesystem').additionalCheck.checkbox,equals(steps('filesystem').additional.newexisting,'new'))]"
},
{
"name": "bastion",
Expand Down Expand Up @@ -879,7 +879,7 @@
"type": "Microsoft.Common.DropDown",
"label": "Image Name",
"defaultValue": "Ubuntu 22.04",
"toolTip": "Select the image to use for the Login Nodes",
"toolTip": "Select the image to use for the Scheduler node",
"constraints": {
"allowedValues": [
{
Expand Down Expand Up @@ -995,7 +995,7 @@
},
"toolTip": "Password for the Slurm accounting database admin user",
"constraints": {
"required": "[not(equals(basics('autogeneratePasswordsAndKeys'),1))]",
"required": "[not(equals(basics('publicKeySource'),1))]",
"regex": "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*()_\\-+=[\\]{}|\\\\:'\",.?`~\";]).{8,123}$",
"validationMessage": "Your password must contain at least 8 characters, including at least one uppercase letter, one lowercase letter, one number, and one special character (@ # $ % ^ & * - _ ! + = [ ] { } | \\ : ' , . ? ` ~ \" ( ) ; )"
},
Expand Down Expand Up @@ -1116,7 +1116,7 @@
"type": "Microsoft.Common.DropDown",
"label": "Image Name",
"defaultValue": "Ubuntu 22.04",
"toolTip": "Select the image to use for the Login Nodes",
"toolTip": "Select the image to use for the Login nodes",
"constraints": {
"allowedValues": [
{
Expand Down Expand Up @@ -1514,22 +1514,22 @@
"location": "[location()]",
"adminUsername": "[basics('adminUser')]",
"adminPassword": "[basics('adminPasswordBox')]",
"adminSshPublicKey": "[if(equals(basics('autogeneratePasswordsAndKeys'),'entered'),basics('adminSshPublicKey'),basics('nullValue'))]",
"storedKey": "[if(equals(basics('autogeneratePasswordsAndKeys'),'stored'),basics('keySelector'),basics('nullValue'))]",
"adminSshPublicKey": "[if(equals(basics('publicKeySource'),'entered'),basics('adminSshPublicKey'),basics('nullValue'))]",
"storedKeyId": "[if(equals(basics('publicKeySource'),'stored'),basics('keySelector').id,basics('nullValue'))]",
"ccVMSize": "[basics('CycleCloudVmSize')]",
"resourceGroup": "[if(equals(basics('newexisting'),'existing'),first(split(basics('rgExisting'),'~')),basics('rgNew'))]",
"sharedFilesystem": {
"type": "[concat(if(equals(steps('filesystem').shared.newexisting,'new'),steps('filesystem').shared.filertype,'nfs'),'-',steps('filesystem').shared.newexisting)]",
"nfsCapacityInGb": "[if(equals(steps('filesystem').shared.filertype,'nfs'),int(steps('filesystem').shared.nfscapacity),basics('nullValue'))]",
"anfServiceTier": "[if(equals(steps('filesystem').shared.filertype,'anf'),steps('filesystem').shared.anftier,basics('nullValue'))]",
"anfServiceLevel": "[if(equals(steps('filesystem').shared.filertype,'anf'),steps('filesystem').shared.anfLevel,basics('nullValue'))]",
"anfCapacityInTiB": "[if(equals(steps('filesystem').shared.filertype,'anf'),int(steps('filesystem').shared.anfcapacity),basics('nullValue'))]",
"ipAddress": "[if(equals(steps('filesystem').shared.newexisting,'existing'),steps('filesystem').shared.ipAddress,basics('nullValue'))]",
"exportPath": "[if(equals(steps('filesystem').shared.newexisting,'existing'),steps('filesystem').shared.exportPath,basics('nullValue'))]",
"mountOptions": "[if(equals(steps('filesystem').shared.newexisting,'existing'),steps('filesystem').shared.mountOptions,basics('nullValue'))]"
},
"additionalFilesystem": {
"type": "[if(steps('filesystem').additionalCheck.checkbox,concat(steps('filesystem').additional.filertype,'-',steps('filesystem').additional.newexisting),'disabled')]",
"anfServiceTier": "[if(equals(steps('filesystem').additional.filertype,'anf'),steps('filesystem').additional.anftier,basics('nullValue'))]",
"anfServiceLevel": "[if(equals(steps('filesystem').additional.filertype,'anf'),steps('filesystem').additional.anfLevel,basics('nullValue'))]",
"anfCapacityInTiB": "[if(equals(steps('filesystem').additional.filertype,'anf'),int(steps('filesystem').additional.anfcapacity),basics('nullValue'))]",
"lustreTier": "[if(equals(steps('filesystem').additional.filertype,'aml'),steps('filesystem').additional.lustretier,basics('nullValue'))]",
"lustreCapacityInTib": "[if(equals(steps('filesystem').additional.filertype,'aml'),int(steps('filesystem').additional.azurelustrecapacity),basics('nullValue'))]",
Expand All @@ -1540,7 +1540,6 @@
},
"network": {
"type": "[steps('networking').newexisting]",
"name": "[if(equals(steps('networking').newexisting,'new'),basics('nullValue'),steps('networking').networkSettings.networkSelector.name)]",
"addressSpace": "[if(equals(steps('networking').newexisting,'new'),concat(steps('networking').networkSettings.baseIpAddress,steps('networking').networkSettings.cidrPrefix),basics('nullValue'))]",
"id": "[if(equals(steps('networking').newexisting,'existing'),steps('networking').networkSettings.networkSelector.id,basics('nullValue'))]",
"cyclecloudSubnet": "[if(equals(steps('networking').newexisting,'new'),basics('nullValue'),steps('networking').networkSettings.ccsubnet)]",
Expand All @@ -1549,16 +1548,15 @@
"additionalFilerSubnet": "[if(and(steps('filesystem').additionalCheck.checkbox,equals(steps('filesystem').additional.newexisting,'new')),if(equals(steps('networking').newexisting,'new'),basics('nullValue'),steps('networking').networkSettings.filersubnet2),basics('nullValue'))]",
"bastion": "[if(equals(steps('networking').newexisting,'new'),steps('networking').networkSettings.bastion,basics('nullValue'))]",
"createNatGateway": "[if(equals(steps('networking').newexisting,'new'),steps('networking').networkSettings.natgateway,basics('nullValue'))]",
"vnetToPeer": "[if(steps('networking').networkSettings.peering,steps('networking').networkSettings.vnetPeeredVnetSelector,basics('nullValue'))]",
"peeringAllowGatewayTransit": "[if(equals(steps('networking').newexisting,'new'),steps('networking').networkSettings.gateway,basics('nullValue'))]"
"vnetToPeer": "[if(steps('networking').networkSettings.peering,parse(concat('{','\"id\": \"',steps('networking').networkSettings.vnetPeeredVnetSelector.id,'\",','\"allowGatewayTransit\": ',string(steps('networking').networkSettings.gateway),'}')),basics('nullValue'))]"
},
"databaseAdminPassword": "[if(steps('scheduler').schedulerSection.slurmAccounting,steps('scheduler').schedulerSection.databaseAdminPassword,basics('nullValue'))]",
"databaseConfig": {
"type": "[if(steps('scheduler').schedulerSection.slurmAccounting,steps('scheduler').schedulerSection.dbConnection,'disabled')]",
"databaseUser": "[if(steps('scheduler').schedulerSection.slurmAccounting,steps('scheduler').schedulerSection.databaseUser,basics('nullValue'))]",
"fqdn": "[if(equals(steps('scheduler').schedulerSection.dbConnection,'fqdn'),steps('scheduler').schedulerSection.databaseURL,basics('nullValue'))]",
"privateIp": "[if(equals(steps('scheduler').schedulerSection.dbConnection,'privateIp'),steps('scheduler').schedulerSection.databasePIP,basics('nullValue'))]",
"dbInfo": "[if(equals(steps('scheduler').schedulerSection.dbConnection,'privateEndpoint'),steps('scheduler').schedulerSection.dbSelector,basics('nullValue'))]"
"dbId": "[if(equals(steps('scheduler').schedulerSection.dbConnection,'privateEndpoint'),steps('scheduler').schedulerSection.dbSelector.id,basics('nullValue'))]"
},
"clusterName": "[steps('scheduler').clusterName]",
"slurmSettings": {
Expand Down