terraform-aws-eks-blueprints icon indicating copy to clipboard operation
terraform-aws-eks-blueprints copied to clipboard

IAM Role issue

Open skuriyadi opened this issue 3 years ago • 15 comments

Hi,

I am getting below error when using latest version of your module, please advise.

Error: Invalid for_each argument │ │ on .terraform/modules/eks-cluster.aws_eks/main.tf line 250, in resource "aws_iam_role_policy_attachment" "this": │ 250: for_each = local.create_iam_role ? toset(compact(distinct(concat([ │ 251: "${local.policy_arn_prefix}/AmazonEKSClusterPolicy", │ 252: "${local.policy_arn_prefix}/AmazonEKSVPCResourceController", │ 253: ], var.iam_role_additional_policies)))) : toset([]) │ ├──────────────── │ │ local.create_iam_role is true │ │ local.policy_arn_prefix is a string, known only after apply │ │ 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.

skuriyadi avatar May 02 '22 21:05 skuriyadi

Hi @skuriyadi this error is documented here. As documented there, this is an issue in Terraform Core.

If you remove the depends_on in your module definition like suggested this error should go away. On the flip side, you may have to do multiple passes over your terraform apply and destroy.

askulkarni2 avatar May 03 '22 01:05 askulkarni2

@askulkarni2 As this code is coming from the module, what are you usually doing to circumvent it here? As removing the dependency seems not really a solution.

grid-dev avatar May 03 '22 11:05 grid-dev

@askulkarni2 , I will continue using the older version for now, I guess the solution which is provided will beat the purpose of creating a complete automated infra setup. Thank you, Shiva

skuriyadi avatar May 03 '22 20:05 skuriyadi

@skuriyadi can you share you current configuration?

bryantbiggs avatar May 03 '22 21:05 bryantbiggs

Hi @bryantbiggs I am using your module to create a EKS cluster with managed nodegroup and your addon module. Sorry, I wont be able to share the configuration.

Thank you!

skuriyadi avatar May 03 '22 21:05 skuriyadi

A bit unsatisfying, but thanks for your responses

grid-dev avatar May 04 '22 07:05 grid-dev

there has been some recent movement on this issue so hopefully improvements in Terraform core are coming soon https://github.com/hashicorp/terraform/issues/30937

bryantbiggs avatar May 04 '22 11:05 bryantbiggs

Hi Team,

Did any improvements come from Terraform on this issuue

skuriyadi avatar Jun 01 '22 19:06 skuriyadi

HI @bryantbiggs , Please let me know if here any update on this?

skuriyadi avatar Jun 17 '22 13:06 skuriyadi

Hi @skuriyadi - you can track the progress in the linked issue above https://github.com/hashicorp/terraform/issues/30937

bryantbiggs avatar Jun 17 '22 17:06 bryantbiggs

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Jul 19 '22 00:07 github-actions[bot]

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Aug 19 '22 00:08 github-actions[bot]

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Sep 19 '22 00:09 github-actions[bot]

I also had this issue. It turned up when I added a depends_on argument on the module resource using this module.

I worked out that if remove the depends_on and use an implicit dependency by using the outputs of the upstream resource in the tags of this module.

It worked for me. Bit of a hack, but I moved forward at least.

domeales-pro avatar Sep 20 '22 10:09 domeales-pro

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Oct 21 '22 00:10 github-actions[bot]

Please see https://github.com/aws-ia/terraform-aws-eks-blueprints/pull/1319

This has been resolved in v19 of the terraform-aws-eks module

bryantbiggs avatar Jan 21 '23 15:01 bryantbiggs