Small AWS terraform cleanup 02/25302/2
authorMaros Mullner <maros.mullner@pantheon.tech>
Thu, 20 Feb 2020 09:17:47 +0000 (10:17 +0100)
committerPeter Mikus <pmikus@cisco.com>
Thu, 20 Feb 2020 09:33:28 +0000 (09:33 +0000)
Signed-off-by: Maros Mullner <maros.mullner@pantheon.tech>
Change-Id: I5acd3dd0b9e2e6beb03c94362ab739601da39443

resources/tools/terraform/aws/main.tf
resources/tools/terraform/aws/nic.tf

index 74baa12..49ef73e 100644 (file)
@@ -35,22 +35,6 @@ variable "trex_dummy_cidr_port_1" {
 }
 
 # IPs
 }
 
 # IPs
-variable "a_gateway" {
-  type = string
-  default = "192.168.0.1"
-}
-variable "b_gateway" {
-  type = string
-  default = "192.168.10.1"
-}
-variable "c_gateway" {
-  type = string
-  default = "200.0.0.1"
-}
-variable "d_gateway" {
-  type = string
-  default = "192.168.20.1"
-}
 variable "tg_if1_ip" {
   type = string
   default = "192.168.10.254"
 variable "tg_if1_ip" {
   type = string
   default = "192.168.10.254"
@@ -100,7 +84,7 @@ resource "aws_vpc" "CSIT" {
 
 resource "aws_security_group" "CSIT" {
   name        = "CSIT"
 
 resource "aws_security_group" "CSIT" {
   name        = "CSIT"
-  description = "Allow  inbound traffic"
+  description = "Allow inbound traffic"
   vpc_id = aws_vpc.CSIT.id
 
   ingress {
   vpc_id = aws_vpc.CSIT.id
 
   ingress {
@@ -118,27 +102,27 @@ resource "aws_security_group" "CSIT" {
   }
 
   egress {
   }
 
   egress {
-    from_port       = 0
-    to_port         = 0
-    protocol        = "-1"
-    cidr_blocks     = ["0.0.0.0/0"]
+    from_port = 0
+    to_port = 0
+    protocol = "-1"
+    cidr_blocks = ["0.0.0.0/0"]
   }
 
   depends_on = [aws_vpc.CSIT]
 }
 
 resource "aws_vpc_ipv4_cidr_block_association" "b" {
   }
 
   depends_on = [aws_vpc.CSIT]
 }
 
 resource "aws_vpc_ipv4_cidr_block_association" "b" {
-  vpc_id     = aws_vpc.CSIT.id
+  vpc_id = aws_vpc.CSIT.id
   cidr_block = var.vpc_cidr_b
   depends_on = [aws_vpc.CSIT]
 }
 resource "aws_vpc_ipv4_cidr_block_association" "c" {
   cidr_block = var.vpc_cidr_b
   depends_on = [aws_vpc.CSIT]
 }
 resource "aws_vpc_ipv4_cidr_block_association" "c" {
-  vpc_id     = aws_vpc.CSIT.id
+  vpc_id = aws_vpc.CSIT.id
   cidr_block = var.vpc_cidr_c
   depends_on = [aws_vpc.CSIT]
 }
 resource "aws_vpc_ipv4_cidr_block_association" "d" {
   cidr_block = var.vpc_cidr_c
   depends_on = [aws_vpc.CSIT]
 }
 resource "aws_vpc_ipv4_cidr_block_association" "d" {
-  vpc_id     = aws_vpc.CSIT.id
+  vpc_id = aws_vpc.CSIT.id
   cidr_block = var.vpc_cidr_d
   depends_on = [aws_vpc.CSIT]
 }
   cidr_block = var.vpc_cidr_d
   depends_on = [aws_vpc.CSIT]
 }
@@ -185,12 +169,12 @@ data "aws_ami" "ubuntu" {
   most_recent = true
 
   filter {
   most_recent = true
 
   filter {
-    name   = "name"
+    name = "name"
     values = ["*hvm-ssd/ubuntu-bionic-18.04-amd64*"]
   }
 
   filter {
     values = ["*hvm-ssd/ubuntu-bionic-18.04-amd64*"]
   }
 
   filter {
-    name   = "virtualization-type"
+    name = "virtualization-type"
     values = ["hvm"]
   }
 
     values = ["hvm"]
   }
 
@@ -198,12 +182,12 @@ data "aws_ami" "ubuntu" {
 }
 
 resource "aws_placement_group" "CSIT" {
 }
 
 resource "aws_placement_group" "CSIT" {
-  name     = "CSIT"
+  name = "CSIT"
   strategy = "cluster"
 }
 
 resource "aws_instance" "tg" {
   strategy = "cluster"
 }
 
 resource "aws_instance" "tg" {
-  ami           = data.aws_ami.ubuntu.id
+  ami = data.aws_ami.ubuntu.id
   instance_type = var.instance_type
 #  cpu_threads_per_core = 1
 #  cpu_core_count = 18
   instance_type = var.instance_type
 #  cpu_threads_per_core = 1
 #  cpu_core_count = 18
@@ -218,7 +202,7 @@ resource "aws_instance" "tg" {
 }
 
 resource "aws_instance" "dut1" {
 }
 
 resource "aws_instance" "dut1" {
-  ami           = data.aws_ami.ubuntu.id
+  ami = data.aws_ami.ubuntu.id
 #  cpu_threads_per_core = 1
 #  cpu_core_count = 18
   instance_type = var.instance_type
 #  cpu_threads_per_core = 1
 #  cpu_core_count = 18
   instance_type = var.instance_type
@@ -233,7 +217,7 @@ resource "aws_instance" "dut1" {
 }
 
 resource "aws_instance" "dut2" {
 }
 
 resource "aws_instance" "dut2" {
-  ami           = data.aws_ami.ubuntu.id
+  ami = data.aws_ami.ubuntu.id
 #  cpu_threads_per_core = 1
 #  cpu_core_count = 18
   instance_type = var.instance_type
 #  cpu_threads_per_core = 1
 #  cpu_core_count = 18
   instance_type = var.instance_type
index 31926e4..3efd74f 100644 (file)
@@ -1,35 +1,35 @@
-resource "aws_network_interface" "dut1_if2" {
-  subnet_id = aws_subnet.c.id
+resource "aws_network_interface" "dut1_if1" {
+  subnet_id = aws_subnet.b.id
   source_dest_check = false
   source_dest_check = false
-  private_ip = var.dut1_if2_ip
-  private_ips = [var.dut1_if2_ip]
+  private_ip = var.dut1_if1_ip
+  private_ips = [var.dut1_if1_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
   security_groups = [aws_security_group.CSIT.id]
   attachment {
-    instance     = aws_instance.dut1.id
+    instance = aws_instance.dut1.id
     device_index = 1
   }
     device_index = 1
   }
-  depends_on = [aws_vpc.CSIT]
+  depends_on = [aws_vpc.CSIT, aws_subnet.b]
 }
 
 }
 
-data "aws_network_interface" "dut1_if2" {
-  id = aws_network_interface.dut1_if2.id
+data "aws_network_interface" "dut1_if1" {
+  id = aws_network_interface.dut1_if1.id
 }
 
 }
 
-resource "aws_network_interface" "dut1_if1" {
-  subnet_id = aws_subnet.b.id
+resource "aws_network_interface" "dut1_if2" {
+  subnet_id = aws_subnet.c.id
   source_dest_check = false
   source_dest_check = false
-  private_ip = var.dut1_if1_ip
-  private_ips = [var.dut1_if1_ip]
+  private_ip = var.dut1_if2_ip
+  private_ips = [var.dut1_if2_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
   security_groups = [aws_security_group.CSIT.id]
   attachment {
-    instance     = aws_instance.dut1.id
+    instance = aws_instance.dut1.id
     device_index = 2
   }
     device_index = 2
   }
-  depends_on = [aws_vpc.CSIT, aws_subnet.b]
+  depends_on = [aws_vpc.CSIT]
 }
 
 }
 
-data "aws_network_interface" "dut1_if1" {
-  id = aws_network_interface.dut1_if1.id
+data "aws_network_interface" "dut1_if2" {
+  id = aws_network_interface.dut1_if2.id
 }
 
 resource "aws_network_interface" "dut2_if1" {
 }
 
 resource "aws_network_interface" "dut2_if1" {
@@ -39,7 +39,7 @@ resource "aws_network_interface" "dut2_if1" {
   private_ips = [var.dut2_if1_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
   private_ips = [var.dut2_if1_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
-    instance     = aws_instance.dut2.id
+    instance = aws_instance.dut2.id
     device_index = 1
   }
   depends_on = [aws_vpc.CSIT, aws_subnet.c]
     device_index = 1
   }
   depends_on = [aws_vpc.CSIT, aws_subnet.c]
@@ -56,7 +56,7 @@ resource "aws_network_interface" "dut2_if2" {
   private_ips = [var.dut2_if2_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
   private_ips = [var.dut2_if2_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
-    instance     = aws_instance.dut2.id
+    instance = aws_instance.dut2.id
     device_index = 2
   }
   depends_on = [aws_vpc.CSIT, aws_subnet.d]
     device_index = 2
   }
   depends_on = [aws_vpc.CSIT, aws_subnet.d]
@@ -73,7 +73,7 @@ resource "aws_network_interface" "tg_if1" {
   private_ips = [var.tg_if1_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
   private_ips = [var.tg_if1_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
-    instance     = aws_instance.tg.id
+    instance = aws_instance.tg.id
     device_index = 1
   }
   depends_on = [aws_vpc.CSIT, aws_subnet.b]
     device_index = 1
   }
   depends_on = [aws_vpc.CSIT, aws_subnet.b]
@@ -90,7 +90,7 @@ resource "aws_network_interface" "tg_if2" {
   private_ips = [var.tg_if2_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
   private_ips = [var.tg_if2_ip]
   security_groups = [aws_security_group.CSIT.id]
   attachment {
-    instance     = aws_instance.tg.id
+    instance = aws_instance.tg.id
     device_index = 2
   }
   depends_on = [aws_vpc.CSIT, aws_subnet.d]
     device_index = 2
   }
   depends_on = [aws_vpc.CSIT, aws_subnet.d]