11// /****************************************************************************************************************************/
22// Create Jumpbox NSG and Jumpbox Subnet, then create Jumpbox VM
33// /****************************************************************************************************************************/
4- param vmName string = 'jumpboxVM' // Default name for Jumpbox VM
4+
5+ @description ('Name of the Jumpbox Virtual Machine.' )
6+ param name string
7+
8+ @description ('Azure region to deploy resources.' )
59param location string = resourceGroup ().location
10+
11+ @description ('Name of the Virtual Network where the Jumpbox VM will be deployed.' )
612param vnetName string
7- param jumpboxVmSize string = 'Standard_D2s_v3' // Default VM size for Jumpbox, can be overridden
813
9- param jumpboxSubnet object = {} // This was defined in the .param file as a complex object
10- param jumpboxAdminUser string = 'JumpboxAdminUser' // Default admin username for Jumpbox VM
14+ @description ('Size of the Jumpbox Virtual Machine.' )
15+ param size string
16+
17+ import { subnetType } from 'virtualNetwork.bicep'
18+ @description ('Optional. Subnet configuration for the Jumpbox VM.' )
19+ param subnet subnetType ?
20+
21+ @description ('Username to access the Jumpbox VM.' )
22+ param username string
23+
1124@secure ()
12- param jumpboxAdminPassword string
25+ @description ('Password to access the Jumpbox VM.' )
26+ param password string
1327
28+ @description ('Optional. Tags to apply to the resources.' )
1429param tags object = {}
30+
31+ @description ('Log Analytics Workspace Resource ID for VM diagnostics.' )
1532param logAnalyticsWorkspaceId string
1633
1734// 1. Create Jumpbox NSG
1835// using AVM Network Security Group module
1936// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/network/network-security-group
20- module jbNsg 'br/public:avm/res/network/network-security-group:0.5.1' = if (!empty (jumpboxSubnet )) {
21- name : '${vnetName }-${jumpboxSubnet . networkSecurityGroup .name }'
37+ module nsg 'br/public:avm/res/network/network-security-group:0.5.1' = if (!empty (subnet )) {
38+ name : '${vnetName }-${subnet .? networkSecurityGroup .name }'
2239 params : {
23- name : '${vnetName }-${jumpboxSubnet . networkSecurityGroup .name }'
40+ name : '${vnetName }-${subnet .? networkSecurityGroup .name }'
2441 location : location
25- securityRules : jumpboxSubnet . networkSecurityGroup .securityRules
42+ securityRules : subnet .? networkSecurityGroup .securityRules
2643 tags : tags
2744 }
2845}
2946
3047// 2. Create Jumpbox subnet as part of the existing VNet
3148// using AVM Virtual Network Subnet module
3249// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/network/virtual-network/subnet
33- module jbSubnet 'br/public:avm/res/network/virtual-network/subnet:0.1.2' = if (!empty (jumpboxSubnet )) {
34- name : jumpboxSubnet . name
50+ module subnetResource 'br/public:avm/res/network/virtual-network/subnet:0.1.2' = if (!empty (subnet )) {
51+ name : subnet .? name ?? '${ vnetName }-jumpbox-subnet'
3552 params : {
3653 virtualNetworkName : vnetName
37- name : jumpboxSubnet . name
38- addressPrefixes : jumpboxSubnet . addressPrefixes
39- networkSecurityGroupResourceId : jbNsg .outputs .resourceId
54+ name : subnet .? name ?? ''
55+ addressPrefixes : subnet .? addressPrefixes
56+ networkSecurityGroupResourceId : nsg .outputs .resourceId
4057 }
4158}
4259
4360// 3. Create Jumpbox VM
4461// using AVM Virtual Machine module
4562// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/compute/virtual-machine
46- var limitedVmName = take (vmName , 15 ) // Shorten VM name to 15 characters to avoid Azure limits
47- module jbVm 'br/public:avm/res/compute/virtual-machine:0.15.0' = {
48- name : vmName
63+ var vmName = take (name , 15 ) // Shorten VM name to 15 characters to avoid Azure limits
64+
65+ module vm 'br/public:avm/res/compute/virtual-machine:0.15.0' = {
66+ name : take ('${vmName }-jumpbox' , 64 )
4967 params : {
50- name : limitedVmName
51- vmSize : jumpboxVmSize
68+ name : vmName
69+ vmSize : size
5270 location : location
53- adminUsername : jumpboxAdminUser
54- adminPassword : jumpboxAdminPassword
71+ adminUsername : username
72+ adminPassword : password
5573 tags : tags
5674 zone : 2
5775 imageReference : {
@@ -69,14 +87,14 @@ module jbVm 'br/public:avm/res/compute/virtual-machine:0.15.0' = {
6987 encryptionAtHost : false // Some Azure subscriptions do not support encryption at host
7088 nicConfigurations : [
7189 {
72- name : '${limitedVmName }-nic'
90+ name : '${vmName }-nic'
7391 ipConfigurations : [
7492 {
7593 name : 'ipconfig1'
76- subnetResourceId : jbSubnet .outputs .resourceId
94+ subnetResourceId : subnetResource .outputs .resourceId
7795 }
7896 ]
79- networkSecurityGroupResourceId : jbNsg .outputs .resourceId
97+ networkSecurityGroupResourceId : nsg .outputs .resourceId
8098 diagnosticSettings : [
8199 {
82100 name : 'jumpboxDiagnostics'
@@ -100,16 +118,14 @@ module jbVm 'br/public:avm/res/compute/virtual-machine:0.15.0' = {
100118 }
101119}
102120
103- output vmId string = jbVm .outputs .resourceId
104- output vmName string = jbVm .outputs .name
105- output vMLocation string = jbVm .outputs .location
121+ output resourceId string = vm .outputs .resourceId
122+ output name string = vm .outputs .name
123+ output location string = vm .outputs .location
106124
107- output subnetId string = jbSubnet .outputs .resourceId
108- output subnetName string = jbSubnet .outputs .name
109- output nsgId string = jbNsg .outputs .resourceId
110- output nsgName string = jbNsg .outputs .name
111-
112- import { subnetType } from 'virtualNetwork.bicep'
125+ output subnetId string = subnetResource .outputs .resourceId
126+ output subnetName string = subnetResource .outputs .name
127+ output nsgId string = nsg .outputs .resourceId
128+ output nsgName string = nsg .outputs .name
113129
114130@export ()
115131@description ('Custom type definition for establishing Jumpbox Virtual Machine and its associated resources.' )
@@ -118,7 +134,7 @@ type jumpBoxConfigurationType = {
118134 name : string
119135
120136 @description ('The size of the VM.' )
121- size : string
137+ size : string ?
122138
123139 @description ('Username to access VM.' )
124140 username : string
0 commit comments