Skip to content
This repository was archived by the owner on Feb 11, 2020. It is now read-only.

Commit b3cdc20

Browse files
alexwlchankenoir
authored andcommitted
Make the environment variables length a static variable (#32)
* Expose an env_vars length to work around a TF bug * Use the right version of the modules * Fix name * Fix the pluralisation issue * Count the service vars as well
1 parent eb4beb8 commit b3cdc20

6 files changed

Lines changed: 12 additions & 4 deletions

File tree

service/ecs_task/data.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ data "aws_iam_role" "task_role" {
7272
# docs: https://www.terraform.io/docs/configuration/interpolation.html
7373

7474
data "template_file" "name_val_pair" {
75-
count = "${length(local.env_vars)}"
75+
count = "${var.config_vars_length + length(var.service_vars)}"
7676
template = "{\"name\": $${jsonencode(key)}, \"value\": $${jsonencode(value)}}"
7777

7878
vars {

service/ecs_task/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ variable "config_vars" {
5656
type = "map"
5757
}
5858

59+
variable "config_vars_length" {}
60+
5961
variable "memory" {
6062
description = "How much memory to allocate to the app"
6163
}

service/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ module "task" {
5353
NGINX_PORT = "${var.primary_container_port}"
5454
}
5555

56-
config_vars = "${var.env_vars}"
56+
config_vars = "${var.env_vars}"
57+
config_vars_length = "${var.env_vars_length}"
5758

5859
log_group_name_prefix = "${var.log_group_name_prefix}"
5960
}

service/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ variable "env_vars" {
8888
default = {}
8989
}
9090

91+
variable "env_vars_length" {}
92+
9193
variable "host_name" {
9294
description = "Hostname to be matched in the host condition"
9395
default = ""

sqs_autoscaling_service/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ data "aws_ecs_cluster" "cluster" {
2121
}
2222

2323
module "service" {
24-
source = "git::https://github.com/wellcometrust/terraform-modules.git//service?ref=v4.0.0"
24+
source = "git::https://github.com/wellcometrust/terraform-modules.git//service?ref=env_vars_length"
2525
name = "${var.name}"
2626

2727
cluster_id = "${data.aws_ecs_cluster.cluster.arn}"
@@ -41,7 +41,8 @@ module "service" {
4141
deployment_minimum_healthy_percent = "0"
4242
deployment_maximum_percent = "200"
4343

44-
env_vars = "${var.env_vars}"
44+
env_vars = "${var.env_vars}"
45+
env_vars_length = "${var.env_vars_length}"
4546

4647
loadbalancer_cloudwatch_id = "${var.alb_cloudwatch_id}"
4748
server_error_alarm_topic_arn = "${var.alb_server_error_alarm_arn}"

sqs_autoscaling_service/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ variable "env_vars" {
1919
type = "map"
2020
}
2121

22+
variable "env_vars_length" {}
23+
2224
variable "alb_priority" {}
2325
variable "alb_listener_https_arn" {}
2426
variable "alb_listener_http_arn" {}

0 commit comments

Comments
 (0)