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

fix: Do not attach policy if Karpenter node role is not created by module #2964

Conversation

dex4er
Copy link
Contributor

@dex4er dex4er commented Mar 10, 2024

Description

Karpenter module fails

│ Error: Invalid index
│ 
│   on .terraform/modules/eks.eks_karpenter/modules/karpenter/main.tf line 576, in resource "aws_iam_role_policy_attachment" "node":
│  576:   role       = aws_iam_role.node[0].name
│     ├────────────────
│     │ aws_iam_role.node is empty tuple
│ 
│ The given key does not identify an element in this collection value: the
│ collection has no elements.
╵

if node role is not created:

module "eks_karpenter" {
  source  = "terraform-aws-modules/eks/aws//modules/karpenter"
  version = "~> 20.0"

  cluster_name = module.eks.cluster_name

  create_iam_role          = true
  create_node_iam_role          = false
}

Motivation and Context

Bugfix

Breaking Changes

No, it's a minor fix

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@dex4er dex4er changed the title Do not attach policy if role is not created fix: do not attach policy if role is not created Mar 10, 2024
@dex4er dex4er force-pushed the fix/karpenter-create_node_iam_role-false branch from fa9533b to 379ea36 Compare March 10, 2024 21:59
@dex4er dex4er changed the title fix: do not attach policy if role is not created fix: Do not attach policy if role is not created Mar 10, 2024
@dex4er dex4er force-pushed the fix/karpenter-create_node_iam_role-false branch from 379ea36 to 6575c45 Compare March 10, 2024 22:00
Copy link
Member

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@bryantbiggs bryantbiggs changed the title fix: Do not attach policy if role is not created fix: Do not attach policy if Karpenter node role is not created by module Mar 10, 2024
@bryantbiggs bryantbiggs merged commit 3ad19d7 into terraform-aws-modules:master Mar 10, 2024
18 checks passed
antonbabenko pushed a commit that referenced this pull request Mar 10, 2024
## [20.8.1](v20.8.0...v20.8.1) (2024-03-10)

### Bug Fixes

* Do not attach policy if Karpenter node role is not created by module ([#2964](#2964)) ([3ad19d7](3ad19d7))
@antonbabenko
Copy link
Member

This PR is included in version 20.8.1 🎉

Copy link

I'm going to lock this pull request 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 related to this change, 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 Apr 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants