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

Override container definitions #60

Merged
merged 8 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
7 changes: 6 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = string
description = "Override the main container_definition"
default = ""
}