Skip to content

Commit

Permalink
Merge pull request #5 from Teradata/feature/regulus-264/add-tagging-a…
Browse files Browse the repository at this point in the history
…zure-resources

Azure tag support
  • Loading branch information
teralauritsen authored Jan 12, 2024
2 parents b984831 + 9c4cacb commit e9e7057
Show file tree
Hide file tree
Showing 23 changed files with 465 additions and 53 deletions.
76 changes: 61 additions & 15 deletions deployments/azure/all-in-one.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "7836508991779513085"
"templateHash": "15418479916005263131"
}
},
"parameters": {
Expand Down Expand Up @@ -187,6 +187,13 @@
"metadata": {
"description": "Use a Network Load Balancer to connect to the Workspace server"
}
},
"Tags": {
"type": "object",
"defaultValue": {},
"metadata": {
"description": "Tags to apply to all newly created resources, in the form of {\"key_one\":\"value_one\",\"key_two\":\"value_two\"}"
}
}
},
"variables": {
Expand Down Expand Up @@ -236,6 +243,9 @@
},
"userClientId": {
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('ResourceGroupName')), 'Microsoft.Resources/deployments', 'workspaces'), '2022-09-01').outputs.PrincipleId.value]"
},
"tags": {
"value": "[parameters('Tags')]"
}
},
"template": {
Expand All @@ -244,8 +254,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.23.1.45101",
"templateHash": "10179246844067754393"
"version": "0.24.24.22086",
"templateHash": "11274348200796028004"
}
},
"parameters": {
Expand All @@ -258,6 +268,10 @@
"location": {
"type": "string"
},
"tags": {
"type": "object",
"defaultValue": {}
},
"userClientId": {
"type": "securestring"
}
Expand All @@ -268,6 +282,7 @@
"apiVersion": "2023-02-01",
"name": "[parameters('keyVaultName')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
"properties": {
"sku": {
"family": "A",
Expand Down Expand Up @@ -353,6 +368,9 @@
},
"detinationAppSecGroups": {
"value": "[parameters('detinationAppSecGroups')]"
},
"tags": {
"value": "[parameters('Tags')]"
}
},
"template": {
Expand All @@ -362,7 +380,7 @@
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "1018858806142179392"
"templateHash": "3088606472882204851"
}
},
"parameters": {
Expand Down Expand Up @@ -399,13 +417,18 @@
"jupyterHttpPort": {
"type": "string",
"defaultValue": "None"
},
"tags": {
"type": "object",
"defaultValue": {}
}
},
"resources": [
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2022-11-01",
"name": "[parameters('name')]",
"tags": "[parameters('tags')]",
"location": "[parameters('location')]"
},
{
Expand Down Expand Up @@ -616,6 +639,9 @@
},
"jupyterHttpPort": {
"value": "[int(parameters('JupyterHttpPort'))]"
},
"tags": {
"value": "[parameters('Tags')]"
}
},
"template": {
Expand All @@ -625,7 +651,7 @@
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "6905843737085590430"
"templateHash": "3385554541683646128"
}
},
"parameters": {
Expand All @@ -646,34 +672,40 @@
"jupyterHttpPort": {
"type": "int",
"defaultValue": 0
},
"tags": {
"type": "object",
"defaultValue": {}
}
},
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2021-08-01",
"name": "inbound",
"name": "[format('{0}-inbound', parameters('name'))]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"properties": {
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static"
}
},
"tags": "[parameters('tags')]"
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2021-08-01",
"name": "outbound",
"name": "[format('{0}-outbound', parameters('name'))]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"properties": {
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static"
}
},
"tags": "[parameters('tags')]"
},
{
"type": "Microsoft.Network/loadBalancers",
Expand All @@ -689,15 +721,15 @@
"name": "[format('{0}Inbound', parameters('name'))]",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', 'inbound')]"
"id": "[resourceId('Microsoft.Network/publicIPAddresses', format('{0}-inbound', parameters('name')))]"
}
}
},
{
"name": "[format('{0}Outbound', parameters('name'))]",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', 'outbound')]"
"id": "[resourceId('Microsoft.Network/publicIPAddresses', format('{0}-outbound', parameters('name')))]"
}
}
}
Expand Down Expand Up @@ -732,9 +764,10 @@
}
]
},
"tags": "[parameters('tags')]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', 'inbound')]",
"[resourceId('Microsoft.Network/publicIPAddresses', 'outbound')]"
"[resourceId('Microsoft.Network/publicIPAddresses', format('{0}-inbound', parameters('name')))]",
"[resourceId('Microsoft.Network/publicIPAddresses', format('{0}-outbound', parameters('name')))]"
]
}
],
Expand All @@ -748,7 +781,7 @@
},
"PublicIp": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', 'inbound'), '2021-08-01').ipAddress]"
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', format('{0}-inbound', parameters('name'))), '2021-08-01').ipAddress]"
}
}
}
Expand Down Expand Up @@ -808,6 +841,9 @@
"nlbPoolNames": "[if(parameters('UseNLB'), createObject('value', reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, parameters('ResourceGroupName')), 'Microsoft.Resources/deployments', 'loadbalancer'), '2022-09-01').outputs.nlbPools.value), createObject('value', createArray()))]",
"usePublicIp": {
"value": "[not(parameters('UseNLB'))]"
},
"tags": {
"value": "[parameters('Tags')]"
}
},
"template": {
Expand All @@ -817,7 +853,7 @@
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "994520545106154152"
"templateHash": "8152473424343277729"
}
},
"parameters": {
Expand Down Expand Up @@ -871,6 +907,10 @@
"nlbPoolNames": {
"type": "array",
"defaultValue": []
},
"tags": {
"type": "object",
"defaultValue": {}
}
},
"variables": {
Expand Down Expand Up @@ -933,6 +973,7 @@
"apiVersion": "2023-04-02",
"name": "[format('{0}-disk', parameters('name'))]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
"properties": {
"creationData": {
"createOption": "Empty"
Expand All @@ -947,6 +988,7 @@
"apiVersion": "2022-11-01",
"name": "[variables('networkInterfaceName')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
"properties": {
"ipConfigurations": [
"[if(parameters('usePublicIp'), createObject('name', 'ipconfigpublic', 'properties', createObject('privateIPAllocationMethod', 'Dynamic', 'subnet', createObject('id', parameters('subnetId')), 'publicIPAddress', createObject('id', resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))), 'loadBalancerBackendAddressPools', variables('resourcePools'))), createObject('name', 'ipconfigprivate', 'properties', createObject('privateIPAllocationMethod', 'Dynamic', 'subnet', createObject('id', parameters('subnetId')), 'loadBalancerBackendAddressPools', variables('resourcePools'))))]"
Expand All @@ -965,6 +1007,7 @@
"apiVersion": "2022-11-01",
"name": "[variables('publicIPAddressName')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
"sku": {
"name": "Basic"
},
Expand All @@ -982,6 +1025,7 @@
"apiVersion": "2023-03-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
"identity": {
"type": "SystemAssigned"
},
Expand Down Expand Up @@ -1029,6 +1073,7 @@
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2023-03-01",
"name": "[format('{0}/{1}', parameters('name'), variables('trustedExtensionName'))]",
"tags": "[parameters('tags')]",
"location": "[parameters('location')]",
"properties": {
"publisher": "[variables('trustedExtensionPublisher')]",
Expand All @@ -1052,6 +1097,7 @@
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2023-03-01",
"name": "[format('{0}/{1}', parameters('name'), variables('dockerExtensionName'))]",
"tags": "[parameters('tags')]",
"location": "[parameters('location')]",
"properties": {
"publisher": "[variables('dockerExtensionPublisher')]",
Expand Down
7 changes: 7 additions & 0 deletions deployments/azure/bicep/all-in-one.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ param JupyterToken string = uniqueString(subscription().id, utcNow())
@description('Use a Network Load Balancer to connect to the Workspace server')
param UseNLB bool = false

@description('Tags to apply to all newly created resources, in the form of {"key_one":"value_one","key_two":"value_two"}')
param Tags object = {}

var roleAssignmentName = guid(subscription().id, WorkspacesName, rg.id, RoleDefinitionId)

var registry = 'teradata'
Expand Down Expand Up @@ -138,6 +141,7 @@ module vault '../modules/vault.bicep' = if (UseKeyVault == 'New') {
keyVaultName: WorkspacesName
location: rg.location
userClientId: workspaces.outputs.PrincipleId
tags: Tags
}
}

Expand All @@ -154,6 +158,7 @@ module firewall '../modules/firewall.bicep' = {
jupyterHttpPort: JupyterHttpPort
sourceAppSecGroups: SourceAppSecGroups
detinationAppSecGroups: detinationAppSecGroups
tags: Tags
}
}

Expand All @@ -166,6 +171,7 @@ module nlb '../modules/nlb.bicep' = if (UseNLB) {
workspacesHttpPort: int(WorkspacesHttpPort)
workspacesGrpcPort: int(WorkspacesGrpcPort)
jupyterHttpPort: int(JupyterHttpPort)
tags: Tags
}
}

Expand All @@ -189,6 +195,7 @@ module workspaces '../modules/instance.bicep' = {
nlbName: UseNLB ? WorkspacesName : ''
nlbPoolNames: UseNLB ? nlb.outputs.nlbPools : []
usePublicIp: !UseNLB
tags: Tags
}
}

Expand Down
1 change: 1 addition & 0 deletions deployments/azure/bicep/all-in-one.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ param WorkspacesVersion = 'latest'
param JupyterVersion = 'latest'
param JupyterToken = 'USE_A_SECURE_TOKEN' /* TODO : please fix the value assigned to this parameter `uniqueString()` */
param UseNLB = false
param Tags = {}
8 changes: 7 additions & 1 deletion deployments/azure/bicep/jupyter.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ param JupyterToken string = uniqueString(subscription().id, utcNow())
@description('Use a Network Load Balancer to connect to the Jupyter Labs server')
param UseNLB bool = false

@description('Tags to apply to all newly created resources, in the form of {"key_one":"value_one","key_two":"value_two"}')
param Tags object = {}

var registry = 'teradata'
var jupyterRepository = 'ai-unlimited-jupyter'

Expand Down Expand Up @@ -110,6 +113,7 @@ module firewall '../modules/firewall.bicep' = {
jupyterHttpPort: JupyterHttpPort
sourceAppSecGroups: SourceAppSecGroups
detinationAppSecGroups: detinationAppSecGroups
tags: Tags
}
}

Expand All @@ -120,6 +124,7 @@ module nlb '../modules/nlb.bicep' = if (UseNLB) {
name: JupyterName
location: rg.location
jupyterHttpPort: int(JupyterHttpPort)
tags: Tags
}
}

Expand All @@ -143,12 +148,13 @@ module jupyter '../modules/instance.bicep' = {
nlbName: UseNLB ? JupyterName : ''
nlbPoolNames: UseNLB ? nlb.outputs.nlbPools : []
usePublicIp: !UseNLB
tags: Tags
}
}

output PublicIP string = UseNLB ? nlb.outputs.PublicIp : jupyter.outputs.PublicIP
output PrivateIP string = jupyter.outputs.PrivateIP
output JupyterLabPublicHttpAccess string = 'http://${jupyter.outputs.PublicIP}:${JupyterHttpPort}?token=${JupyterToken}'
output JupyterLabPublicHttpAccess string = 'http://${UseNLB ? nlb.outputs.PublicIp : jupyter.outputs.PublicIP}:${JupyterHttpPort}?token=${JupyterToken}'
output JupyterLabPrivateHttpAccess string = 'http://${jupyter.outputs.PrivateIP}:${JupyterHttpPort}?token=${JupyterToken}'
output sshCommand string = 'ssh azureuser@${jupyter.outputs.PublicIP}'
output SecurityGroup string = firewall.outputs.Id
1 change: 1 addition & 0 deletions deployments/azure/bicep/jupyter.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ param ExistingPersistentVolume = 'NONE'
param JupyterVersion = 'latest'
param JupyterToken = 'USE_A_SECURE_TOKEN' /* TODO : please fix the value assigned to this parameter `uniqueString()` */
param UseNLB = false
param Tags = {}
5 changes: 5 additions & 0 deletions deployments/azure/bicep/resources.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ param networkCidr array = [ '10.0.0.0/16' ]
@description('New subnet CIDR.')
param subnetCidr string = '10.0.0.0/24'

@description('Tags to apply to all newly created resources, in the form of {"key_one":"value_one","key_two":"value_two"}')
param Tags object = {}

resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: name
location: location
tags: Tags
}

module network '../modules/network.bicep' = {
Expand All @@ -26,6 +30,7 @@ module network '../modules/network.bicep' = {
networkCidr: networkCidr
subnetCidr: subnetCidr
location: location
tags: Tags
}
}

Expand Down
Loading

0 comments on commit e9e7057

Please sign in to comment.