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
- Support for providing maps of node groups/Fargate profiles to the cluster module definition or use separate node group/Fargate profile sub-modules
19
19
- Provisions to provide node group/Fargate profile "default" settings - useful for when creating multiple node groups/Fargate profiles where you want to set a common set of configurations once, and then individual control only select features
20
20
21
+
### ℹ️ `Error: Invalid for_each argument ...`
22
+
23
+
Users may encounter an error such as `Error: Invalid for_each argument - 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 ...`
24
+
25
+
This error is due to an upstream issue with [Terraform core](https://github.com/hashicorp/terraform/issues/4149). There are two potential options you can take to help mitigate this issue:
26
+
27
+
1. Create the dependent resources before the cluster => `terraform apply --target <your policy or your security group>` and then `terraform apply` for the cluster (or other similar means to just ensure the referenced resources exist before creating the cluster)
28
+
- Note: this is the route users will have to take for adding additonal security groups to nodes since there isn't a separate "security group attachment" resource
29
+
2. For addtional IAM policies, users can attach the policies outside of the cluster definition as demonstrated below
# you could also do the following or any comibination:
35
+
# for_each = merge(
36
+
# module.eks.eks_managed_node_groups,
37
+
# module.eks.self_managed_node_group,
38
+
# module.eks.fargate_profile,
39
+
# )
40
+
41
+
# This policy does not have to exist at the time of cluster creation. Terraform can
42
+
# deduce the proper order of its creation to avoid errors during creation
43
+
policy_arn = aws_iam_policy.node_additional.arn
44
+
role = each.value.iam_role_name
45
+
}
46
+
```
47
+
48
+
The tl;dr for this issue is that the Terraform resource passed into the modules map definition *must* be known before you can apply the EKS module. The variables this potentially affects are:
49
+
50
+
-`cluster_security_group_additional_rules` (i.e. - referencing an external security group resource in a rule)
51
+
-`node_security_group_additional_rules` (i.e. - referencing an external security group resource in a rule)
52
+
-`iam_role_additional_policies` (i.e. - referencing an external policy resource)
Copy file name to clipboardExpand all lines: examples/eks_managed_node_group/main.tf
+1-2
Original file line number
Diff line number
Diff line change
@@ -270,7 +270,6 @@ module "eks" {
270
270
tags=local.tags
271
271
}
272
272
273
-
274
273
# References to resources that do not exist yet when creating a cluster will cause a plan failure due to https://github.com/hashicorp/terraform/issues/4149
275
274
# There are two options users can take
276
275
# 1. Create the dependent resources before the cluster => `terraform apply --target <your policy or your security group> and then `terraform apply`
| <aname="input_post_bootstrap_user_data"></a> [post\_bootstrap\_user\_data](#input\_post\_bootstrap\_user\_data)| User data that is appended to the user data script after of the EKS bootstrap script. Not used when `platform` = `bottlerocket`|`string`|`""`| no |
140
140
| <aname="input_pre_bootstrap_user_data"></a> [pre\_bootstrap\_user\_data](#input\_pre\_bootstrap\_user\_data)| User data that is injected into the user data script ahead of the EKS bootstrap script. Not used when `platform` = `bottlerocket`|`string`|`""`| no |
141
141
| <aname="input_ram_disk_id"></a> [ram\_disk\_id](#input\_ram\_disk\_id)| The ID of the ram disk |`string`|`null`| no |
142
-
| <aname="input_remote_access"></a> [remote\_access](#input\_remote\_access)| Configuration block with remote access settings |`map(string)`|`{}`| no |
142
+
| <aname="input_remote_access"></a> [remote\_access](#input\_remote\_access)| Configuration block with remote access settings |`any`|`{}`| no |
143
143
| <aname="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description)| Description for the security group created |`string`|`"EKS managed node group security group"`| no |
144
144
| <aname="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name)| Name to use on security group created |`string`|`null`| no |
145
145
| <aname="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules)| List of security group rules to add to the security group created |`any`|`{}`| no |
0 commit comments