Skip to content

Commit

Permalink
Modified tags to support adding values with defaults (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawngib authored Nov 19, 2021
1 parent 222bfe2 commit d2cafe3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
13 changes: 8 additions & 5 deletions src/bicep/mlz.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module hubResourceGroup './modules/resourceGroup.bicep' = {
params: {
name: hubResourceGroupName
location: hubLocation
tags: calculatedTags
}
}

Expand All @@ -20,7 +21,7 @@ module spokeResourceGroups './modules/resourceGroup.bicep' = [for spoke in spoke
params: {
name: spoke.resourceGroupName
location: spoke.location
tags: tags
tags: calculatedTags
}
}]

Expand All @@ -32,7 +33,7 @@ module logAnalyticsWorkspace './modules/logAnalyticsWorkspace.bicep' = {
params: {
name: logAnalyticsWorkspaceName
location: logAnalyticsWorkspaceLocation
tags: tags
tags: calculatedTags
deploySentinel: deploySentinel
retentionInDays: logAnalyticsWorkspaceRetentionInDays
skuName: logAnalyticsWorkspaceSkuName
Expand All @@ -50,7 +51,7 @@ module hubNetwork './modules/hubNetwork.bicep' = {
scope: resourceGroup(hubSubscriptionId, hubResourceGroupName)
params: {
location: hubLocation
tags: tags
tags: calculatedTags

logStorageAccountName: hubLogStorageAccountName
logStorageSkuName: hubLogStorageSkuName
Expand Down Expand Up @@ -105,7 +106,7 @@ module spokeNetworks './modules/spokeNetwork.bicep' = [ for spoke in spokes: {
scope: resourceGroup(spoke.subscriptionId, spoke.resourceGroupName)
params: {
location: spoke.location
tags: tags
tags: calculatedTags

logStorageAccountName: spoke.logStorageAccountName
logStorageSkuName: spoke.logStorageSkuName
Expand Down Expand Up @@ -547,10 +548,12 @@ param windowsVmVersion string = 'latest'
param windowsVmCreateOption string = 'FromImage'
param windowsVmStorageAccountType string = 'StandardSSD_LRS'

param tags object = {
param tags object = {}
var defaultTags = {
'resourcePrefix': resourcePrefix
'DeploymentType': 'MissionLandingZoneARM'
}
var calculatedTags = union(tags,defaultTags)

param uniqueId string = uniqueString(deployment().name)
param nowUtc string = utcNow()
Expand Down
23 changes: 14 additions & 9 deletions src/bicep/mlz.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.4.1008.15138",
"templateHash": "11074406747608602454"
"templateHash": "17151661725468237381"
}
},
"parameters": {
Expand Down Expand Up @@ -649,10 +649,7 @@
},
"tags": {
"type": "object",
"defaultValue": {
"resourcePrefix": "[parameters('resourcePrefix')]",
"DeploymentType": "MissionLandingZoneARM"
}
"defaultValue": {}
},
"uniqueId": {
"type": "string",
Expand All @@ -667,6 +664,11 @@
"variables": {
"firewallClientSubnetName": "AzureFirewallSubnet",
"firewallManagementSubnetName": "AzureFirewallManagementSubnet",
"defaultTags": {
"resourcePrefix": "[parameters('resourcePrefix')]",
"DeploymentType": "MissionLandingZoneARM"
},
"calculatedTags": "[union(parameters('tags'), variables('defaultTags'))]",
"spokes": [
{
"name": "operations",
Expand Down Expand Up @@ -745,6 +747,9 @@
},
"location": {
"value": "[parameters('hubLocation')]"
},
"tags": {
"value": "[variables('calculatedTags')]"
}
},
"template": {
Expand Down Expand Up @@ -819,7 +824,7 @@
"value": "[variables('spokes')[copyIndex()].location]"
},
"tags": {
"value": "[parameters('tags')]"
"value": "[variables('calculatedTags')]"
}
},
"template": {
Expand Down Expand Up @@ -890,7 +895,7 @@
"value": "[parameters('logAnalyticsWorkspaceLocation')]"
},
"tags": {
"value": "[parameters('tags')]"
"value": "[variables('calculatedTags')]"
},
"deploySentinel": {
"value": "[parameters('deploySentinel')]"
Expand Down Expand Up @@ -1100,7 +1105,7 @@
"value": "[parameters('hubLocation')]"
},
"tags": {
"value": "[parameters('tags')]"
"value": "[variables('calculatedTags')]"
},
"logStorageAccountName": {
"value": "[parameters('hubLogStorageAccountName')]"
Expand Down Expand Up @@ -2771,7 +2776,7 @@
"value": "[variables('spokes')[copyIndex()].location]"
},
"tags": {
"value": "[parameters('tags')]"
"value": "[variables('calculatedTags')]"
},
"logStorageAccountName": {
"value": "[variables('spokes')[copyIndex()].logStorageAccountName]"
Expand Down

0 comments on commit d2cafe3

Please sign in to comment.