2 region = "eu-central-1"
5 variable "avail_zone" {
7 default = "eu-central-1a"
10 variable "vpc_cidr_mgmt" {
12 default = "192.168.0.0/24"
14 variable "vpc_cidr_b" {
16 default = "192.168.10.0/24"
18 variable "vpc_cidr_c" {
20 default = "200.0.0.0/24"
22 variable "vpc_cidr_d" {
24 default = "192.168.20.0/24"
28 variable "trex_dummy_cidr_port_0" {
30 default = "10.0.0.0/24"
32 variable "trex_dummy_cidr_port_1" {
34 default = "20.0.0.0/24"
38 variable "tg_if1_ip" {
40 default = "192.168.10.254"
42 variable "tg_if2_ip" {
44 default = "192.168.20.254"
46 variable "dut1_if1_ip" {
48 default = "192.168.10.11"
50 variable "dut1_if2_ip" {
52 default = "200.0.0.101"
54 variable "dut2_if1_ip" {
56 default = "200.0.0.102"
58 variable "dut2_if2_ip" {
60 default = "192.168.20.11"
62 variable "tg_mgmt_ip" {
64 default = "192.168.0.10"
66 variable "dut1_mgmt_ip" {
68 default = "192.168.0.11"
70 variable "dut2_mgmt_ip" {
72 default = "192.168.0.12"
76 variable "instance_type" {
78 default = "c5n.9xlarge"
81 resource "aws_vpc" "CSIT" {
82 cidr_block = var.vpc_cidr_mgmt
85 resource "aws_security_group" "CSIT" {
87 description = "Allow inbound traffic"
88 vpc_id = aws_vpc.CSIT.id
94 cidr_blocks = ["0.0.0.0/0"]
108 cidr_blocks = ["0.0.0.0/0"]
111 depends_on = [aws_vpc.CSIT]
114 resource "aws_vpc_ipv4_cidr_block_association" "b" {
115 vpc_id = aws_vpc.CSIT.id
116 cidr_block = var.vpc_cidr_b
117 depends_on = [aws_vpc.CSIT]
119 resource "aws_vpc_ipv4_cidr_block_association" "c" {
120 vpc_id = aws_vpc.CSIT.id
121 cidr_block = var.vpc_cidr_c
122 depends_on = [aws_vpc.CSIT]
124 resource "aws_vpc_ipv4_cidr_block_association" "d" {
125 vpc_id = aws_vpc.CSIT.id
126 cidr_block = var.vpc_cidr_d
127 depends_on = [aws_vpc.CSIT]
130 resource "aws_subnet" "mgmt" {
131 vpc_id = aws_vpc.CSIT.id
132 cidr_block = var.vpc_cidr_mgmt
133 availability_zone = var.avail_zone
134 depends_on = [aws_vpc.CSIT]
137 resource "aws_subnet" "b" {
138 vpc_id = aws_vpc.CSIT.id
139 cidr_block = var.vpc_cidr_b
140 availability_zone = var.avail_zone
141 depends_on = [aws_vpc.CSIT, aws_vpc_ipv4_cidr_block_association.b]
144 resource "aws_subnet" "c" {
145 vpc_id = aws_vpc.CSIT.id
146 cidr_block = var.vpc_cidr_c
147 availability_zone = var.avail_zone
148 depends_on = [aws_vpc.CSIT, aws_vpc_ipv4_cidr_block_association.c]
151 resource "aws_subnet" "d" {
152 vpc_id = aws_vpc.CSIT.id
153 cidr_block = var.vpc_cidr_d
154 availability_zone = var.avail_zone
155 depends_on = [aws_vpc.CSIT, aws_vpc_ipv4_cidr_block_association.d]
158 resource "aws_internet_gateway" "CSIT" {
159 vpc_id = aws_vpc.CSIT.id
160 depends_on = [aws_vpc.CSIT]
163 resource "aws_key_pair" "CSIT" {
165 public_key = file("~/.ssh/id_rsa.pub")
168 data "aws_ami" "ubuntu" {
173 values = ["*hvm-ssd/ubuntu-bionic-18.04-amd64*"]
177 name = "virtualization-type"
181 owners = ["099720109477"] # Canonical
184 resource "aws_placement_group" "CSIT" {
189 resource "aws_instance" "tg" {
190 ami = data.aws_ami.ubuntu.id
191 instance_type = var.instance_type
192 # cpu_threads_per_core = 1
193 # cpu_core_count = 18
194 key_name = aws_key_pair.CSIT.key_name
195 associate_public_ip_address = true
196 subnet_id = aws_subnet.mgmt.id
200 private_ip = var.tg_mgmt_ip
201 vpc_security_group_ids = [aws_security_group.CSIT.id]
202 depends_on = [aws_vpc.CSIT, aws_placement_group.CSIT]
203 placement_group = aws_placement_group.CSIT.id
204 source_dest_check = false
207 resource "aws_instance" "dut1" {
208 ami = data.aws_ami.ubuntu.id
209 # cpu_threads_per_core = 1
210 # cpu_core_count = 18
211 instance_type = var.instance_type
212 key_name = aws_key_pair.CSIT.key_name
213 associate_public_ip_address = true
214 subnet_id = aws_subnet.mgmt.id
218 private_ip = var.dut1_mgmt_ip
219 vpc_security_group_ids = [aws_security_group.CSIT.id]
220 depends_on = [aws_vpc.CSIT, aws_placement_group.CSIT]
221 placement_group = aws_placement_group.CSIT.id
222 source_dest_check = false
225 resource "aws_instance" "dut2" {
226 ami = data.aws_ami.ubuntu.id
227 # cpu_threads_per_core = 1
228 # cpu_core_count = 18
229 instance_type = var.instance_type
230 key_name = aws_key_pair.CSIT.key_name
231 associate_public_ip_address = true
232 subnet_id = aws_subnet.mgmt.id
236 private_ip = var.dut2_mgmt_ip
237 vpc_security_group_ids = [aws_security_group.CSIT.id]
238 depends_on = [aws_vpc.CSIT, aws_placement_group.CSIT]
239 placement_group = aws_placement_group.CSIT.id
240 source_dest_check = false
243 resource "aws_route" "CSIT-igw" {
244 route_table_id = aws_vpc.CSIT.main_route_table_id
245 gateway_id = aws_internet_gateway.CSIT.id
246 destination_cidr_block = "0.0.0.0/0"
247 depends_on = [aws_vpc.CSIT, aws_internet_gateway.CSIT]
249 resource "aws_route" "dummy-trex-port-0" {
250 route_table_id = aws_vpc.CSIT.main_route_table_id
251 network_interface_id = aws_instance.tg.primary_network_interface_id
252 destination_cidr_block = var.trex_dummy_cidr_port_0
253 depends_on = [aws_vpc.CSIT, aws_instance.dut1]
255 resource "aws_route" "dummy-trex-port-1" {
256 route_table_id = aws_vpc.CSIT.main_route_table_id
257 network_interface_id = aws_instance.tg.primary_network_interface_id
258 destination_cidr_block = var.trex_dummy_cidr_port_1
259 depends_on = [aws_vpc.CSIT, aws_instance.dut2]
262 resource "null_resource" "deploy_tg" {
263 depends_on = [ aws_instance.tg ]
266 host = aws_instance.tg.public_ip
267 private_key = file("~/.ssh/id_rsa")
269 provisioner "ansible" {
272 file_path = "../../testbed-setup/ansible/site_aws.yaml"
273 force_handlers = true
277 ansible_python_interpreter = "/usr/bin/python3"
283 resource "null_resource" "deploy_dut1" {
284 depends_on = [ aws_instance.dut1 ]
287 host = aws_instance.dut1.public_ip
288 private_key = file("~/.ssh/id_rsa")
290 provisioner "ansible" {
293 file_path = "../../testbed-setup/ansible/site_aws.yaml"
294 force_handlers = true
298 ansible_python_interpreter = "/usr/bin/python3"
304 resource "null_resource" "deploy_dut2" {
305 depends_on = [ aws_instance.dut2 ]
308 host = aws_instance.dut2.public_ip
309 private_key = file("~/.ssh/id_rsa")
311 provisioner "ansible" {
314 file_path = "../../testbed-setup/ansible/site_aws.yaml"
315 force_handlers = true
319 ansible_python_interpreter = "/usr/bin/python3"
326 resource "null_resource" "deploy_topology" {
327 depends_on = [ aws_instance.tg, aws_instance.dut1, aws_instance.dut2 ]
328 provisioner "ansible" {
331 file_path = "../../testbed-setup/ansible/cloud_topology.yaml"
335 ansible_python_interpreter = "/usr/bin/python3"
336 cloud_topology = "3n_aws_c5n"
337 tg_if1_mac = data.aws_network_interface.tg_if1.mac_address
338 tg_if2_mac = data.aws_network_interface.tg_if2.mac_address
339 dut1_if1_mac = data.aws_network_interface.dut1_if1.mac_address
340 dut1_if2_mac = data.aws_network_interface.dut1_if2.mac_address
341 dut2_if1_mac = data.aws_network_interface.dut2_if1.mac_address
342 dut2_if2_mac = data.aws_network_interface.dut2_if2.mac_address
343 tg_public_ip = aws_instance.tg.public_ip
344 dut1_public_ip = aws_instance.dut1.public_ip
345 dut2_public_ip = aws_instance.dut2.public_ip
352 value = "TG IP: ${aws_instance.tg.public_ip}"
356 value = "DUT1 IP: ${aws_instance.dut1.public_ip}"
360 value = "DUT2 IP: ${aws_instance.dut2.public_ip}"