From 584b2dbce7e99e4da7b4e95695910fba6eb4b17f Mon Sep 17 00:00:00 2001 From: Zach Madell Date: Wed, 20 Sep 2023 17:41:13 -0600 Subject: [PATCH 1/7] add gateway_count variable --- modules/gateway-task/main.tf | 2 +- modules/gateway-task/variables.tf | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/gateway-task/main.tf b/modules/gateway-task/main.tf index dbaec083..2953c249 100644 --- a/modules/gateway-task/main.tf +++ b/modules/gateway-task/main.tf @@ -184,7 +184,7 @@ resource "aws_ecs_service" "this" { name = local.service_name cluster = var.ecs_cluster_arn task_definition = aws_ecs_task_definition.this.arn - desired_count = 1 + desired_count = var.gateway_count network_configuration { subnets = var.subnets security_groups = local.security_groups diff --git a/modules/gateway-task/variables.tf b/modules/gateway-task/variables.tf index 67c9c1fc..63db1dc1 100644 --- a/modules/gateway-task/variables.tf +++ b/modules/gateway-task/variables.tf @@ -6,6 +6,12 @@ variable "family" { type = string } +variable "gateway_count" { + description = "Number of gateways to deploy to ECS." + type = number + default = 1 +} + variable "ecs_cluster_arn" { description = "The ARN of the ECS cluster where the gateway will be running." type = string @@ -354,4 +360,4 @@ variable "grpc_config" { contains(["port", "tls", "tlsServerName", "caCertFile"], key) ]) } -} \ No newline at end of file +} From 1328f51dc82b245ed592fef25bd038d6e1c341b7 Mon Sep 17 00:00:00 2001 From: Zach Madell Date: Mon, 25 Sep 2023 09:35:39 -0600 Subject: [PATCH 2/7] test --- .../terraform/mesh-gateway-validate/main.tf | 5 +++++ test/acceptance/tests/validation/validation_test.go | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/test/acceptance/tests/validation/terraform/mesh-gateway-validate/main.tf b/test/acceptance/tests/validation/terraform/mesh-gateway-validate/main.tf index b903de4d..e3c3e569 100644 --- a/test/acceptance/tests/validation/terraform/mesh-gateway-validate/main.tf +++ b/test/acceptance/tests/validation/terraform/mesh-gateway-validate/main.tf @@ -60,6 +60,10 @@ variable "lb_modify_security_group_id" { default = "" } +variable "gateway_count" { + type = number + default = 1 +} module "test_gateway" { source = "../../../../../../modules/gateway-task" @@ -68,6 +72,7 @@ module "test_gateway" { subnets = ["subnets"] security_groups = var.security_groups kind = var.kind + gateway_count = var.gateway_count consul_server_hosts = "localhost:8500" enable_mesh_gateway_wan_federation = var.enable_mesh_gateway_wan_federation tls = var.tls diff --git a/test/acceptance/tests/validation/validation_test.go b/test/acceptance/tests/validation/validation_test.go index ce419e6f..21125993 100644 --- a/test/acceptance/tests/validation/validation_test.go +++ b/test/acceptance/tests/validation/validation_test.go @@ -786,6 +786,7 @@ func TestValidation_MeshGateway(t *testing.T) { lbModifySecGroup bool lbModifySecGroupID string expError string + gatewayCount int }{ "kind is required": { kind: "", @@ -823,8 +824,7 @@ func TestValidation_MeshGateway(t *testing.T) { kind: "mesh-gateway", lbEnabled: true, lbSubnets: []string{"subnet"}, - lbVpcID: "vpc", - }, + lbVpcID: "vpc", }, "lb_enabled and no lb subnets": { kind: "mesh-gateway", lbEnabled: true, @@ -868,6 +868,13 @@ func TestValidation_MeshGateway(t *testing.T) { lbModifySecGroup: true, lbModifySecGroupID: "mod-sg", }, + "multiple gateways": { + kind: "mesh-gateway", + lbEnabled: true, + lbSubnets: []string{"subnet"}, + lbVpcID: "vpc", + gatewayCount: 2, + }, } for name, c := range cases { c := c @@ -885,6 +892,7 @@ func TestValidation_MeshGateway(t *testing.T) { "lb_create_security_group": c.lbCreateSecGroup, "lb_modify_security_group": c.lbModifySecGroup, "lb_modify_security_group_id": c.lbModifySecGroupID, + "multiple_gateways": c.gatewayCount, } if len(c.kind) > 0 { tfVars["kind"] = c.kind From 6000a0853697ed48163afa7557671038489ff3c3 Mon Sep 17 00:00:00 2001 From: Zach Madell Date: Mon, 25 Sep 2023 09:38:06 -0600 Subject: [PATCH 3/7] fix var --- test/acceptance/tests/validation/validation_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/acceptance/tests/validation/validation_test.go b/test/acceptance/tests/validation/validation_test.go index 21125993..6815d5e6 100644 --- a/test/acceptance/tests/validation/validation_test.go +++ b/test/acceptance/tests/validation/validation_test.go @@ -892,7 +892,7 @@ func TestValidation_MeshGateway(t *testing.T) { "lb_create_security_group": c.lbCreateSecGroup, "lb_modify_security_group": c.lbModifySecGroup, "lb_modify_security_group_id": c.lbModifySecGroupID, - "multiple_gateways": c.gatewayCount, + "gateway_count": c.gatewayCount, } if len(c.kind) > 0 { tfVars["kind"] = c.kind From cb8d9b5d1b5cd87bc762829b1b6c8b8f20052bdd Mon Sep 17 00:00:00 2001 From: Zach Madell Date: Mon, 25 Sep 2023 09:40:47 -0600 Subject: [PATCH 4/7] fmt --- test/acceptance/tests/validation/validation_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/acceptance/tests/validation/validation_test.go b/test/acceptance/tests/validation/validation_test.go index 6815d5e6..a83e7436 100644 --- a/test/acceptance/tests/validation/validation_test.go +++ b/test/acceptance/tests/validation/validation_test.go @@ -786,7 +786,7 @@ func TestValidation_MeshGateway(t *testing.T) { lbModifySecGroup bool lbModifySecGroupID string expError string - gatewayCount int + gatewayCount int }{ "kind is required": { kind: "", @@ -824,7 +824,7 @@ func TestValidation_MeshGateway(t *testing.T) { kind: "mesh-gateway", lbEnabled: true, lbSubnets: []string{"subnet"}, - lbVpcID: "vpc", }, + lbVpcID: "vpc"}, "lb_enabled and no lb subnets": { kind: "mesh-gateway", lbEnabled: true, @@ -869,10 +869,10 @@ func TestValidation_MeshGateway(t *testing.T) { lbModifySecGroupID: "mod-sg", }, "multiple gateways": { - kind: "mesh-gateway", - lbEnabled: true, - lbSubnets: []string{"subnet"}, - lbVpcID: "vpc", + kind: "mesh-gateway", + lbEnabled: true, + lbSubnets: []string{"subnet"}, + lbVpcID: "vpc", gatewayCount: 2, }, } From eda35f5ce64aab884c6eddaceb803732765e0dc6 Mon Sep 17 00:00:00 2001 From: Zach Madell Date: Mon, 25 Sep 2023 09:43:07 -0600 Subject: [PATCH 5/7] tf fmt --- .../tests/validation/terraform/mesh-gateway-validate/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/acceptance/tests/validation/terraform/mesh-gateway-validate/main.tf b/test/acceptance/tests/validation/terraform/mesh-gateway-validate/main.tf index e3c3e569..623b1a14 100644 --- a/test/acceptance/tests/validation/terraform/mesh-gateway-validate/main.tf +++ b/test/acceptance/tests/validation/terraform/mesh-gateway-validate/main.tf @@ -72,7 +72,7 @@ module "test_gateway" { subnets = ["subnets"] security_groups = var.security_groups kind = var.kind - gateway_count = var.gateway_count + gateway_count = var.gateway_count consul_server_hosts = "localhost:8500" enable_mesh_gateway_wan_federation = var.enable_mesh_gateway_wan_federation tls = var.tls From a34e3e844414c828ba9b6aa6ecf7dbc92c00539e Mon Sep 17 00:00:00 2001 From: Zach Madell <102036230+zmadell523@users.noreply.github.com> Date: Wed, 27 Sep 2023 09:29:26 -0600 Subject: [PATCH 6/7] Update test/acceptance/tests/validation/validation_test.go Co-authored-by: Ganesh S --- test/acceptance/tests/validation/validation_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/acceptance/tests/validation/validation_test.go b/test/acceptance/tests/validation/validation_test.go index a83e7436..8b61cecf 100644 --- a/test/acceptance/tests/validation/validation_test.go +++ b/test/acceptance/tests/validation/validation_test.go @@ -824,7 +824,8 @@ func TestValidation_MeshGateway(t *testing.T) { kind: "mesh-gateway", lbEnabled: true, lbSubnets: []string{"subnet"}, - lbVpcID: "vpc"}, + lbVpcID: "vpc" + }, "lb_enabled and no lb subnets": { kind: "mesh-gateway", lbEnabled: true, From f53dd0de8011740c1edaaafec0c2d87285dbec95 Mon Sep 17 00:00:00 2001 From: Zach Madell Date: Wed, 27 Sep 2023 09:38:10 -0600 Subject: [PATCH 7/7] comma --- test/acceptance/tests/validation/validation_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/acceptance/tests/validation/validation_test.go b/test/acceptance/tests/validation/validation_test.go index 8b61cecf..bb093089 100644 --- a/test/acceptance/tests/validation/validation_test.go +++ b/test/acceptance/tests/validation/validation_test.go @@ -824,7 +824,7 @@ func TestValidation_MeshGateway(t *testing.T) { kind: "mesh-gateway", lbEnabled: true, lbSubnets: []string{"subnet"}, - lbVpcID: "vpc" + lbVpcID: "vpc", }, "lb_enabled and no lb subnets": { kind: "mesh-gateway",