-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.bicep
221 lines (203 loc) · 5.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
@description('Resource Group to deploy resource in')
param location string = resourceGroup().location
@description('UserName for SSH and Web')
@minLength(2)
@maxLength(28)
param tpotAdminUsername string
@description('Password for SSH and Web')
@secure()
@minLength(12)
@maxLength(72)
param tpotAdminPassword string
@allowed([
'STANDARD'
'HIVE'
'HIVE_SENSOR'
'INDUSTRIAL'
'LOG4J'
'MEDICAL'
'MINI'
'SENSOR'
])
param tpotFlavor string = 'STANDARD'
@description('Allowed IP for T-Pot administration')
@minLength(7)
@maxLength(16)
param nsgAllowedIP string
@description('Size of VM')
param vmSize string = 'Standard_B4ms'
var virtualMachineName = 'honey'
var ResourceNamingSuffix = 'honeypot-test'
var storageAccountResourceName = '${virtualMachineName}st01'
var PublicIPResourceName = 'pip-${ResourceNamingSuffix}'
var NetworkSecurityGroupResourceName = 'nsg-${ResourceNamingSuffix}'
var virtualNetworkResourceName = 'vnet-${ResourceNamingSuffix}'
var virtualMachineResourceName = 'vm-${virtualMachineName}-${ResourceNamingSuffix}'
var nicResourceName = 'nic-${virtualMachineName}-${ResourceNamingSuffix}'
var vmPublisher = 'debian'
var vmOffer = 'debian-11'
var vmSku = '11-gen2'
var vmVersion = 'latest'
var addressPrefix = '10.0.0.0/16'
var subnetName = 'Subnet'
var subnetPrefix = '10.0.0.0/24'
var subnetReference = resourceId('Microsoft.Network/virtualNetworks/subnets', virtualNetworkResourceName, subnetName)
resource StorageAccountResource 'Microsoft.Storage/storageAccounts@2021-01-01' = {
name: storageAccountResourceName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
}
resource PublicIPResource 'Microsoft.Network/publicIPAddresses@2020-05-01' = {
name: PublicIPResourceName
location: location
properties: {
publicIPAllocationMethod: 'Dynamic'
}
}
resource NetworkSecurityGroupResource 'Microsoft.Network/networkSecurityGroups@2020-05-01' = {
name: NetworkSecurityGroupResourceName
location: location
properties: {
securityRules: [
{
name: 'TPOT-allow-management'
properties: {
priority: 1000
access: 'Allow'
direction: 'Inbound'
protocol: 'Tcp'
sourceAddressPrefix: nsgAllowedIP
sourcePortRange: '*'
destinationAddressPrefix: '*'
destinationPortRange: '64294-64297'
}
}
{
name: 'TPOT-allow-honeypot'
properties: {
priority: 2000
access: 'Allow'
direction: 'Inbound'
protocol: '*'
sourceAddressPrefix: '*'
sourcePortRanges: [
'0-64293'
'64298-65535'
]
destinationAddressPrefix: '*'
destinationPortRanges: [
'0-64293'
'64298-65535'
]
}
}
]
}
}
resource virtualNetworkResouce 'Microsoft.Network/virtualNetworks@2020-05-01' = {
name: virtualNetworkResourceName
location: location
properties: {
addressSpace: {
addressPrefixes: [
addressPrefix
]
}
subnets: [
{
name: subnetName
properties: {
addressPrefix: subnetPrefix
networkSecurityGroup: {
id: NetworkSecurityGroupResource.id
}
}
}
]
}
}
resource nicResource 'Microsoft.Network/networkInterfaces@2020-05-01' = {
name: nicResourceName
location: location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
privateIPAllocationMethod: 'Dynamic'
publicIPAddress: {
id: PublicIPResource.id
}
subnet: {
id: subnetReference
}
}
}
]
}
dependsOn: [
virtualNetworkResouce
]
}
resource virtualMachineResource 'Microsoft.Compute/virtualMachines@2020-06-01' = {
name: virtualMachineResourceName
location: location
properties: {
hardwareProfile: {
vmSize: vmSize
}
osProfile: {
computerName: virtualMachineName
adminUsername: tpotAdminUsername
adminPassword: tpotAdminPassword
}
storageProfile: {
imageReference: {
publisher: vmPublisher
offer: vmOffer
sku: vmSku
version: vmVersion
}
osDisk: {
name: '${virtualMachineResourceName}-osdisk'
caching: 'ReadWrite'
createOption: 'FromImage'
}
}
networkProfile: {
networkInterfaces: [
{
id: nicResource.id
}
]
}
}
dependsOn: [
StorageAccountResource
]
}
resource virtualMachineResourceInstallTPot 'Microsoft.Compute/virtualMachines/extensions@2020-06-01' = {
parent: virtualMachineResource
name: 'install_tpot'
location: location
properties: {
publisher: 'Microsoft.Azure.Extensions'
type: 'CustomScript'
typeHandlerVersion: '2.1'
autoUpgradeMinorVersion: true
settings: {
skipDos2Unix: false
fileUris: [
'https://raw.githubusercontent.com/rikardronnkvist/Azure-T-Pot-Bicep/main/install_tpot.sh'
]
}
protectedSettings: {
commandToExecute: 'sh install_tpot.sh -u ${tpotAdminUsername} -p ${tpotAdminPassword} -f ${tpotFlavor}'
}
}
}
output VMName string = virtualMachineResourceName
output PublicIpName string = PublicIPResourceName