Skip to content

Commit

Permalink
Override container definitions (#60)
Browse files Browse the repository at this point in the history
* var.container_definition to override definition

* Override the container_definition

* Change var.container_definition to string

* Updated README.md

* Update variables.tf

* Update README.md

* Update terraform.md

Co-authored-by: actions-bot <[email protected]>
  • Loading branch information
nitrocode and actions-bot authored Jul 28, 2020
1 parent dd868c7 commit 376db54
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,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 |
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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 |
Expand Down
7 changes: 6 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,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" {
Expand All @@ -132,7 +137,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)
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,12 @@ variable "init_containers" {
default = []
}

variable "container_definition" {
type = string
description = "Override the main container_definition"
default = ""
}

variable "cloudwatch_log_group_enabled" {
type = bool
description = "A boolean to disable cloudwatch log group creation"
Expand Down

0 comments on commit 376db54

Please sign in to comment.