Skip to content

Commit a143c5c

Browse files
authored
Updates to allow optional identity resources (#838)
1 parent 88bac86 commit a143c5c

File tree

5 files changed

+290
-666
lines changed

5 files changed

+290
-666
lines changed

src/bicep/form/mlz.portal.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,20 @@
100100
"text": "The Identity spoke can be used to house Active Directory and other AuthN and AuthZ solutions."
101101
}
102102
},
103+
{
104+
"name": "deployIdentity",
105+
"type": "Microsoft.Common.CheckBox",
106+
"label": "Deploy identity resources?",
107+
"toolTip": "Check here to create the identity resources.",
108+
"constraints": {
109+
"required": false
110+
}
111+
},
103112
{
104113
"name": "identitySubscriptionId",
105114
"label": "Identity Subscription",
106115
"type": "Microsoft.Common.DropDown",
116+
"visible": "[steps('basics').identitySection.deployIdentity]",
107117
"defaultValue": "",
108118
"toolTip": "Select the Subscription for your Mission Landing Zone Identity network.",
109119
"multiselect": false,
@@ -195,11 +205,11 @@
195205
"name": "location",
196206
"type": "Microsoft.Common.LocationSelector",
197207
"label": "Location",
198-
"toolTip": "Select the location for the AVD session hosts.",
208+
"toolTip": "Select the deployment location for MLZ.",
199209
"resourceTypes": [
200-
"Microsoft.Compute/virtualMachines"
210+
"Microsoft.Compute/virtualMachines"
201211
]
202-
}
212+
}
203213
]
204214
},
205215
{
@@ -444,6 +454,7 @@
444454
"name": "identityVirtualNetwork",
445455
"label": "Identity Virtual Network",
446456
"type": "Microsoft.Common.Section",
457+
"visible": "[steps('basics').identitySection.deployIdentity]",
447458
"elements": [
448459
{
449460
"name": "virtualNetworkAddressCidrRange",
@@ -992,6 +1003,7 @@
9921003
"parameters": {
9931004
"bastionHostSubnetAddressPrefix": "[steps('remoteAccess').azureBastionSubnetSection.bastionSubnetAddressCidrRange]",
9941005
"deployDefender": "[steps('compliance').defenderSection.deployDefender]",
1006+
"deployIdentity": "[steps('basics').identitySection.deployIdentity]",
9951007
"deployPolicy": "[steps('compliance').policySection.deployPolicy]",
9961008
"deployRemoteAccess": "[steps('remoteAccess').remoteAccessSection.deployRemoteAccess]",
9971009
"deploySentinel": "[steps('compliance').sentinelSection.deploySentinel]",
@@ -1004,7 +1016,7 @@
10041016
"hubVirtualNetworkAddressPrefix": "[steps('networking').hubVirtualNetwork.virtualNetworkAddressCidrRange]",
10051017
"hybridUseBenefit": "[steps('remoteAccess').windowsVmSection.hybridUseBenefit]",
10061018
"identitySubnetAddressPrefix": "[steps('networking').identityVirtualNetwork.subnetAddressCidrRange]",
1007-
"identitySubscriptionId": "[replace(steps('basics').identitySection.identitySubscriptionId, '/subscriptions/', '')]",
1019+
"identitySubscriptionId": "[if(steps('basics').identitySection.deployIdentity, replace(steps('basics').identitySection.identitySubscriptionId, '/subscriptions/', ''), replace(steps('basics').hubSection.hubSubscriptionId, '/subscriptions/', ''))]",
10081020
"identityVirtualNetworkAddressPrefix": "[steps('networking').identityVirtualNetwork.virtualNetworkAddressCidrRange]",
10091021
"linuxVmAdminPasswordOrKey": "[if(equals(steps('remoteAccess').linuxVmSection.linuxVmAdminPasswordOrKey.authenticationType, 'password'), steps('remoteAccess').linuxVmSection.linuxVmAdminPasswordOrKey.password, steps('remoteAccess').linuxVmSection.linuxVmAdminPasswordOrKey.sshPublicKey)]",
10101022
"linuxVmAdminUsername": "[steps('remoteAccess').linuxVmSection.linuxVmAdminUsername]",

src/bicep/mlz.bicep

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ param supportedClouds array = [
4848
'AzureUSGovernment'
4949
]
5050

51+
@description('Choose to deploy the identity resources. The identity resoures are not required if you plan to use cloud identities.')
52+
param deployIdentity bool
53+
5154
// RESOURCE NAMING PARAMETERS
5255

5356
@description('A suffix to use for naming deployments uniquely. It defaults to the Bicep resolution of the "utcNow()" function.')
@@ -655,26 +658,8 @@ var bastionHostPublicIPAddressAllocationMethod = 'Static'
655658

656659
// SPOKES
657660

658-
var spokes = [
659-
{
660-
name: identityName
661-
subscriptionId: identitySubscriptionId
662-
resourceGroupName: identityResourceGroupName
663-
logStorageAccountName: identityLogStorageAccountName
664-
virtualNetworkName: identityVirtualNetworkName
665-
virtualNetworkAddressPrefix: identityVirtualNetworkAddressPrefix
666-
virtualNetworkDiagnosticsLogs: identityVirtualNetworkDiagnosticsLogs
667-
virtualNetworkDiagnosticsMetrics: identityVirtualNetworkDiagnosticsMetrics
668-
networkSecurityGroupName: identityNetworkSecurityGroupName
669-
networkSecurityGroupRules: identityNetworkSecurityGroupRules
670-
networkSecurityGroupDiagnosticsLogs: identityNetworkSecurityGroupDiagnosticsLogs
671-
networkSecurityGroupDiagnosticsMetrics: identityNetworkSecurityGroupDiagnosticsMetrics
672-
routeTableName: identityRouteTableName
673-
subnetName: identitySubnetName
674-
subnetAddressPrefix: identitySubnetAddressPrefix
675-
subnetPrivateEndpointNetworkPolicies: 'Disabled'
676-
subnetPrivateLinkServiceNetworkPolicies: 'Disabled'
677-
}
661+
var spokes = union(spokesCommon, spokesIdentity)
662+
var spokesCommon = [
678663
{
679664
name: operationsName
680665
subscriptionId: operationsSubscriptionId
@@ -714,6 +699,27 @@ var spokes = [
714699
subnetPrivateLinkServiceNetworkPolicies: 'Disabled'
715700
}
716701
]
702+
var spokesIdentity = deployIdentity ? [
703+
{
704+
name: identityName
705+
subscriptionId: identitySubscriptionId
706+
resourceGroupName: identityResourceGroupName
707+
logStorageAccountName: identityLogStorageAccountName
708+
virtualNetworkName: identityVirtualNetworkName
709+
virtualNetworkAddressPrefix: identityVirtualNetworkAddressPrefix
710+
virtualNetworkDiagnosticsLogs: identityVirtualNetworkDiagnosticsLogs
711+
virtualNetworkDiagnosticsMetrics: identityVirtualNetworkDiagnosticsMetrics
712+
networkSecurityGroupName: identityNetworkSecurityGroupName
713+
networkSecurityGroupRules: identityNetworkSecurityGroupRules
714+
networkSecurityGroupDiagnosticsLogs: identityNetworkSecurityGroupDiagnosticsLogs
715+
networkSecurityGroupDiagnosticsMetrics: identityNetworkSecurityGroupDiagnosticsMetrics
716+
routeTableName: identityRouteTableName
717+
subnetName: identitySubnetName
718+
subnetAddressPrefix: identitySubnetAddressPrefix
719+
subnetPrivateEndpointNetworkPolicies: 'Disabled'
720+
subnetPrivateLinkServiceNetworkPolicies: 'Disabled'
721+
}
722+
] : []
717723

718724
// TAGS
719725

@@ -880,9 +886,19 @@ module privateDnsZones './modules/private-dns.bicep' = {
880886
name: 'deploy-private-dns-zones-${deploymentNameSuffix}'
881887
scope: resourceGroup(hubSubscriptionId, hubResourceGroupName)
882888
params: {
883-
vnetName: hubNetwork.outputs.virtualNetworkName
889+
deployIdentity: deployIdentity
890+
deploymentNameSuffix: deploymentNameSuffix
891+
hubVirtualNetworkName: hubNetwork.outputs.virtualNetworkName
892+
hubVirtualNetworkResourceGroupName: hubResourceGroupName
893+
hubVirtualNetworkSubscriptionId: hubSubscriptionId
894+
identityVirtualNetworkName: deployIdentity ? spokes[2].virtualNetworkName : ''
895+
identityVirtualNetworkResourceGroupName: identityResourceGroupName
896+
identityVirtualNetworkSubscriptionId: identitySubscriptionId
884897
tags: tags
885898
}
899+
dependsOn: [
900+
spokeNetworks
901+
]
886902
}
887903

888904
// OPERATIONS CMK DEPENDANCIES
@@ -897,7 +913,7 @@ module operationsCustomerManagedKeys './core/operations-customer-managed-keys.bi
897913
keyVaultPrivateDnsZoneResourceId: privateDnsZones.outputs.keyvaultDnsPrivateDnsZoneId
898914
location: location
899915
resourcePrefix: resourcePrefix
900-
subnetResourceId: spokeNetworks[1].outputs.subnetResourceId
916+
subnetResourceId: spokeNetworks[0].outputs.subnetResourceId
901917
tags: calculatedTags
902918
userAssignedIdentityName: operationsUserAssignedIdentityName
903919
}
@@ -921,7 +937,7 @@ module azureMonitor './modules/azure-monitor.bicep' = if (contains(supportedClou
921937
location: location
922938
tags: tags
923939
resourcePrefix: resourcePrefix
924-
subnetResourceId: spokeNetworks[1].outputs.subnetResourceId
940+
subnetResourceId: spokeNetworks[0].outputs.subnetResourceId
925941
}
926942
dependsOn: [
927943
logAnalyticsWorkspace

0 commit comments

Comments
 (0)