-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlbi.bicep
116 lines (104 loc) · 3.94 KB
/
lbi.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Deploys the Internal Standard Load Balancer
////////////////////////////////////////////////////////////////////////////////
// Required parameters
////////////////////////////////////////////////////////////////////////////////
param location string
@description('Name of the Azure virtual network where the load balancer needs to be deployed.')
param virtualNetworkName string
@description('Name of the resource group where the virtual network is created.')
param virtualNetworkResourceGroup string
@description('Name of the subnet in the virtual network where the load balancer needs to be deployed.')
param subnetName string
////////////////////////////////////////////////////////////////////////////////
// Parameters with acceptable defaults
////////////////////////////////////////////////////////////////////////////////
@description('Format string of the resource names.')
param resourceNameFormat string = '{0}-syslogfwd-{1}'
@description('A value to indicate the deployment number.')
@minValue(0)
@maxValue(99)
param sequence int = 1
////////////////////////////////////////////////////////////////////////////////
// VARIABLES
////////////////////////////////////////////////////////////////////////////////
var sequenceFormatted = format('{0:00}', sequence)
var lbName = format(resourceNameFormat, 'lbi', sequenceFormatted)
var frontendName = 'syslog-internal-frontend'
var backendName = 'syslogfwd-backend'
////////////////////////////////////////////////////////////////////////////////
// RESOURCES
////////////////////////////////////////////////////////////////////////////////
resource vnet 'Microsoft.Network/virtualNetworks@2021-02-01' existing = {
name: virtualNetworkName
scope: resourceGroup(virtualNetworkResourceGroup)
}
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' existing = {
name: '${vnet.name}/${subnetName}'
scope: resourceGroup(virtualNetworkResourceGroup)
}
resource loadBalancer 'Microsoft.Network/loadBalancers@2021-02-01' = {
name: lbName
location: location
sku: {
name: 'Standard'
tier: 'Regional'
}
properties: {
frontendIPConfigurations: [
{
name: frontendName
properties: {
subnet: {
id: subnet.id
}
privateIPAllocationMethod: 'Dynamic'
privateIPAddressVersion: 'IPv4'
}
}
]
backendAddressPools: [
{
name: backendName
}
]
loadBalancingRules: [
{
name: 'syslog-rule-tcp'
properties: {
protocol: 'Tcp'
frontendPort: 514
backendPort: 514
frontendIPConfiguration: {
id: resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', lbName, frontendName)
}
backendAddressPool: {
id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', lbName, backendName)
}
enableFloatingIP: false
enableTcpReset: true
}
}
{
name: 'syslog-rule-udp'
properties: {
protocol: 'Udp'
frontendPort: 514
backendPort: 514
frontendIPConfiguration: {
id: resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', lbName, frontendName)
}
backendAddressPool: {
id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', lbName, backendName)
}
enableFloatingIP: false
enableTcpReset: true
}
}
]
}
}
////////////////////////////////////////////////////////////////////////////////
// OUTPUTS
////////////////////////////////////////////////////////////////////////////////
output backendAddressPoolId string = loadBalancer.properties.backendAddressPools[0].id
output frontendIP string = loadBalancer.properties.frontendIPConfigurations[0].properties.privateIPAddress