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

Invalid for_each argument on aws_default_tags #2281

Closed
boopathykpm opened this issue Oct 26, 2022 · 4 comments · Fixed by #2250
Closed

Invalid for_each argument on aws_default_tags #2281

boopathykpm opened this issue Oct 26, 2022 · 4 comments · Fixed by #2250

Comments

@boopathykpm
Copy link

Getting the error while running the EKS cluster creation

│ Error: Invalid for_each argument

│ on .terraform/modules/eks/main.tf line 71, in resource "aws_ec2_tag" "cluster_primary_security_group":
│ 71: for_each = { for k, v in merge(var.tags, var.cluster_tags, data.aws_default_tags.current.tags) :
│ 72: k => v if local.create && k != "Name" && var.create_cluster_primary_security_group_tags
│ 73: }
│ ├────────────────
│ │ data.aws_default_tags.current.tags is a map of string, known only after apply
│ │ local.create is true
│ │ var.cluster_tags is map of string with 3 elements
│ │ var.create_cluster_primary_security_group_tags is true
│ │ var.tags is map of string with 3 elements

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.

This is happening because of data "aws_default_tags" "current" {}.

There is no proper documentation to fix this error, any suggestions ?

@mmclane
Copy link

mmclane commented Nov 2, 2022

I am getting the same issue. I have tried v18.30.0, v18.30.1, and v18.30.2. Going back to v18.29.1 fixes the issue for me.

@bryantbiggs bryantbiggs added the bug label Nov 7, 2022
@bryantbiggs
Copy link
Member

the use of default tags added in v18.30 was unfortunately found to have introduced some issues and we will be correcting this in v19 since its removal is a breaking change. Apologies for any headache experienced by this

@antonbabenko
Copy link
Member

This issue has been resolved in version 19.0.0 🎉

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants