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 "a_gateway" {
40 default = "192.168.0.1"
42 variable "b_gateway" {
44 default = "192.168.10.1"
46 variable "c_gateway" {
50 variable "d_gateway" {
52 default = "192.168.20.1"
54 variable "tg_if1_ip" {
56 default = "192.168.10.254"
58 variable "tg_if2_ip" {
60 default = "192.168.20.254"
62 variable "dut1_if1_ip" {
64 default = "192.168.10.11"
66 variable "dut1_if2_ip" {
68 default = "200.0.0.101"
70 variable "dut2_if1_ip" {
72 default = "200.0.0.102"
74 variable "dut2_if2_ip" {
76 default = "192.168.20.11"
78 variable "tg_mgmt_ip" {
80 default = "192.168.0.10"
82 variable "dut1_mgmt_ip" {
84 default = "192.168.0.11"
86 variable "dut2_mgmt_ip" {
88 default = "192.168.0.12"
92 variable "instance_type" {
94 default = "c5n.9xlarge"
97 resource "aws_vpc" "CSIT" {
98 cidr_block = var.vpc_cidr_mgmt
101 resource "aws_security_group" "CSIT" {
103 description = "Allow inbound traffic"
104 vpc_id = aws_vpc.CSIT.id
110 cidr_blocks = ["0.0.0.0/0"]
124 cidr_blocks = ["0.0.0.0/0"]
127 depends_on = [aws_vpc.CSIT]
130 resource "aws_vpc_ipv4_cidr_block_association" "b" {
131 vpc_id = aws_vpc.CSIT.id
132 cidr_block = var.vpc_cidr_b
133 depends_on = [aws_vpc.CSIT]
135 resource "aws_vpc_ipv4_cidr_block_association" "c" {
136 vpc_id = aws_vpc.CSIT.id
137 cidr_block = var.vpc_cidr_c
138 depends_on = [aws_vpc.CSIT]
140 resource "aws_vpc_ipv4_cidr_block_association" "d" {
141 vpc_id = aws_vpc.CSIT.id
142 cidr_block = var.vpc_cidr_d
143 depends_on = [aws_vpc.CSIT]
146 resource "aws_subnet" "mgmt" {
147 vpc_id = aws_vpc.CSIT.id
148 cidr_block = var.vpc_cidr_mgmt
149 availability_zone = var.avail_zone
150 depends_on = [aws_vpc.CSIT]
153 resource "aws_subnet" "b" {
154 vpc_id = aws_vpc.CSIT.id
155 cidr_block = var.vpc_cidr_b
156 availability_zone = var.avail_zone
157 depends_on = [aws_vpc.CSIT, aws_vpc_ipv4_cidr_block_association.b]
160 resource "aws_subnet" "c" {
161 vpc_id = aws_vpc.CSIT.id
162 cidr_block = var.vpc_cidr_c
163 availability_zone = var.avail_zone
164 depends_on = [aws_vpc.CSIT, aws_vpc_ipv4_cidr_block_association.c]
167 resource "aws_subnet" "d" {
168 vpc_id = aws_vpc.CSIT.id
169 cidr_block = var.vpc_cidr_d
170 availability_zone = var.avail_zone
171 depends_on = [aws_vpc.CSIT, aws_vpc_ipv4_cidr_block_association.d]
174 resource "aws_internet_gateway" "CSIT" {
175 vpc_id = aws_vpc.CSIT.id
176 depends_on = [aws_vpc.CSIT]
179 resource "aws_key_pair" "CSIT" {
181 public_key = file("~/.ssh/id_rsa.pub")
184 data "aws_ami" "ubuntu" {
189 values = ["*hvm-ssd/ubuntu-bionic-18.04-amd64*"]
193 name = "virtualization-type"
197 owners = ["099720109477"] # Canonical
200 resource "aws_placement_group" "CSIT" {
205 resource "aws_instance" "tg" {
206 ami = data.aws_ami.ubuntu.id
207 instance_type = var.instance_type
208 # cpu_threads_per_core = 1
209 # cpu_core_count = 18
210 key_name = aws_key_pair.CSIT.key_name
211 associate_public_ip_address = true
212 subnet_id = aws_subnet.mgmt.id
213 private_ip = var.tg_mgmt_ip
214 vpc_security_group_ids = [aws_security_group.CSIT.id]
215 depends_on = [aws_vpc.CSIT, aws_placement_group.CSIT]
216 placement_group = aws_placement_group.CSIT.id
217 source_dest_check = false
220 resource "aws_instance" "dut1" {
221 ami = data.aws_ami.ubuntu.id
222 # cpu_threads_per_core = 1
223 # cpu_core_count = 18
224 instance_type = var.instance_type
225 key_name = aws_key_pair.CSIT.key_name
226 associate_public_ip_address = true
227 subnet_id = aws_subnet.mgmt.id
228 private_ip = var.dut1_mgmt_ip
229 vpc_security_group_ids = [aws_security_group.CSIT.id]
230 depends_on = [aws_vpc.CSIT, aws_placement_group.CSIT]
231 placement_group = aws_placement_group.CSIT.id
232 source_dest_check = false
235 resource "aws_instance" "dut2" {
236 ami = data.aws_ami.ubuntu.id
237 # cpu_threads_per_core = 1
238 # cpu_core_count = 18
239 instance_type = var.instance_type
240 key_name = aws_key_pair.CSIT.key_name
241 associate_public_ip_address = true
242 subnet_id = aws_subnet.mgmt.id
243 private_ip = var.dut2_mgmt_ip
244 vpc_security_group_ids = [aws_security_group.CSIT.id]
245 depends_on = [aws_vpc.CSIT, aws_placement_group.CSIT]
246 placement_group = aws_placement_group.CSIT.id
247 source_dest_check = false
250 resource "aws_route" "CSIT-igw" {
251 route_table_id = aws_vpc.CSIT.main_route_table_id
252 gateway_id = aws_internet_gateway.CSIT.id
253 destination_cidr_block = "0.0.0.0/0"
254 depends_on = [aws_vpc.CSIT, aws_internet_gateway.CSIT]
256 resource "aws_route" "dummy-trex-port-0" {
257 route_table_id = aws_vpc.CSIT.main_route_table_id
258 network_interface_id = aws_instance.tg.primary_network_interface_id
259 destination_cidr_block = var.trex_dummy_cidr_port_0
260 depends_on = [aws_vpc.CSIT, aws_instance.dut1]
262 resource "aws_route" "dummy-trex-port-1" {
263 route_table_id = aws_vpc.CSIT.main_route_table_id
264 network_interface_id = aws_instance.tg.primary_network_interface_id
265 destination_cidr_block = var.trex_dummy_cidr_port_1
266 depends_on = [aws_vpc.CSIT, aws_instance.dut2]
269 resource "null_resource" "deploy_tg" {
270 depends_on = [ aws_instance.tg ]
273 host = aws_instance.tg.public_ip
274 private_key = file("~/.ssh/id_rsa")
276 provisioner "ansible" {
279 file_path = "../../testbed-setup/ansible/site_aws.yaml"
280 force_handlers = true
284 ansible_python_interpreter = "/usr/bin/python3"
290 resource "null_resource" "deploy_dut1" {
291 depends_on = [ aws_instance.dut1 ]
294 host = aws_instance.dut1.public_ip
295 private_key = file("~/.ssh/id_rsa")
297 provisioner "ansible" {
300 file_path = "../../testbed-setup/ansible/site_aws.yaml"
301 force_handlers = true
305 ansible_python_interpreter = "/usr/bin/python3"
311 resource "null_resource" "deploy_dut2" {
312 depends_on = [ aws_instance.dut2 ]
315 host = aws_instance.dut2.public_ip
316 private_key = file("~/.ssh/id_rsa")
318 provisioner "ansible" {
321 file_path = "../../testbed-setup/ansible/site_aws.yaml"
322 force_handlers = true
326 ansible_python_interpreter = "/usr/bin/python3"
333 resource "null_resource" "deploy_topology" {
334 depends_on = [ aws_instance.tg, aws_instance.dut1, aws_instance.dut2 ]
335 provisioner "ansible" {
338 file_path = "../../testbed-setup/ansible/cloud_topology.yaml"
342 ansible_python_interpreter = "/usr/bin/python3"
343 cloud_topology = "aws"
344 tg_if1_mac = data.aws_network_interface.tg_if1.mac_address
345 tg_if2_mac = data.aws_network_interface.tg_if2.mac_address
346 dut1_if1_mac = data.aws_network_interface.dut1_if1.mac_address
347 dut1_if2_mac = data.aws_network_interface.dut1_if2.mac_address
348 dut2_if1_mac = data.aws_network_interface.dut2_if1.mac_address
349 dut2_if2_mac = data.aws_network_interface.dut2_if2.mac_address
350 tg_public_ip = aws_instance.tg.public_ip
351 dut1_public_ip = aws_instance.dut1.public_ip
352 dut2_public_ip = aws_instance.dut2.public_ip
359 value = "TG IP: ${aws_instance.tg.public_ip}"
363 value = "DUT1 IP: ${aws_instance.dut1.public_ip}"
367 value = "DUT2 IP: ${aws_instance.dut2.public_ip}"