7 variable "vpc_cidr_a" {
9 default = "172.16.0.0/24"
12 variable "vpc_cidr_b" {
14 default = "192.168.10.0/24"
17 variable "vpc_cidr_c" {
19 default = "200.0.0.0/24"
22 variable "vpc_cidr_d" {
24 default = "192.168.20.0/24"
27 variable "trex_dummy_cidr_port_0" {
29 default = "10.0.0.0/24"
32 variable "trex_dummy_cidr_port_1" {
34 default = "20.0.0.0/24"
37 # Create resource group and resources
39 resource "azurerm_resource_group" "CSIT" {
41 location = "North Europe"
44 resource "azurerm_virtual_network" "CSIT" {
46 resource_group_name = azurerm_resource_group.CSIT.name
47 location = azurerm_resource_group.CSIT.location
48 address_space = [ var.vpc_cidr_a,
52 depends_on = [ azurerm_resource_group.CSIT ]
55 resource "azurerm_subnet" "a" {
57 resource_group_name = azurerm_resource_group.CSIT.name
58 virtual_network_name = azurerm_virtual_network.CSIT.name
59 address_prefix = var.vpc_cidr_a
60 depends_on = [ azurerm_resource_group.CSIT ]
63 resource "azurerm_subnet" "b" {
65 resource_group_name = azurerm_resource_group.CSIT.name
66 virtual_network_name = azurerm_virtual_network.CSIT.name
67 address_prefix = var.vpc_cidr_b
68 depends_on = [ azurerm_resource_group.CSIT ]
71 resource "azurerm_subnet" "c" {
73 resource_group_name = azurerm_resource_group.CSIT.name
74 virtual_network_name = azurerm_virtual_network.CSIT.name
75 address_prefix = var.vpc_cidr_c
76 depends_on = [ azurerm_resource_group.CSIT ]
79 resource "azurerm_subnet" "d" {
81 resource_group_name = azurerm_resource_group.CSIT.name
82 virtual_network_name = azurerm_virtual_network.CSIT.name
83 address_prefix = var.vpc_cidr_d
84 depends_on = [ azurerm_resource_group.CSIT ]
87 # Create a security group of the Kiknos instances
89 resource "azurerm_network_security_group" "CSIT" {
91 resource_group_name = azurerm_resource_group.CSIT.name
92 location = azurerm_resource_group.CSIT.location
99 source_port_range = "*"
100 destination_port_range = "500"
101 source_address_prefix = "*"
102 destination_address_prefix = "*"
107 direction = "Inbound"
110 source_port_range = "*"
111 destination_port_range = "4500"
112 source_address_prefix = "*"
113 destination_address_prefix = "*"
118 direction = "Inbound"
121 source_port_range = "*"
122 destination_port_range = "22"
123 source_address_prefix = "*"
124 destination_address_prefix = "*"
129 direction = "Inbound"
132 source_port_range = "*"
133 destination_port_range = "*"
134 source_address_prefix = "*"
135 destination_address_prefix = "*"
140 direction = "Outbound"
143 source_port_range = "*"
144 destination_port_range = "*"
145 source_address_prefix = "*"
146 destination_address_prefix = "*"
148 depends_on = [azurerm_virtual_network.CSIT]
153 resource "azurerm_public_ip" "tg_public_ip" {
154 name = "tg_public_ip"
155 location = azurerm_resource_group.CSIT.location
156 resource_group_name = azurerm_resource_group.CSIT.name
157 allocation_method = "Dynamic"
158 depends_on = [ azurerm_resource_group.CSIT ]
161 resource "azurerm_public_ip" "dut1_public_ip" {
162 name = "dut1_public_ip"
163 location = azurerm_resource_group.CSIT.location
164 resource_group_name = azurerm_resource_group.CSIT.name
165 allocation_method = "Dynamic"
166 depends_on = [ azurerm_resource_group.CSIT ]
169 resource "azurerm_public_ip" "dut2_public_ip" {
170 name = "dut2_public_ip"
171 location = azurerm_resource_group.CSIT.location
172 resource_group_name = azurerm_resource_group.CSIT.name
173 allocation_method = "Dynamic"
174 depends_on = [ azurerm_resource_group.CSIT ]
177 # Create network interface
179 resource "azurerm_network_interface" "tg_mng" {
181 location = azurerm_resource_group.CSIT.location
182 resource_group_name = azurerm_resource_group.CSIT.name
183 network_security_group_id = azurerm_network_security_group.CSIT.id
187 subnet_id = azurerm_subnet.a.id
188 private_ip_address_allocation = "Static"
189 private_ip_address = "172.16.0.10"
190 public_ip_address_id = azurerm_public_ip.tg_public_ip.id
192 depends_on = [ azurerm_resource_group.CSIT,
194 azurerm_public_ip.tg_public_ip ]
197 resource "azurerm_network_interface" "dut1_mng" {
199 location = azurerm_resource_group.CSIT.location
200 resource_group_name = azurerm_resource_group.CSIT.name
201 network_security_group_id = azurerm_network_security_group.CSIT.id
205 subnet_id = azurerm_subnet.a.id
206 private_ip_address_allocation = "Static"
207 private_ip_address = "172.16.0.11"
208 public_ip_address_id = azurerm_public_ip.dut1_public_ip.id
210 depends_on = [ azurerm_resource_group.CSIT,
212 azurerm_public_ip.dut1_public_ip ]
215 resource "azurerm_network_interface" "dut2_mng" {
217 location = azurerm_resource_group.CSIT.location
218 resource_group_name = azurerm_resource_group.CSIT.name
219 network_security_group_id = azurerm_network_security_group.CSIT.id
223 subnet_id = azurerm_subnet.a.id
224 private_ip_address_allocation = "Static"
225 private_ip_address = "172.16.0.12"
226 public_ip_address_id = azurerm_public_ip.dut2_public_ip.id
228 depends_on = [ azurerm_resource_group.CSIT,
230 azurerm_public_ip.dut2_public_ip ]
233 resource "azurerm_route_table" "b" {
235 location = azurerm_resource_group.CSIT.location
236 resource_group_name = azurerm_resource_group.CSIT.name
237 depends_on = [ azurerm_resource_group.CSIT,
239 disable_bgp_route_propagation = false
242 address_prefix = "10.0.0.0/24"
243 next_hop_type = "VirtualAppliance"
244 next_hop_in_ip_address = "192.168.10.254"
248 address_prefix = "20.0.0.0/24"
249 next_hop_type = "VirtualAppliance"
250 next_hop_in_ip_address = "192.168.10.11"
254 address_prefix = "192.168.20.0/24"
255 next_hop_type = "VirtualAppliance"
256 next_hop_in_ip_address = "192.168.10.11"
260 resource "azurerm_route_table" "c" {
262 location = azurerm_resource_group.CSIT.location
263 resource_group_name = azurerm_resource_group.CSIT.name
264 depends_on = [ azurerm_resource_group.CSIT,
266 disable_bgp_route_propagation = false
269 address_prefix = "10.0.0.0/24"
270 next_hop_type = "VirtualAppliance"
271 next_hop_in_ip_address = "200.0.0.101"
275 address_prefix = "20.0.0.0/24"
276 next_hop_type = "VirtualAppliance"
277 next_hop_in_ip_address = "200.0.0.102"
281 address_prefix = "192.168.10.0/24"
282 next_hop_type = "VirtualAppliance"
283 next_hop_in_ip_address = "200.0.0.101"
287 address_prefix = "192.168.20.0/24"
288 next_hop_type = "VirtualAppliance"
289 next_hop_in_ip_address = "200.0.0.102"
293 resource "azurerm_route_table" "d" {
295 location = azurerm_resource_group.CSIT.location
296 resource_group_name = azurerm_resource_group.CSIT.name
297 depends_on = [ azurerm_resource_group.CSIT,
299 disable_bgp_route_propagation = false
302 address_prefix = "10.0.0.0/24"
303 next_hop_type = "VirtualAppliance"
304 next_hop_in_ip_address = "192.168.20.11"
308 address_prefix = "20.0.0.0/24"
309 next_hop_type = "VirtualAppliance"
310 next_hop_in_ip_address = "192.168.20.254"
314 address_prefix = "192.168.10.0/24"
315 next_hop_type = "VirtualAppliance"
316 next_hop_in_ip_address = "192.168.20.11"
320 resource "azurerm_subnet_route_table_association" "b" {
321 subnet_id = azurerm_subnet.b.id
322 route_table_id = azurerm_route_table.b.id
325 resource "azurerm_subnet_route_table_association" "c" {
326 subnet_id = azurerm_subnet.c.id
327 route_table_id = azurerm_route_table.c.id
330 resource "azurerm_subnet_route_table_association" "d" {
331 subnet_id = azurerm_subnet.d.id
332 route_table_id = azurerm_route_table.d.id
335 resource "azurerm_virtual_machine" "tg" {
337 location = azurerm_resource_group.CSIT.location
338 resource_group_name = azurerm_resource_group.CSIT.name
339 primary_network_interface_id = azurerm_network_interface.tg_mng.id
340 network_interface_ids = [ azurerm_network_interface.tg_mng.id,
341 azurerm_network_interface.tg_if1.id,
342 azurerm_network_interface.tg_if2.id ]
343 vm_size = "Standard_F32s_v2"
344 delete_os_disk_on_termination = true
345 delete_data_disks_on_termination = true
348 caching = "ReadWrite"
349 create_option = "FromImage"
350 managed_disk_type = "StandardSSD_LRS"
352 storage_image_reference {
353 publisher = "Canonical"
354 offer = "UbuntuServer"
360 admin_username = "testuser"
361 admin_password = "Csit1234"
363 os_profile_linux_config {
364 disable_password_authentication = false
366 path = "/home/testuser/.ssh/authorized_keys"
367 key_data = file("~/.ssh/id_rsa.pub")
370 depends_on = [ azurerm_resource_group.CSIT,
371 azurerm_network_interface.tg_mng ]
374 resource "azurerm_virtual_machine" "dut1" {
376 location = azurerm_resource_group.CSIT.location
377 resource_group_name = azurerm_resource_group.CSIT.name
378 primary_network_interface_id = azurerm_network_interface.dut1_mng.id
379 network_interface_ids = [ azurerm_network_interface.dut1_mng.id,
380 azurerm_network_interface.dut1_if1.id,
381 azurerm_network_interface.dut1_if2.id ]
382 vm_size = "Standard_F32s_v2"
383 delete_os_disk_on_termination = true
384 delete_data_disks_on_termination = true
387 caching = "ReadWrite"
388 create_option = "FromImage"
389 managed_disk_type = "StandardSSD_LRS"
391 storage_image_reference {
392 publisher = "Canonical"
393 offer = "UbuntuServer"
398 computer_name = "dut1"
399 admin_username = "testuser"
400 admin_password = "Csit1234"
402 os_profile_linux_config {
403 disable_password_authentication = false
405 path = "/home/testuser/.ssh/authorized_keys"
406 key_data = file("~/.ssh/id_rsa.pub")
409 depends_on = [ azurerm_resource_group.CSIT,
410 azurerm_network_interface.dut1_mng ]
413 resource "azurerm_virtual_machine" "dut2" {
415 location = azurerm_resource_group.CSIT.location
416 resource_group_name = azurerm_resource_group.CSIT.name
417 primary_network_interface_id = azurerm_network_interface.dut2_mng.id
418 network_interface_ids = [ azurerm_network_interface.dut2_mng.id,
419 azurerm_network_interface.dut2_if1.id,
420 azurerm_network_interface.dut2_if2.id ]
421 vm_size = "Standard_F32s_v2"
422 delete_os_disk_on_termination = true
423 delete_data_disks_on_termination = true
426 caching = "ReadWrite"
427 create_option = "FromImage"
428 managed_disk_type = "StandardSSD_LRS"
430 storage_image_reference {
431 publisher = "Canonical"
432 offer = "UbuntuServer"
437 computer_name = "dut2"
438 admin_username = "testuser"
439 admin_password = "Csit1234"
441 os_profile_linux_config {
442 disable_password_authentication = false
444 path = "/home/testuser/.ssh/authorized_keys"
445 key_data = file("~/.ssh/id_rsa.pub")
448 depends_on = [ azurerm_resource_group.CSIT,
449 azurerm_network_interface.dut2_mng ]
452 data "azurerm_public_ip" "tg_public_ip" {
453 name = "tg_public_ip"
454 resource_group_name = azurerm_resource_group.CSIT.name
455 depends_on = [ azurerm_virtual_machine.tg ]
458 data "azurerm_public_ip" "dut1_public_ip" {
459 name = "dut1_public_ip"
460 resource_group_name = azurerm_resource_group.CSIT.name
461 depends_on = [ azurerm_virtual_machine.dut1 ]
464 data "azurerm_public_ip" "dut2_public_ip" {
465 name = "dut2_public_ip"
466 resource_group_name = azurerm_resource_group.CSIT.name
467 depends_on = [ azurerm_virtual_machine.dut2 ]
472 resource "null_resource" "deploy_tg" {
473 depends_on = [ azurerm_virtual_machine.tg,
474 azurerm_network_interface.tg_if1,
475 azurerm_network_interface.tg_if2 ]
478 host = data.azurerm_public_ip.tg_public_ip.ip_address
480 provisioner "ansible" {
483 file_path = "../../testbed-setup/ansible/site_azure.yaml"
484 force_handlers = true
488 ansible_python_interpreter = "python3"
490 remote_net = var.vpc_cidr_d
491 tg_if1_mac = azurerm_network_interface.tg_if1.mac_address
492 tg_if2_mac = azurerm_network_interface.tg_if2.mac_address
493 dut1_if1_mac = azurerm_network_interface.dut1_if1.mac_address
494 dut1_if2_mac = azurerm_network_interface.dut1_if2.mac_address
495 dut2_if1_mac = azurerm_network_interface.dut2_if1.mac_address
496 dut2_if2_mac = azurerm_network_interface.dut2_if2.mac_address
497 dut1_if1_ip = azurerm_network_interface.dut1_if1.private_ip_address
498 dut2_if2_ip = azurerm_network_interface.dut2_if2.private_ip_address
504 resource "null_resource" "deploy_dut1" {
505 depends_on = [ azurerm_virtual_machine.dut1,
506 azurerm_network_interface.dut1_if1,
507 azurerm_network_interface.dut1_if2 ]
510 host = data.azurerm_public_ip.dut1_public_ip.ip_address
512 provisioner "ansible" {
515 file_path = "../../testbed-setup/ansible/site_azure.yaml"
516 force_handlers = true
520 ansible_python_interpreter = "python3"
522 dut1_if1_ip = azurerm_network_interface.dut1_if1.private_ip_address
523 dut1_if1_mac = azurerm_network_interface.dut1_if1.mac_address
524 dut1_if2_ip = azurerm_network_interface.dut1_if2.private_ip_address
525 dut1_if2_mac = azurerm_network_interface.dut1_if2.mac_address
526 dut2_if2_ip = azurerm_network_interface.dut2_if1.private_ip_address
527 dut2_if1_gateway = azurerm_network_interface.dut2_if1.private_ip_address
528 traffic_if1 = var.trex_dummy_cidr_port_0
529 traffic_if2 = var.trex_dummy_cidr_port_1
535 resource "null_resource" "deploy_dut2" {
536 depends_on = [ azurerm_virtual_machine.dut2,
537 azurerm_network_interface.dut2_if1,
538 azurerm_network_interface.dut2_if2 ]
541 host = data.azurerm_public_ip.dut2_public_ip.ip_address
543 provisioner "ansible" {
546 file_path = "../../testbed-setup/ansible/site_azure.yaml"
547 force_handlers = true
551 ansible_python_interpreter = "python3"
553 dut2_if1_ip = azurerm_network_interface.dut2_if1.private_ip_address
554 dut2_if1_mac = azurerm_network_interface.dut2_if1.mac_address
555 dut2_if2_ip = azurerm_network_interface.dut2_if2.private_ip_address
556 dut2_if2_mac = azurerm_network_interface.dut2_if2.mac_address
557 dut1_if2_ip = azurerm_network_interface.dut1_if2.private_ip_address
558 dut1_if2_gateway = azurerm_network_interface.dut1_if2.private_ip_address
559 traffic_if1 = var.trex_dummy_cidr_port_0
560 traffic_if2 = var.trex_dummy_cidr_port_1
567 value = "TG IP: ${data.azurerm_public_ip.tg_public_ip.ip_address}"
571 value = "DUT1 IP: ${data.azurerm_public_ip.dut1_public_ip.ip_address}"
575 value = "DUT2 IP: ${data.azurerm_public_ip.dut2_public_ip.ip_address}"