-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.bicep
95 lines (84 loc) · 2.23 KB
/
main.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
@description('Name of the virtual network')
param vnetName string = 'myVnet'
@description('Name of the subnet for virtual network')
param subnetName string = 'mySubnet'
@description('Address space for virtual network')
param vnetAddressSpace string = '192.168.0.0/16'
@description('Subnet prefix for virtual network')
param vnetSubnetPrefix string = '192.168.0.0/24'
@description('Name of the NAT gateway resource')
param natGatewayName string = 'myNATgateway'
@description('dns of the public ip address, leave blank for no dns')
param publicIpDns string = 'gw-${uniqueString(resourceGroup().id)}'
@description('Location of resources')
param location string = resourceGroup().location
var publicIpName = '${natGatewayName}-ip'
var publicIpAddresses = [
{
id: publicIp.id
}
]
resource publicIp 'Microsoft.Network/publicIPAddresses@2020-06-01' = {
name: publicIpName
location: location
sku: {
name: 'Standard'
}
properties: {
publicIPAddressVersion: 'IPv4'
publicIPAllocationMethod: 'Static'
idleTimeoutInMinutes: 4
dnsSettings: {
domainNameLabel: publicIpDns
}
}
}
resource natGateway 'Microsoft.Network/natGateways@2020-06-01' = {
name: natGatewayName
location: location
sku: {
name: 'Standard'
}
properties: {
idleTimeoutInMinutes: 4
publicIpAddresses: !empty(publicIpDns) ? publicIpAddresses : null
}
}
resource vnet 'Microsoft.Network/virtualNetworks@2020-06-01' = {
name: vnetName
location: location
properties: {
addressSpace: {
addressPrefixes: [
vnetAddressSpace
]
}
subnets: [
{
name: subnetName
properties: {
addressPrefix: vnetSubnetPrefix
natGateway: {
id: natGateway.id
}
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
]
enableDdosProtection: false
enableVmProtection: false
}
}
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2020-06-01' = {
parent: vnet
name: 'mySubnet'
properties: {
addressPrefix: vnetSubnetPrefix
natGateway: {
id: natGateway.id
}
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}