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

Replace for_each with count for producing ECS custom policies. #30

Merged
merged 1 commit into from
Jul 30, 2022

Conversation

nbeloglazov
Copy link
Contributor

Current approach using for_each doesn't work if a policy contains reference to resource. In this case it throws the following error:

Error: Invalid for_each argument
│
│   on .terraform/modules/td/main.tf line 17, in resource "aws_iam_policy" "ecs_task_execution_role_custom_policy":
│   17:   for_each    = { for s in var.ecs_task_execution_role_custom_policies : index(var.ecs_task_execution_role_custom_policies, s) => s }
│     ├────────────────
│     │ var.ecs_task_execution_role_custom_policies is list of string with 1 element
│
│ 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.

Looks like for_each in this case isn't really necessary as it's used only to convert a list to index => value map. And that's what count imitate as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging this pull request may close these issues.

2 participants