-
-
Notifications
You must be signed in to change notification settings - Fork 555
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
port_mappings are always empty #151
Comments
Does anyone know if this has any solution? Or do I need to rewrite it and use classical terraform resources instead of a module? I see others had similar issues, but I am not sure if anyone found a fix, |
if you can provide a reproduction, we can take a look and help figure out whats going on. However, the code provided above is not deployable |
Ok. Here is a simplified version taken from here #147 (comment)
The output of nginx_container_definition:
The actual JSON in AWS ECS Tasks:
As you see, portMappings and mountPoints are empty. |
ah this is a duplicate of #147 - what is the motivation for having the container definition defined on its own, outside the service? |
Because I have many containers running on the same service and also custom dynamic env and secrets, which are not supported inside the service (because of for_each). |
What do you mean "not supported"? |
Yes, that works, but I need to merge static and dynamic env and secrets from a map. Something like this:
This works with the container-definition module, but it does not work under services module. I get
Maybe I am missing something or there is another solution. I cannot have hardcoded env vars and secrets because I have hundreds of services and containers, each with other settings. |
And what if you do this instead: locals {
additional_environment = {
"APP_ENV" = var.App_Env,
"NODE_ENV" = var.Node_Env,
"CONFIG_REDIS__HOST" = lookup(aws_elasticache_cluster.elastic_cache_cluster["cluster1-redis"].cache_nodes[0], "address", null)
"CONFIG_POSTGRES__USER" = var.aurora_postgresql_v2_master_username,
"CONFIG_POSTGRES__PASSWORD" = var.aurora_postgresql_v2_master_pwd,
"CONFIG_POSTGRES__HOST" = lookup(module.aurora_postgresql_v2, "cluster_endpoint", null),
}
}
module "ecs_container_definition" {
source = "terraform-aws-modules/ecs/aws//modules/container-definition"
version = "~> 5.7.3"
for_each = var.ecs_services
name = each.value["ecs_task_container_name"]
cpu = each.value["ecs_task_cpu"]
memory = each.value["ecs_task_memory"]
environment = concat([
for key, value in local.additional_environment : {
name = key
value = value
}
],
local.environment_variables
) |
yea, that did the trick. Thanks! |
Here is my code for whoever has the same issue:
|
Actually it seems it works only when the resources exist already. However, if I try to plan it from scratch, I still have the same issue:
|
this also fails. I also added depends_on for the module. |
this doesn't work either: My code:
|
We also have an error regarding this line when creating an ECS cluster with a service and task definition. We have multiple containers inside a task definition. The error is the same as ours when running the terraform apply command:
Please let us know what the solution would be to fix it. @bryantbiggs The workaround that we tried is to first create the ECS cluster and service, and comment out the task definition. Then, uncomment the task definition and run |
the actual issue is #147 which we do not have a fix at this time |
Description
When I try to create a new container definition, the port_mapping are always empty.
Versions
Module version [Required]:
5.7.3
Terraform version:
Terraform v1.6.6
on darwin_arm64
Provider version(s):
Reproduction Code [Required]
Steps to reproduce the behavior:
output "ecs_container_definitions" {
description = "Container definitions for each ECS service"
value = { for svc_name, def in module.ecs_container_definition : svc_name => def.container_definition }
}
Expected behavior
In AWS task definition:
Actual behavior
In AWS task definition:
Terminal Output Screenshot(s)
Additional context
Similar issue as this one:
#122
The text was updated successfully, but these errors were encountered: