7 variable "vpc_addr_space_a" {
9 default = "172.16.0.0/16"
12 variable "vpc_cidr_a" {
14 default = "172.16.0.0/24"
17 variable "vpc_cidr_b" {
19 default = "172.16.10.0/24"
22 variable "vpc_cidr_c" {
24 default = "172.16.200.0/24"
27 variable "vpc_cidr_d" {
29 default = "172.16.20.0/24"
32 variable "trex_dummy_cidr_port_0" {
34 default = "172.16.11.0/24"
37 variable "trex_dummy_cidr_port_1" {
39 default = "172.16.21.0/24"
42 # Create resource group and resources
44 resource "azurerm_resource_group" "CSIT" {
50 resource "azurerm_virtual_network" "CSIT" {
52 resource_group_name = azurerm_resource_group.CSIT.name
53 location = azurerm_resource_group.CSIT.location
54 address_space = [ var.vpc_addr_space_a ]
55 depends_on = [ azurerm_resource_group.CSIT ]
58 resource "azurerm_subnet" "a" {
60 resource_group_name = azurerm_resource_group.CSIT.name
61 virtual_network_name = azurerm_virtual_network.CSIT.name
62 address_prefix = var.vpc_cidr_a
63 depends_on = [ azurerm_resource_group.CSIT ]
66 resource "azurerm_subnet" "b" {
68 resource_group_name = azurerm_resource_group.CSIT.name
69 virtual_network_name = azurerm_virtual_network.CSIT.name
70 address_prefix = var.vpc_cidr_b
71 depends_on = [ azurerm_resource_group.CSIT ]
74 resource "azurerm_subnet" "c" {
76 resource_group_name = azurerm_resource_group.CSIT.name
77 virtual_network_name = azurerm_virtual_network.CSIT.name
78 address_prefix = var.vpc_cidr_c
79 depends_on = [ azurerm_resource_group.CSIT ]
82 resource "azurerm_subnet" "d" {
84 resource_group_name = azurerm_resource_group.CSIT.name
85 virtual_network_name = azurerm_virtual_network.CSIT.name
86 address_prefix = var.vpc_cidr_d
87 depends_on = [ azurerm_resource_group.CSIT ]
90 # Create a security group of the Kiknos instances
92 resource "azurerm_network_security_group" "CSIT" {
94 resource_group_name = azurerm_resource_group.CSIT.name
95 location = azurerm_resource_group.CSIT.location
102 source_port_range = "*"
103 destination_port_range = "500"
104 source_address_prefix = "*"
105 destination_address_prefix = "*"
110 direction = "Inbound"
113 source_port_range = "*"
114 destination_port_range = "4500"
115 source_address_prefix = "*"
116 destination_address_prefix = "*"
121 direction = "Inbound"
124 source_port_range = "*"
125 destination_port_range = "22"
126 source_address_prefix = "*"
127 destination_address_prefix = "*"
132 direction = "Inbound"
135 source_port_range = "*"
136 destination_port_range = "*"
137 source_address_prefix = "*"
138 destination_address_prefix = "*"
143 direction = "Outbound"
146 source_port_range = "*"
147 destination_port_range = "*"
148 source_address_prefix = "*"
149 destination_address_prefix = "*"
151 depends_on = [azurerm_virtual_network.CSIT]
156 resource "azurerm_public_ip" "tg_public_ip" {
157 name = "tg_public_ip"
158 location = azurerm_resource_group.CSIT.location
159 resource_group_name = azurerm_resource_group.CSIT.name
160 allocation_method = "Dynamic"
161 depends_on = [ azurerm_resource_group.CSIT ]
164 resource "azurerm_public_ip" "dut1_public_ip" {
165 name = "dut1_public_ip"
166 location = azurerm_resource_group.CSIT.location
167 resource_group_name = azurerm_resource_group.CSIT.name
168 allocation_method = "Dynamic"
169 depends_on = [ azurerm_resource_group.CSIT ]
172 resource "azurerm_public_ip" "dut2_public_ip" {
173 name = "dut2_public_ip"
174 location = azurerm_resource_group.CSIT.location
175 resource_group_name = azurerm_resource_group.CSIT.name
176 allocation_method = "Dynamic"
177 depends_on = [ azurerm_resource_group.CSIT ]
180 # Create network interface
182 resource "azurerm_network_interface" "tg_mng" {
184 location = azurerm_resource_group.CSIT.location
185 resource_group_name = azurerm_resource_group.CSIT.name
186 network_security_group_id = azurerm_network_security_group.CSIT.id
190 subnet_id = azurerm_subnet.a.id
191 private_ip_address_allocation = "Static"
192 private_ip_address = "172.16.0.10"
193 public_ip_address_id = azurerm_public_ip.tg_public_ip.id
195 depends_on = [ azurerm_resource_group.CSIT,
197 azurerm_public_ip.tg_public_ip ]
200 resource "azurerm_network_interface" "dut1_mng" {
202 location = azurerm_resource_group.CSIT.location
203 resource_group_name = azurerm_resource_group.CSIT.name
204 network_security_group_id = azurerm_network_security_group.CSIT.id
208 subnet_id = azurerm_subnet.a.id
209 private_ip_address_allocation = "Static"
210 private_ip_address = "172.16.0.11"
211 public_ip_address_id = azurerm_public_ip.dut1_public_ip.id
213 depends_on = [ azurerm_resource_group.CSIT,
215 azurerm_public_ip.dut1_public_ip ]
218 resource "azurerm_network_interface" "dut2_mng" {
220 location = azurerm_resource_group.CSIT.location
221 resource_group_name = azurerm_resource_group.CSIT.name
222 network_security_group_id = azurerm_network_security_group.CSIT.id
226 subnet_id = azurerm_subnet.a.id
227 private_ip_address_allocation = "Static"
228 private_ip_address = "172.16.0.12"
229 public_ip_address_id = azurerm_public_ip.dut2_public_ip.id
231 depends_on = [ azurerm_resource_group.CSIT,
233 azurerm_public_ip.dut2_public_ip ]
236 resource "azurerm_route_table" "b" {
238 location = azurerm_resource_group.CSIT.location
239 resource_group_name = azurerm_resource_group.CSIT.name
240 depends_on = [ azurerm_resource_group.CSIT,
242 disable_bgp_route_propagation = false
245 address_prefix = var.trex_dummy_cidr_port_0
246 next_hop_type = "VirtualAppliance"
247 next_hop_in_ip_address = data.azurerm_network_interface.tg_if1.private_ip_address
251 address_prefix = var.trex_dummy_cidr_port_1
252 next_hop_type = "VirtualAppliance"
253 next_hop_in_ip_address = data.azurerm_network_interface.dut1_if1.private_ip_address
257 address_prefix = var.vpc_cidr_d
258 next_hop_type = "VirtualAppliance"
259 next_hop_in_ip_address = data.azurerm_network_interface.dut1_if1.private_ip_address
263 resource "azurerm_route_table" "c" {
265 location = azurerm_resource_group.CSIT.location
266 resource_group_name = azurerm_resource_group.CSIT.name
267 depends_on = [ azurerm_resource_group.CSIT,
269 disable_bgp_route_propagation = false
272 address_prefix = var.trex_dummy_cidr_port_0
273 next_hop_type = "VirtualAppliance"
274 next_hop_in_ip_address = data.azurerm_network_interface.dut1_if2.private_ip_address
278 address_prefix = "100.0.0.0/8"
279 next_hop_type = "VirtualAppliance"
280 next_hop_in_ip_address = data.azurerm_network_interface.dut1_if2.private_ip_address
284 address_prefix = var.trex_dummy_cidr_port_1
285 next_hop_type = "VirtualAppliance"
286 next_hop_in_ip_address = data.azurerm_network_interface.dut2_if1.private_ip_address
290 address_prefix = var.vpc_cidr_b
291 next_hop_type = "VirtualAppliance"
292 next_hop_in_ip_address = data.azurerm_network_interface.dut1_if2.private_ip_address
296 address_prefix = var.vpc_cidr_d
297 next_hop_type = "VirtualAppliance"
298 next_hop_in_ip_address = data.azurerm_network_interface.dut2_if1.private_ip_address
302 resource "azurerm_route_table" "d" {
304 location = azurerm_resource_group.CSIT.location
305 resource_group_name = azurerm_resource_group.CSIT.name
306 depends_on = [ azurerm_resource_group.CSIT,
308 disable_bgp_route_propagation = false
311 address_prefix = var.trex_dummy_cidr_port_0
312 next_hop_type = "VirtualAppliance"
313 next_hop_in_ip_address = data.azurerm_network_interface.dut2_if2.private_ip_address
317 address_prefix = var.trex_dummy_cidr_port_1
318 next_hop_type = "VirtualAppliance"
319 next_hop_in_ip_address = data.azurerm_network_interface.tg_if2.private_ip_address
323 address_prefix = var.vpc_cidr_b
324 next_hop_type = "VirtualAppliance"
325 next_hop_in_ip_address = data.azurerm_network_interface.dut2_if2.private_ip_address
329 resource "azurerm_subnet_route_table_association" "b" {
330 subnet_id = azurerm_subnet.b.id
331 route_table_id = azurerm_route_table.b.id
334 resource "azurerm_subnet_route_table_association" "c" {
335 subnet_id = azurerm_subnet.c.id
336 route_table_id = azurerm_route_table.c.id
339 resource "azurerm_subnet_route_table_association" "d" {
340 subnet_id = azurerm_subnet.d.id
341 route_table_id = azurerm_route_table.d.id
344 resource "azurerm_virtual_machine" "tg" {
346 location = azurerm_resource_group.CSIT.location
347 resource_group_name = azurerm_resource_group.CSIT.name
348 primary_network_interface_id = azurerm_network_interface.tg_mng.id
349 network_interface_ids = [ azurerm_network_interface.tg_mng.id,
350 azurerm_network_interface.tg_if1.id,
351 azurerm_network_interface.tg_if2.id ]
352 vm_size = "Standard_F32s_v2"
353 delete_os_disk_on_termination = true
354 delete_data_disks_on_termination = true
357 caching = "ReadWrite"
358 create_option = "FromImage"
359 managed_disk_type = "StandardSSD_LRS"
361 storage_image_reference {
362 publisher = "Canonical"
363 offer = "UbuntuServer"
369 admin_username = "ubuntu"
371 os_profile_linux_config {
372 disable_password_authentication = true
374 path = "/home/ubuntu/.ssh/authorized_keys"
375 key_data = file("~/.ssh/id_rsa.pub")
378 depends_on = [ azurerm_resource_group.CSIT,
379 azurerm_network_interface.tg_mng ]
382 resource "azurerm_virtual_machine" "dut1" {
384 location = azurerm_resource_group.CSIT.location
385 resource_group_name = azurerm_resource_group.CSIT.name
386 primary_network_interface_id = azurerm_network_interface.dut1_mng.id
387 network_interface_ids = [ azurerm_network_interface.dut1_mng.id,
388 azurerm_network_interface.dut1_if1.id,
389 azurerm_network_interface.dut1_if2.id ]
390 vm_size = "Standard_F32s_v2"
391 delete_os_disk_on_termination = true
392 delete_data_disks_on_termination = true
395 caching = "ReadWrite"
396 create_option = "FromImage"
397 managed_disk_type = "StandardSSD_LRS"
399 storage_image_reference {
400 publisher = "Canonical"
401 offer = "UbuntuServer"
406 computer_name = "dut1"
407 admin_username = "ubuntu"
409 os_profile_linux_config {
410 disable_password_authentication = true
412 path = "/home/ubuntu/.ssh/authorized_keys"
413 key_data = file("~/.ssh/id_rsa.pub")
416 depends_on = [ azurerm_resource_group.CSIT,
417 azurerm_network_interface.dut1_mng ]
420 resource "azurerm_virtual_machine" "dut2" {
422 location = azurerm_resource_group.CSIT.location
423 resource_group_name = azurerm_resource_group.CSIT.name
424 primary_network_interface_id = azurerm_network_interface.dut2_mng.id
425 network_interface_ids = [ azurerm_network_interface.dut2_mng.id,
426 azurerm_network_interface.dut2_if1.id,
427 azurerm_network_interface.dut2_if2.id ]
428 vm_size = "Standard_F32s_v2"
429 delete_os_disk_on_termination = true
430 delete_data_disks_on_termination = true
433 caching = "ReadWrite"
434 create_option = "FromImage"
435 managed_disk_type = "StandardSSD_LRS"
437 storage_image_reference {
438 publisher = "Canonical"
439 offer = "UbuntuServer"
444 computer_name = "dut2"
445 admin_username = "ubuntu"
447 os_profile_linux_config {
448 disable_password_authentication = true
450 path = "/home/ubuntu/.ssh/authorized_keys"
451 key_data = file("~/.ssh/id_rsa.pub")
454 depends_on = [ azurerm_resource_group.CSIT,
455 azurerm_network_interface.dut2_mng ]
458 data "azurerm_public_ip" "tg_public_ip" {
459 name = "tg_public_ip"
460 resource_group_name = azurerm_resource_group.CSIT.name
461 depends_on = [ azurerm_virtual_machine.tg ]
464 data "azurerm_public_ip" "dut1_public_ip" {
465 name = "dut1_public_ip"
466 resource_group_name = azurerm_resource_group.CSIT.name
467 depends_on = [ azurerm_virtual_machine.dut1 ]
470 data "azurerm_public_ip" "dut2_public_ip" {
471 name = "dut2_public_ip"
472 resource_group_name = azurerm_resource_group.CSIT.name
473 depends_on = [ azurerm_virtual_machine.dut2 ]
478 resource "null_resource" "deploy_tg" {
479 depends_on = [ azurerm_virtual_machine.tg,
480 azurerm_network_interface.tg_if1,
481 azurerm_network_interface.tg_if2 ]
484 host = data.azurerm_public_ip.tg_public_ip.ip_address
485 private_key = file("~/.ssh/id_rsa")
487 provisioner "ansible" {
490 file_path = "../../testbed-setup/ansible/site_azure.yaml"
491 force_handlers = true
495 ansible_python_interpreter = "/usr/bin/python3"
502 resource "null_resource" "deploy_dut1" {
503 depends_on = [ azurerm_virtual_machine.dut1,
504 azurerm_network_interface.dut1_if1,
505 azurerm_network_interface.dut1_if2 ]
508 host = data.azurerm_public_ip.dut1_public_ip.ip_address
509 private_key = file("~/.ssh/id_rsa")
511 provisioner "ansible" {
514 file_path = "../../testbed-setup/ansible/site_azure.yaml"
515 force_handlers = true
519 ansible_python_interpreter = "/usr/bin/python3"
526 resource "null_resource" "deploy_dut2" {
527 depends_on = [ azurerm_virtual_machine.dut2,
528 azurerm_network_interface.dut2_if1,
529 azurerm_network_interface.dut2_if2 ]
532 host = data.azurerm_public_ip.dut2_public_ip.ip_address
533 private_key = file("~/.ssh/id_rsa")
535 provisioner "ansible" {
538 file_path = "../../testbed-setup/ansible/site_azure.yaml"
539 force_handlers = true
543 ansible_python_interpreter = "/usr/bin/python3"
550 resource "null_resource" "deploy_topology" {
551 depends_on = [ azurerm_virtual_machine.tg,
552 azurerm_network_interface.tg_if1,
553 azurerm_network_interface.tg_if2,
554 azurerm_virtual_machine.dut1,
555 azurerm_network_interface.dut1_if1,
556 azurerm_network_interface.dut1_if2,
557 azurerm_virtual_machine.dut2,
558 azurerm_network_interface.dut2_if1,
559 azurerm_network_interface.dut2_if2 ]
560 provisioner "ansible" {
563 file_path = "../../testbed-setup/ansible/cloud_topology.yaml"
567 ansible_python_interpreter = "/usr/bin/python3"
568 cloud_topology = "3n_azure_Fsv2"
569 tg_if1_mac = data.azurerm_network_interface.tg_if1.mac_address
570 tg_if2_mac = data.azurerm_network_interface.tg_if2.mac_address
571 dut1_if1_mac = data.azurerm_network_interface.dut1_if1.mac_address
572 dut1_if2_mac = data.azurerm_network_interface.dut1_if2.mac_address
573 dut2_if1_mac = data.azurerm_network_interface.dut2_if1.mac_address
574 dut2_if2_mac = data.azurerm_network_interface.dut2_if2.mac_address
575 tg_public_ip = data.azurerm_public_ip.tg_public_ip.ip_address
576 dut1_public_ip = data.azurerm_public_ip.dut1_public_ip.ip_address
577 dut2_public_ip = data.azurerm_public_ip.dut2_public_ip.ip_address
584 value = "TG IP: ${data.azurerm_public_ip.tg_public_ip.ip_address}"
588 value = "DUT1 IP: ${data.azurerm_public_ip.dut1_public_ip.ip_address}"
592 value = "DUT2 IP: ${data.azurerm_public_ip.dut2_public_ip.ip_address}"