You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
│ Error: Invalid for_each argument
│
│ on .terraform/modules/ecs/modules/service/main.tf line 531, in module "container_definition":
│ 531: for_each = { for k, v in var.container_definitions : k => v if local.create_task_definition && try(v.create, true) }
│ ├────────────────
│ │ local.create_task_definition is true
│ │ var.container_definitions will be known only after apply
│
│ The "for_each" map includes keys derived from resource attributes that cannot be determined until
│ apply, and so Terraform cannot determine the full set of keys that will identify the instances of
│ this resource.
│
│ When working with unknown values in for_each, it's better to define the map keys statically in
│ your configuration and place apply-time results only in the map values.
│
│ Alternatively, you could use the -target planning option to first apply only the resources that
│ the for_each value depends on, and then apply a second time to fully converge.
Terminal Output Screenshot(s)
Additional context
By looking at main.tf I see that some variables definitions uses lookup and some try call. eg: load_balancer is also not known at plan time, but because it is defined as:
This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days
Description
I want to provision a new ecs cluster with services and secrets, but it's impossible to do this in a single apply.
Versions
Reproduction Code [Required]
Steps to reproduce the behavior:
Expected behavior
An ecs service is created with secrets.
Actual behavior
Terminal Output Screenshot(s)
Additional context
By looking at
main.tf
I see that some variables definitions useslookup
and sometry
call. eg:load_balancer
is also not known at plan time, but because it is defined as:The resource can be created. For other derived keys with
try
it is impossible. What's the recommend workaournd in this case?The text was updated successfully, but these errors were encountered: