public-private/azuredeploy.json

raw link view readme
1
2 {
3 "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
4 "contentVersion": "1.0.0.0",
5 "parameters": {
6 "admin-username": {
7 "type": "string"
8 },
9 "ssh-public-key": {
10 "type": "string"
11 }
12 },
13 "variables": {
14 "ssh-keypath": "[concat('/home/', parameters('admin-username'), '/.ssh/authorized_keys')]",
15 "unique-prefix": "[concat(replace(resourceGroup().name,'-',''), substring(uniquestring(resourceGroup().name), 0, 5))]",
16 "storage-name": "[variables('unique-prefix')]",
17 "vnet-name": "[concat(resourceGroup().name, '-vnet')]",
18 "ip-prefix": "[concat(resourceGroup().name, '-ip-')]",
19 "nsg-prefix": "[concat(resourceGroup().name, '-nsg')]",
20 "nic-prefix": "[concat(resourceGroup().name, '-nic-')]",
21 "access-nic-internal": "[concat(resourceGroup().name, '-access-nic-internal')]",
22 "access-nic-external": "[concat(resourceGroup().name, '-access-nic-external')]",
23 "vm-prefix": "[concat(resourceGroup().name, '-vm-')]",
24 "names": [
25 "alpha",
26 "beta",
27 "gamma",
28 "delta",
29 "epsilon",
30 "zeta",
31 "eta",
32 "theta",
33 "iota",
34 "kappa",
35 "lambda",
36 "mu",
37 "nu",
38 "xi",
39 "omicron",
40 "pi",
41 "rho",
42 "sigma",
43 "tau",
44 "upsilon",
45 "phi",
46 "chi",
47 "psi",
48 "omega"
49 ],
50 "private-vm-size": "Standard_DS1_v2",
51 "vnet-address-space": "10.16.0.0/12",
52 "vnet-subnet01-octet": 17,
53 "vnet-subnet02-octet": 18
54 },
55 "resources": [
56 {
57 "comments": "",
58 "type": "Microsoft.Network/publicIPAddresses",
59 "name": "[concat(variables('ip-prefix'), variables('names')[0])]",
60 "apiVersion": "2017-03-01",
61 "location": "[resourceGroup().location]",
62 "properties": {
63 "publicIPAllocationMethod": "Dynamic",
64 "idleTimeoutInMinutes": 4,
65 "dnsSettings": {
66 "domainNameLabel": "[concat(variables('unique-prefix'), '-', variables('names')[0])]"
67 }
68 },
69 "resources": [],
70 "dependsOn": []
71 },
72 {
73 "comments": "",
74 "type": "Microsoft.Compute/virtualMachines",
75 "name": "[concat(variables('vm-prefix'), variables('names')[0])]",
76 "apiVersion": "2016-04-30-preview",
77 "location": "[resourceGroup().location]",
78 "properties": {
79 "hardwareProfile": {
80 "vmSize": "Standard_DS2_v2"
81 },
82 "storageProfile": {
83 "imageReference": {
84 "publisher": "OpenLogic",
85 "offer": "CentOS",
86 "sku": "7.2",
87 "version": "latest"
88 },
89 "osDisk": {
90 "name": "[concat(variables('vm-prefix'), variables('names')[0], '-boot')]",
91 "createOption": "FromImage",
92 "vhd": {
93 "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storage-name')), '2015-06-15').primaryEndpoints.blob, 'vhds/', variables('names')[0], '-boot.vhd')]"
94 },
95 "caching": "ReadWrite"
96 },
97 "dataDisks": [
98 {
99 "name": "[concat(variables('vm-prefix'), variables('names')[0], '-disk01')]",
100 "diskSizeGB": 127,
101 "lun": 0,
102 "vhd": {
103 "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storage-name')), '2015-06-15').primaryEndpoints.blob, 'vhds/', variables('names')[0], '-data01.vhd')]"
104 },
105 "createOption": "Empty"
106 }
107 ]
108 },
109 "osProfile": {
110 "computerName": "[concat(variables('vm-prefix'), variables('names')[0])]",
111 "adminUsername": "[parameters('admin-username')]",
112 "linuxConfiguration": {
113 "disablePasswordAuthentication": true,
114 "ssh": {
115 "publicKeys": [
116 {
117 "path": "[variables('ssh-keypath')]",
118 "keyData": "[parameters('ssh-public-key')]"
119 }
120 ]
121 }
122 }
123 },
124 "networkProfile": {
125 "networkInterfaces": [
126 {
127 "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nic-prefix'), variables('names')[0]))]",
128 "properties": {
129 "primary": true
130 }
131 },
132 {
133 "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('vm-prefix'), variables('names')[0], '-', variables('names')[1]))]",
134 "properties": {
135 "primary": false
136 }
137 }
138 ]
139 }
140 },
141 "resources": [],
142 "dependsOn": [
143 "[resourceId('Microsoft.Storage/storageAccounts', variables('storage-name'))]",
144 "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nic-prefix'), variables('names')[0]))]",
145 "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('vm-prefix'), variables('names')[0], '-', variables('names')[1]))]"
146 ]
147 },
148 {
149 "comments": "",
150 "type": "Microsoft.Compute/virtualMachines",
151 "name": "[concat(variables('vm-prefix'), variables('names')[1])]",
152 "apiVersion": "2016-04-30-preview",
153 "location": "[resourceGroup().location]",
154 "properties": {
155 "hardwareProfile": {
156 "vmSize": "[variables('private-vm-size')]"
157 },
158 "storageProfile": {
159 "imageReference": {
160 "publisher": "OpenLogic",
161 "offer": "CentOS",
162 "sku": "7.2",
163 "version": "latest"
164 },
165 "osDisk": {
166 "name": "[concat(concat(variables('vm-prefix'), variables('names')[1]), '-boot')]",
167 "createOption": "FromImage",
168 "vhd": {
169 "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storage-name')), '2015-06-15').primaryEndpoints.blob, 'vhds/', variables('names')[1], '-boot.vhd')]"
170 },
171 "caching": "ReadWrite"
172 },
173 "dataDisks": [
174 {
175 "name": "[concat(variables('vm-prefix'), variables('names')[1], '-disk01')]",
176 "diskSizeGB": 127,
177 "lun": 0,
178 "vhd": {
179 "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storage-name')), '2015-06-15').primaryEndpoints.blob, 'vhds/', variables('names')[1], '-data01.vhd')]"
180 },
181 "createOption": "Empty"
182 }
183 ]
184 },
185 "osProfile": {
186 "computerName": "[concat(variables('vm-prefix'), variables('names')[1])]",
187 "adminUsername": "[parameters('admin-username')]",
188 "linuxConfiguration": {
189 "disablePasswordAuthentication": true,
190 "ssh": {
191 "publicKeys": [
192 {
193 "path": "[variables('ssh-keypath')]",
194 "keyData": "[parameters('ssh-public-key')]"
195 }
196 ]
197 }
198 }
199 },
200 "networkProfile": {
201 "networkInterfaces": [
202 {
203 "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('vm-prefix'), variables('names')[1]))]"
204 }
205 ]
206 }
207 },
208 "resources": [],
209 "dependsOn": [
210 "[resourceId('Microsoft.Storage/storageAccounts', variables('storage-name'))]",
211 "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('vm-prefix'), variables('names')[1]))]"
212 ]
213 },
214 {
215 "comments": "",
216 "type": "Microsoft.Network/networkInterfaces",
217 "name": "[concat(variables('nic-prefix'), variables('names')[0])]",
218 "apiVersion": "2017-03-01",
219 "location": "[resourceGroup().location]",
220 "properties": {
221 "ipConfigurations": [
222 {
223 "name": "ifconfig1",
224 "properties": {
225 "privateIPAllocationMethod": "Dynamic",
226 "publicIPAddress": {
227 "id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('ip-prefix'), variables('names')[0]))]"
228 },
229 "subnet": {
230 "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name')), '/subnets/subnet01')]"
231 }
232 }
233 }
234 ],
235 "dnsSettings": {
236 "dnsServers": []
237 },
238 "enableIPForwarding": false,
239 "networkSecurityGroup": {
240 "id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[0]))]"
241 }
242 },
243 "resources": [],
244 "dependsOn": [
245 "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('ip-prefix'), variables('names')[0]))]",
246 "[resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name'))]",
247 "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[0]))]"
248 ]
249 },
250 {
251 "comments": "",
252 "type": "Microsoft.Network/networkInterfaces",
253 "name": "[concat(variables('vm-prefix'), variables('names')[0], '-', variables('names')[1])]",
254 "apiVersion": "2017-03-01",
255 "location": "[resourceGroup().location]",
256 "properties": {
257 "ipConfigurations": [
258 {
259 "name": "ifconfig",
260 "properties": {
261 "privateIPAddress": "[concat('10.', variables('vnet-subnet02-octet'), '.0.4')]",
262 "privateIPAllocationMethod": "Static",
263 "subnet": {
264 "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name')), '/subnets/subnet02')]"
265 }
266 }
267 }
268 ],
269 "dnsSettings": {
270 "dnsServers": []
271 },
272 "enableIPForwarding": false,
273 "networkSecurityGroup": {
274 "id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[0]))]"
275 }
276 },
277 "resources": [],
278 "dependsOn": [
279 "[resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name'))]",
280 "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[0]))]"
281 ]
282 },
283 {
284 "comments": "",
285 "type": "Microsoft.Network/networkInterfaces",
286 "name": "[concat(variables('vm-prefix'), variables('names')[1])]",
287 "apiVersion": "2017-03-01",
288 "location": "[resourceGroup().location]",
289 "properties": {
290 "ipConfigurations": [
291 {
292 "name": "ifconfig",
293 "properties": {
294 "privateIPAddress": "[concat('10.', variables('vnet-subnet02-octet'), '.0.5')]",
295 "privateIPAllocationMethod": "Static",
296 "subnet": {
297 "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name')), '/subnets/subnet02')]"
298 }
299 }
300 }
301 ],
302 "dnsSettings": {
303 "dnsServers": []
304 },
305 "enableIPForwarding": false,
306 "networkSecurityGroup": {
307 "id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[1]))]"
308 }
309 },
310 "resources": [],
311 "dependsOn": [
312 "[resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name'))]",
313 "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[1]))]"
314 ]
315 },
316 {
317 "comments": "",
318 "type": "Microsoft.Network/virtualNetworks",
319 "name": "[variables('vnet-name')]",
320 "apiVersion": "2017-03-01",
321 "location": "[resourceGroup().location]",
322 "properties": {
323 "addressSpace": {
324 "addressPrefixes": [
325 "[variables('vnet-address-space')]"
326 ]
327 },
328 "subnets": [
329 {
330 "name": "subnet01",
331 "properties": {
332 "addressPrefix": "[concat('10.', variables('vnet-subnet01-octet'), '.0.0/16')]"
333 }
334 },
335 {
336 "name": "subnet02",
337 "properties": {
338 "addressPrefix": "[concat('10.', variables('vnet-subnet02-octet'), '.0.0/16')]"
339 }
340 }
341 ]
342 },
343 "resources": [],
344 "dependsOn": []
345 },
346 {
347 "comments": "",
348 "type": "Microsoft.Network/networkSecurityGroups",
349 "name": "[concat(variables('nsg-prefix'), variables('names')[0])]",
350 "apiVersion": "2017-03-01",
351 "location": "[resourceGroup().location]",
352 "properties": {
353 "securityRules": [
354 {
355 "name": "default-allow-ssh",
356 "properties": {
357 "protocol": "Tcp",
358 "sourcePortRange": "*",
359 "destinationPortRange": "22",
360 "sourceAddressPrefix": "*",
361 "destinationAddressPrefix": "*",
362 "access": "Allow",
363 "priority": 1000,
364 "direction": "Inbound"
365 }
366 },
367 {
368 "name": "http",
369 "properties": {
370 "protocol": "Tcp",
371 "sourcePortRange": "*",
372 "destinationPortRange": "80",
373 "sourceAddressPrefix": "*",
374 "destinationAddressPrefix": "*",
375 "access": "Allow",
376 "priority": 1100,
377 "direction": "Inbound"
378 }
379 },
380 {
381 "name": "https",
382 "properties": {
383 "protocol": "Tcp",
384 "sourcePortRange": "*",
385 "destinationPortRange": "443",
386 "sourceAddressPrefix": "*",
387 "destinationAddressPrefix": "*",
388 "access": "Allow",
389 "priority": 1200,
390 "direction": "Inbound"
391 }
392 }
393 ]
394 },
395 "resources": [],
396 "dependsOn": []
397 },
398 {
399 "comments": "",
400 "type": "Microsoft.Network/networkSecurityGroups",
401 "name": "[concat(variables('nsg-prefix'), variables('names')[1])]",
402 "apiVersion": "2017-03-01",
403 "location": "[resourceGroup().location]",
404 "properties": {
405 "securityRules": [
406 {
407 "name": "default-allow-ssh",
408 "properties": {
409 "protocol": "Tcp",
410 "sourcePortRange": "*",
411 "destinationPortRange": "22",
412 "sourceAddressPrefix": "*",
413 "destinationAddressPrefix": "*",
414 "access": "Allow",
415 "priority": 1000,
416 "direction": "Inbound"
417 }
418 }
419 ]
420 },
421 "resources": [],
422 "dependsOn": []
423 },
424 {
425 "comments": "",
426 "type": "Microsoft.Storage/storageAccounts",
427 "sku": {
428 "name": "Standard_LRS",
429 "tier": "Standard"
430 },
431 "kind": "Storage",
432 "name": "[variables('storage-name')]",
433 "apiVersion": "2016-01-01",
434 "location": "[resourceGroup().location]",
435 "tags": {},
436 "properties": {},
437 "resources": [],
438 "dependsOn": []
439 }
440 ],
441 "outputs": {
442 "sshCommand": {
443 "type": "string",
444 "value": "[concat('ssh ', variables('unique-prefix'), '-', variables('names')[0], '.', resourceGroup().location, '.cloudapp.azure.com')]"
445 }
446 }
447 }
448
449
450
451