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
I am trying to create an EKS platform for launching our application code. Currently we have nothing up and running in AWS that is managed by Terraform. Ideally we want to spin up and tear down entire infrastructures using a single set of terraform config. Currently I cannot get the EKS module to build a successful plan.
When trying to plan or apply, this module will fail due to an internal dependency issue with the for_each statement in the main.tf file on line 207 as well as the sub-module eks-managed-node-group\main.tf line 427. (See the error output below)
╷
│ Error: Invalid for_each argument
│
│ on <PATH TO EKS MODULE>\main.tf line 207, in resource "aws_iam_role_policy_attachment" "this":
│ 207: for_each = var.create && var.create_iam_role ? toset(compact(distinct(concat([
│ 208: "${local.policy_arn_prefix}/AmazonEKSClusterPolicy",
│ 209: "${local.policy_arn_prefix}/AmazonEKSVPCResourceController",
│ 210: ], var.iam_role_additional_policies)))) : toset([])
│ ├────────────────
│ │ local.policy_arn_prefix is a string, known only after apply
│ │ var.create is true
│ │ var.create_iam_role is true
│ │ var.iam_role_additional_policies is empty list of string
│
│ 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.
╵
╷
│ Error: Invalid for_each argument
│
│ on <PATH TO EKS MODULE>\modules\eks-managed-node-group\main.tf line 427, in resource "aws_iam_role_policy_attachment" "this":
│ 427: for_each = var.create && var.create_iam_role ? toset(compact(distinct(concat([
│ 428: "${local.policy_arn_prefix}/AmazonEKSWorkerNodePolicy",
│ 429: "${local.policy_arn_prefix}/AmazonEC2ContainerRegistryReadOnly",
│ 430: "${local.policy_arn_prefix}/AmazonEKS_CNI_Policy",
│ 431: ], var.iam_role_additional_policies)))) : toset([])
│ ├────────────────
│ │ local.policy_arn_prefix is a string, known only after apply
│ │ var.create is true
│ │ var.create_iam_role is true
│ │ var.iam_role_additional_policies is empty list of string
│
│ 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.
╵
Note - you shouldn't need your depends_on block, you already have those resources specified in the cluster definition and they will create the appropriate dependencies. You can double check by comparing graph outputs
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.
Description
I am trying to create an EKS platform for launching our application code. Currently we have nothing up and running in AWS that is managed by Terraform. Ideally we want to spin up and tear down entire infrastructures using a single set of terraform config. Currently I cannot get the EKS module to build a successful plan.
When trying to plan or apply, this module will fail due to an internal dependency issue with the for_each statement in the
main.tf
file on line 207 as well as the sub-moduleeks-managed-node-group\main.tf
line 427. (See the error output below)Versions
Reproduction
Steps to reproduce the behavior:
Currently there are no AWS resources created in the region
terraform init
terraform plan
Expected behavior
No internal files should have dependency issues
Actual behavior
The IAM role policy attachment uses
local.policy_arn_prefix
which usesdata.aws_partition.current.partition
which is known only after applyTerminal Output
(in the description)
The text was updated successfully, but these errors were encountered: