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
HI, I am trying to use this code in order to tag asg group, it is working when all the resources are already created. but when I am trying to run it from scratch I am getting this error
│ Error: Invalid for_each argument
│
│ on modules/eks/main.tf line 144, in resource "aws_autoscaling_group_tag" "example":
│ 144: for_each = toset(
│ 145: [for asg in flatten(
│ 146: [for resources in aws_eks_node_group.worker-nodes.resources : resources.autoscaling_groups]
│ 147: ) : asg.name]
│ 148: )
│ ├────────────────
│ │ aws_eks_node_group.worker-nodes.resources is a list of object, known only after apply
│
│ The "for_each" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target
│ argument to first apply only the resources that the for_each depends on.
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.
HI, I am trying to use this code in order to tag asg group, it is working when all the resources are already created. but when I am trying to run it from scratch I am getting this error
│ Error: Invalid for_each argument
│
│ on modules/eks/main.tf line 144, in resource "aws_autoscaling_group_tag" "example":
│ 144: for_each = toset(
│ 145: [for asg in flatten(
│ 146: [for resources in aws_eks_node_group.worker-nodes.resources : resources.autoscaling_groups]
│ 147: ) : asg.name]
│ 148: )
│ ├────────────────
│ │ aws_eks_node_group.worker-nodes.resources is a list of object, known only after apply
│
│ The "for_each" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target
│ argument to first apply only the resources that the for_each depends on.
The code block which I am using
resource "aws_autoscaling_group_tag" "example" {
for_each = toset(
[for asg in flatten(
[for resources in aws_eks_node_group.worker-nodes.resources : resources.autoscaling_groups]
) : asg.name]
)
autoscaling_group_name = each.value
tag {
key = "Name"
value = "Worker"
propagate_at_launch = true
}
depends_on = [
aws_eks_node_group.worker-nodes,
aws_eks_cluster.eks,
]
}
The text was updated successfully, but these errors were encountered: