Skip to content

Commit

Permalink
Expose gateway_count in gateway module (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmadell523 authored Sep 29, 2023
1 parent 9c7e419 commit 1e7217d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/gateway-task/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion modules/gateway-task/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -354,4 +360,4 @@ variable "grpc_config" {
contains(["port", "tls", "tlsServerName", "caCertFile"], key)
])
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/acceptance/tests/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ func TestValidation_MeshGateway(t *testing.T) {
lbModifySecGroup bool
lbModifySecGroupID string
expError string
gatewayCount int
}{
"kind is required": {
kind: "",
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1e7217d

Please sign in to comment.