public-private/azuredeploy.json

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