terraform-aws-ecs
terraform-aws-ecs copied to clipboard
Dynamically add container(s) to container_definitions
Is your request related to a new offering from AWS?
Is this functionality available in the AWS provider for Terraform? See CHANGELOG.md, too.
- No π: please wait to file a request until the functionality is avaialble in the AWS provider
- Yes β : please list the AWS provider version which introduced this functionality
Is your request related to a problem? Please describe.
Add container based on condition
Describe the solution you'd like.
container_definitions = {
app = {
image = "..."
}
}
additional_containers = flatten(var.create_sidecar ? [
{
image = "..."
}
]: [])
Describe alternatives you've considered.
Additional context
You can achieve this using a locals or dynamic block
container_definitions = { nginx = { image = "nginx:latest" port_mappings = [ { protocol = "tcp", containerPort = 80 } ] environment = [ { name = "ENV", value = var.environment } ] }, aws-otel-collector = { image = "public.ecr.aws/aws-observability/aws-otel-collector:v0.40.2", port_mappings = [ { "containerPort" : 2000, "protocol" : "udp" } ] }, appconfig-agent = { image = "public.ecr.aws/aws-appconfig/aws-appconfig-agent:2.x", port_mappings = [ { "containerPort" : 2772, "protocol" : "tcp" } ] } }
container_definitions = local.container_definitions
This issue has been resolved in version 6.0.0 :tada:
I'm going to lock this issue because it has been closed for 30 days β³. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.