Skip to content

Commit 88f6312

Browse files
authored
Merge pull request #38 from microsoft/nsg-updates
Infra - nsg inbound updates to use optional IP
2 parents 78901bd + f0b1ec0 commit 88f6312

3 files changed

Lines changed: 12 additions & 29 deletions

File tree

infra/main.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ param tags object = {}
3737
@description('Specifies the object id of a Microsoft Entra ID user. In general, this the object id of the system administrator who deploys the Azure resources. This defaults to the deploying user.')
3838
param userObjectId string = deployer().objectId
3939

40+
@description('Optional IP address to allow access to the jump-box VM. This is necessary to provide secure access to the private VNET via a jump-box VM with Bastion. If not specified, all IP addresses are allowed.')
41+
param allowedIpAddress string = ''
42+
4043
@description('Specifies if Microsoft APIM is deployed.')
4144
param apiManagementEnabled bool = false
4245

@@ -280,6 +283,7 @@ module network './modules/virtualNetwork.bicep' = if (networkIsolation) {
280283
natGatewayName: toLower('nat-${name}')
281284
natGatewayPublicIps: 1
282285
natGatewayIdleTimeoutMins: 30
286+
allowedIpAddress: allowedIpAddress
283287
workspaceId: logAnalyticsWorkspace.outputs.resourceId
284288
location: location
285289
tags: allTags

infra/main.parameters.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"vmSize": {
1515
"value": "${AZURE_VM_SIZE=Standard_DS4_v2}"
1616
},
17+
"allowedIpAddress": {
18+
"value": "${AZURE_ALLOWED_IP_ADDRESS}"
19+
},
1720
"aiModelDeployments": {
1821
"value": [
1922
{

infra/modules/virtualNetwork.bicep

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ param natGatewayPublicIps int = 1
5959
@description('Specifies the idle timeout in minutes for the Azure NAT Gateway.')
6060
param natGatewayIdleTimeoutMins int = 30
6161

62+
@description('Optional IP address to allow access throught Bastion NSG. If not specified, all IP addresses are allowed.')
63+
param allowedIpAddress string = ''
64+
6265
@description('Specifies the resource id of the Log Analytics workspace.')
6366
param workspaceId string
6467

@@ -179,7 +182,7 @@ resource bastionSubnetNsg 'Microsoft.Network/networkSecurityGroups@2023-04-01' =
179182
properties: {
180183
protocol: 'Tcp'
181184
sourcePortRange: '*'
182-
sourceAddressPrefix: 'Internet'
185+
sourceAddressPrefix: empty(allowedIpAddress) ? 'Internet' : allowedIpAddress
183186
destinationPortRange: '443'
184187
destinationAddressPrefix: '*'
185188
access: 'Allow'
@@ -325,34 +328,7 @@ resource vmSubnetNsg 'Microsoft.Network/networkSecurityGroups@2023-04-01' = {
325328
location: location
326329
tags: tags
327330
properties: {
328-
securityRules: [
329-
{
330-
name: 'AllowSshInbound'
331-
properties: {
332-
priority: 100
333-
access: 'Allow'
334-
direction: 'Inbound'
335-
protocol: 'Tcp'
336-
sourcePortRange: '*'
337-
destinationPortRange: '22'
338-
sourceAddressPrefix: '*'
339-
destinationAddressPrefix: '*'
340-
}
341-
}
342-
{
343-
name: 'AllowRDP'
344-
properties: {
345-
priority: 101
346-
access: 'Allow'
347-
direction: 'Inbound'
348-
protocol: 'Tcp'
349-
sourcePortRange: '*'
350-
destinationPortRange: '3389'
351-
sourceAddressPrefix: '*'
352-
destinationAddressPrefix: '*'
353-
}
354-
}
355-
]
331+
securityRules: []
356332
}
357333
}
358334

0 commit comments

Comments
 (0)