From df62c589e9948f33a040e11ea9fc632ce6bb2b34 Mon Sep 17 00:00:00 2001 From: nitro Date: Mon, 27 Jul 2020 16:07:03 -0400 Subject: [PATCH 1/7] var.container_definition to override definition --- variables.tf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/variables.tf b/variables.tf index 98068d9b..ec10af5e 100644 --- a/variables.tf +++ b/variables.tf @@ -877,3 +877,9 @@ variable "init_containers" { description = "A list of additional init containers to start. The map contains the container_definition (JSON) and the main container's dependency condition (string) on the init container. The latter can be one of START, COMPLETE, SUCCESS or HEALTHY." default = [] } + +variable "container_definition" { + type = map(string) + description = "Override the main container_definition" + default = [] +} From 178abd475a01d22030eeeb0c62a70bfcd16e0c1a Mon Sep 17 00:00:00 2001 From: nitro Date: Mon, 27 Jul 2020 16:12:01 -0400 Subject: [PATCH 2/7] Override the container_definition --- main.tf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index add1c777..bd8996c8 100644 --- a/main.tf +++ b/main.tf @@ -118,6 +118,11 @@ locals { condition = init_container.condition } ] + + # override container_definition if var.container_definition is supplied + main_container_definition = coalesce(var.container_definition, module.container_definition.json_map) + # combine all container definitions + all_container_definitions = "[${join(",", concat(local.init_container_definitions, [local.main_container_definition]))}]" } module "ecs_alb_service_task" { @@ -130,7 +135,7 @@ module "ecs_alb_service_task" { use_alb_security_group = var.use_alb_security_group nlb_cidr_blocks = var.nlb_cidr_blocks use_nlb_cidr_blocks = var.use_nlb_cidr_blocks - container_definition_json = "[${join(",", concat(local.init_container_definitions, [module.container_definition.json_map]))}]" + container_definition_json = local.all_container_definitions desired_count = var.desired_count health_check_grace_period_seconds = var.health_check_grace_period_seconds task_cpu = coalesce(var.task_cpu, var.container_cpu) From 8ce9eb53617bceb958dc5b8dbcfdbcd9b02893a7 Mon Sep 17 00:00:00 2001 From: nitro Date: Mon, 27 Jul 2020 16:12:32 -0400 Subject: [PATCH 3/7] Change var.container_definition to string --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index ec10af5e..1aa8fb75 100644 --- a/variables.tf +++ b/variables.tf @@ -879,7 +879,7 @@ variable "init_containers" { } variable "container_definition" { - type = map(string) + type = string description = "Override the main container_definition" default = [] } From 51960e4bacd8e79342889d5f0ac878c6dab418df Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Mon, 27 Jul 2020 20:15:52 +0000 Subject: [PATCH 4/7] Updated README.md --- README.md | 1 + docs/terraform.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index ed464d1d..33a9cb73 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ Available targets: | codepipeline\_s3\_bucket\_force\_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | `bool` | `false` | no | | command | The command that is passed to the container | `list(string)` | `null` | no | | container\_cpu | The vCPU setting to control cpu limits of container. (If FARGATE launch type is used below, this must be a supported vCPU size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `number` | `256` | no | +| container\_definition | Override the main container\_definition | `string` | `[]` | no | | container\_image | The default container image to use in container definition | `string` | `"cloudposse/default-backend"` | no | | container\_memory | The amount of RAM to allow container to use in MB. (If FARGATE launch type is used below, this must be a supported Memory size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `number` | `512` | no | | container\_memory\_reservation | The amount of RAM (Soft Limit) to allow container to use in MB. This value must be less than `container_memory` if set | `number` | `128` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 46adc82b..f77e5bcb 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -76,6 +76,7 @@ | codepipeline\_s3\_bucket\_force\_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | `bool` | `false` | no | | command | The command that is passed to the container | `list(string)` | `null` | no | | container\_cpu | The vCPU setting to control cpu limits of container. (If FARGATE launch type is used below, this must be a supported vCPU size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `number` | `256` | no | +| container\_definition | Override the main container\_definition | `string` | `[]` | no | | container\_image | The default container image to use in container definition | `string` | `"cloudposse/default-backend"` | no | | container\_memory | The amount of RAM to allow container to use in MB. (If FARGATE launch type is used below, this must be a supported Memory size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `number` | `512` | no | | container\_memory\_reservation | The amount of RAM (Soft Limit) to allow container to use in MB. This value must be less than `container_memory` if set | `number` | `128` | no | From 68ad857c82a00a7f08fbcb094de28df71a0abd2f Mon Sep 17 00:00:00 2001 From: nitro Date: Mon, 27 Jul 2020 16:31:22 -0400 Subject: [PATCH 5/7] Update variables.tf --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 1aa8fb75..8b688e22 100644 --- a/variables.tf +++ b/variables.tf @@ -881,5 +881,5 @@ variable "init_containers" { variable "container_definition" { type = string description = "Override the main container_definition" - default = [] + default = "" } From 624a4f0c5cb1b3e2966d4ff205e97a3bde487140 Mon Sep 17 00:00:00 2001 From: nitro Date: Mon, 27 Jul 2020 16:32:13 -0400 Subject: [PATCH 6/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33a9cb73..a171d14c 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ Available targets: | codepipeline\_s3\_bucket\_force\_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | `bool` | `false` | no | | command | The command that is passed to the container | `list(string)` | `null` | no | | container\_cpu | The vCPU setting to control cpu limits of container. (If FARGATE launch type is used below, this must be a supported vCPU size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `number` | `256` | no | -| container\_definition | Override the main container\_definition | `string` | `[]` | no | +| container\_definition | Override the main container\_definition | `string` | `""` | no | | container\_image | The default container image to use in container definition | `string` | `"cloudposse/default-backend"` | no | | container\_memory | The amount of RAM to allow container to use in MB. (If FARGATE launch type is used below, this must be a supported Memory size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `number` | `512` | no | | container\_memory\_reservation | The amount of RAM (Soft Limit) to allow container to use in MB. This value must be less than `container_memory` if set | `number` | `128` | no | From e17f635090e3065d0221416f4282117bb1dfc8a3 Mon Sep 17 00:00:00 2001 From: nitro Date: Mon, 27 Jul 2020 16:32:27 -0400 Subject: [PATCH 7/7] Update terraform.md --- docs/terraform.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/terraform.md b/docs/terraform.md index f77e5bcb..d4d3a1a6 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -76,7 +76,7 @@ | codepipeline\_s3\_bucket\_force\_destroy | A boolean that indicates all objects should be deleted from the CodePipeline artifact store S3 bucket so that the bucket can be destroyed without error | `bool` | `false` | no | | command | The command that is passed to the container | `list(string)` | `null` | no | | container\_cpu | The vCPU setting to control cpu limits of container. (If FARGATE launch type is used below, this must be a supported vCPU size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `number` | `256` | no | -| container\_definition | Override the main container\_definition | `string` | `[]` | no | +| container\_definition | Override the main container\_definition | `string` | `""` | no | | container\_image | The default container image to use in container definition | `string` | `"cloudposse/default-backend"` | no | | container\_memory | The amount of RAM to allow container to use in MB. (If FARGATE launch type is used below, this must be a supported Memory size from the table here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html) | `number` | `512` | no | | container\_memory\_reservation | The amount of RAM (Soft Limit) to allow container to use in MB. This value must be less than `container_memory` if set | `number` | `128` | no |