Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose gateway_count in gateway module #210

Merged
merged 7 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 10 additions & 2 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 @@ -823,8 +824,7 @@ func TestValidation_MeshGateway(t *testing.T) {
kind: "mesh-gateway",
lbEnabled: true,
lbSubnets: []string{"subnet"},
lbVpcID: "vpc",
},
lbVpcID: "vpc"},
zmadell523 marked this conversation as resolved.
Show resolved Hide resolved
"lb_enabled and no lb subnets": {
kind: "mesh-gateway",
lbEnabled: true,
Expand Down Expand Up @@ -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
Expand All @@ -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,
"gateway_count": c.gatewayCount,
}
if len(c.kind) > 0 {
tfVars["kind"] = c.kind
Expand Down