@@ -8,9 +8,6 @@ param name string
88@description ('Azure region to deploy resources.' )
99param location string = resourceGroup ().location
1010
11- @description ('Conditional. List of address prefixes for the subnet. Leave empty to skip subnet creation.' )
12- param subnetAddressPrefixes string []?
13-
1411@description ('Resource ID of the Virtual Network where the Azure Bastion Host will be deployed.' )
1512param vnetId string
1613
@@ -26,19 +23,38 @@ param tags object = {}
2623@description ('Optional. Enable/Disable usage telemetry for module.' )
2724param enableTelemetry bool = true
2825
29- // 1. Create Azure Bastion Host using AVM Subnet Module with special config for Azure Bastion Subnet
26+ import { subnetType } from 'virtualNetwork.bicep'
27+ @description ('Optional. Subnet configuration for the Jumpbox VM.' )
28+ param subnet subnetType ?
29+
30+ // 1. Create AzureBastionSubnet NSG
31+ // using AVM Network Security Group module
32+ // https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/network/network-security-group
33+ module nsg 'br/public:avm/res/network/network-security-group:0.5.1' = if (!empty (subnet )) {
34+ name : '${vnetName }-${subnet .?networkSecurityGroup .name }'
35+ params : {
36+ name : '${subnet .?networkSecurityGroup .name }-${vnetName }'
37+ location : location
38+ securityRules : subnet .?networkSecurityGroup .securityRules
39+ tags : tags
40+ enableTelemetry : enableTelemetry
41+ }
42+ }
43+
44+ // 2. Create Azure Bastion Host using AVM Subnet Module with special config for Azure Bastion Subnet
3045// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/network/virtual-network/subnet
31- module bastionSubnet 'br/public:avm/res/network/virtual-network/subnet:0.1.2' = if (!empty (subnetAddressPrefixes )) {
46+ module bastionSubnet 'br/public:avm/res/network/virtual-network/subnet:0.1.2' = if (!empty (subnet )) {
3247 name : take ('bastionSubnet-${vnetName }' , 64 )
3348 params : {
3449 virtualNetworkName : vnetName
3550 name : 'AzureBastionSubnet' // this name required as is for Azure Bastion Host subnet
36- addressPrefixes : subnetAddressPrefixes
51+ addressPrefixes : subnet .?addressPrefixes
52+ networkSecurityGroupResourceId : nsg .outputs .resourceId
3753 enableTelemetry : enableTelemetry
3854 }
3955}
4056
41- // 2 . Create Azure Bastion Host in AzureBastionsubnetSubnet using AVM Bastion Host module
57+ // 3 . Create Azure Bastion Host in AzureBastionsubnetSubnet using AVM Bastion Host module
4258// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/network/bastion-host
4359
4460module bastionHost 'br/public:avm/res/network/bastion-host:0.6.1' = {
@@ -64,9 +80,12 @@ module bastionHost 'br/public:avm/res/network/bastion-host:0.6.1' = {
6480 enableTelemetry : enableTelemetry
6581 publicIPAddressObject : {
6682 name : 'pip-${name }'
67- zones :[]
83+ zones : []
6884 }
6985 }
86+ dependsOn : [
87+ bastionSubnet
88+ ]
7089}
7190
7291output resourceId string = bastionHost .outputs .resourceId
@@ -80,6 +99,6 @@ type bastionHostConfigurationType = {
8099 @description ('The name of the Bastion Host resource.' )
81100 name : string
82101
83- @description ('Optional. List of address prefixes for the subnet .' )
84- subnetAddressPrefixes : string [] ?
102+ @description ('Optional. Subnet configuration for the Jumpbox VM .' )
103+ subnet : subnetType ?
85104}
0 commit comments