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" {
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 = "ubuntu"
362 os_profile_linux_config {
363 disable_password_authentication = true
365 path = "/home/ubuntu/.ssh/authorized_keys"
366 key_data = file("~/.ssh/id_rsa.pub")
369 depends_on = [ azurerm_resource_group.CSIT,
370 azurerm_network_interface.tg_mng ]
373 resource "azurerm_virtual_machine" "dut1" {
375 location = azurerm_resource_group.CSIT.location
376 resource_group_name = azurerm_resource_group.CSIT.name
377 primary_network_interface_id = azurerm_network_interface.dut1_mng.id
378 network_interface_ids = [ azurerm_network_interface.dut1_mng.id,
379 azurerm_network_interface.dut1_if1.id,
380 azurerm_network_interface.dut1_if2.id ]
381 vm_size = "Standard_F32s_v2"
382 delete_os_disk_on_termination = true
383 delete_data_disks_on_termination = true
386 caching = "ReadWrite"
387 create_option = "FromImage"
388 managed_disk_type = "StandardSSD_LRS"
390 storage_image_reference {
391 publisher = "Canonical"
392 offer = "UbuntuServer"
397 computer_name = "dut1"
398 admin_username = "ubuntu"
400 os_profile_linux_config {
401 disable_password_authentication = true
403 path = "/home/ubuntu/.ssh/authorized_keys"
404 key_data = file("~/.ssh/id_rsa.pub")
407 depends_on = [ azurerm_resource_group.CSIT,
408 azurerm_network_interface.dut1_mng ]
411 resource "azurerm_virtual_machine" "dut2" {
413 location = azurerm_resource_group.CSIT.location
414 resource_group_name = azurerm_resource_group.CSIT.name
415 primary_network_interface_id = azurerm_network_interface.dut2_mng.id
416 network_interface_ids = [ azurerm_network_interface.dut2_mng.id,
417 azurerm_network_interface.dut2_if1.id,
418 azurerm_network_interface.dut2_if2.id ]
419 vm_size = "Standard_F32s_v2"
420 delete_os_disk_on_termination = true
421 delete_data_disks_on_termination = true
424 caching = "ReadWrite"
425 create_option = "FromImage"
426 managed_disk_type = "StandardSSD_LRS"
428 storage_image_reference {
429 publisher = "Canonical"
430 offer = "UbuntuServer"
435 computer_name = "dut2"
436 admin_username = "ubuntu"
438 os_profile_linux_config {
439 disable_password_authentication = true
441 path = "/home/ubuntu/.ssh/authorized_keys"
442 key_data = file("~/.ssh/id_rsa.pub")
445 depends_on = [ azurerm_resource_group.CSIT,
446 azurerm_network_interface.dut2_mng ]
449 data "azurerm_public_ip" "tg_public_ip" {
450 name = "tg_public_ip"
451 resource_group_name = azurerm_resource_group.CSIT.name
452 depends_on = [ azurerm_virtual_machine.tg ]
455 data "azurerm_public_ip" "dut1_public_ip" {
456 name = "dut1_public_ip"
457 resource_group_name = azurerm_resource_group.CSIT.name
458 depends_on = [ azurerm_virtual_machine.dut1 ]
461 data "azurerm_public_ip" "dut2_public_ip" {
462 name = "dut2_public_ip"
463 resource_group_name = azurerm_resource_group.CSIT.name
464 depends_on = [ azurerm_virtual_machine.dut2 ]
469 resource "null_resource" "deploy_tg" {
470 depends_on = [ azurerm_virtual_machine.tg,
471 azurerm_network_interface.tg_if1,
472 azurerm_network_interface.tg_if2 ]
475 host = data.azurerm_public_ip.tg_public_ip.ip_address
476 private_key = file("~/.ssh/id_rsa")
478 provisioner "ansible" {
481 file_path = "../../testbed-setup/ansible/site_azure.yaml"
482 force_handlers = true
486 ansible_python_interpreter = "/usr/bin/python3"
493 resource "null_resource" "deploy_dut1" {
494 depends_on = [ azurerm_virtual_machine.dut1,
495 azurerm_network_interface.dut1_if1,
496 azurerm_network_interface.dut1_if2 ]
499 host = data.azurerm_public_ip.dut1_public_ip.ip_address
500 private_key = file("~/.ssh/id_rsa")
502 provisioner "ansible" {
505 file_path = "../../testbed-setup/ansible/site_azure.yaml"
506 force_handlers = true
510 ansible_python_interpreter = "/usr/bin/python3"
517 resource "null_resource" "deploy_dut2" {
518 depends_on = [ azurerm_virtual_machine.dut2,
519 azurerm_network_interface.dut2_if1,
520 azurerm_network_interface.dut2_if2 ]
523 host = data.azurerm_public_ip.dut2_public_ip.ip_address
524 private_key = file("~/.ssh/id_rsa")
526 provisioner "ansible" {
529 file_path = "../../testbed-setup/ansible/site_azure.yaml"
530 force_handlers = true
534 ansible_python_interpreter = "/usr/bin/python3"
541 resource "null_resource" "deploy_topology" {
542 depends_on = [ azurerm_virtual_machine.tg,
543 azurerm_network_interface.tg_if1,
544 azurerm_network_interface.tg_if2,
545 azurerm_virtual_machine.dut1,
546 azurerm_network_interface.dut1_if1,
547 azurerm_network_interface.dut1_if2,
548 azurerm_virtual_machine.dut2,
549 azurerm_network_interface.dut2_if1,
550 azurerm_network_interface.dut2_if2 ]
551 provisioner "ansible" {
554 file_path = "../../testbed-setup/ansible/cloud_topology.yaml"
558 ansible_python_interpreter = "/usr/bin/python3"
559 cloud_topology = "azure"
560 tg_if1_mac = data.azurerm_network_interface.tg_if1.mac_address
561 tg_if2_mac = data.azurerm_network_interface.tg_if2.mac_address
562 dut1_if1_mac = data.azurerm_network_interface.dut1_if1.mac_address
563 dut1_if2_mac = data.azurerm_network_interface.dut1_if2.mac_address
564 dut2_if1_mac = data.azurerm_network_interface.dut2_if1.mac_address
565 dut2_if2_mac = data.azurerm_network_interface.dut2_if2.mac_address
566 tg_public_ip = data.azurerm_public_ip.tg_public_ip.ip_address
567 dut1_public_ip = data.azurerm_public_ip.dut1_public_ip.ip_address
568 dut2_public_ip = data.azurerm_public_ip.dut2_public_ip.ip_address
575 value = "TG IP: ${data.azurerm_public_ip.tg_public_ip.ip_address}"
579 value = "DUT1 IP: ${data.azurerm_public_ip.dut1_public_ip.ip_address}"
583 value = "DUT2 IP: ${data.azurerm_public_ip.dut2_public_ip.ip_address}"