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 +} 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..623b1a14 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..bb093089 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: "", @@ -868,6 +869,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 +893,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, + "gateway_count": c.gatewayCount, } if len(c.kind) > 0 { tfVars["kind"] = c.kind