Skip to content

Conversation

bryantbiggs
Copy link
Member

Description

  • Correct logic to try to use module created IAM role before falling back to user provided IAM role
  • Add missing tags to identity providers variable definition
  • Revert changs to OIDC dual stack issuer url
  • Revert temporary changes to example sources to point back to a published version

Motivation and Context

Breaking Changes

  • No

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

…ng back to user provided IAM role

@bryantbiggs bryantbiggs requested a review from antonbabenko July 24, 2025 12:41
client_id_list = distinct(compact(concat(["sts.amazonaws.com"], var.openid_connect_audiences)))
thumbprint_list = concat(local.oidc_root_ca_thumbprint, var.custom_oidc_thumbprints)
url = local.dualstack_oidc_issuer_url
url = aws_eks_cluster.this[0].identity[0].oidc[0].issuer

Choose a reason for hiding this comment

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

👍

enabled = compute_config.value.enabled
node_pools = compute_config.value.node_pools
node_role_arn = compute_config.value.node_pools != null ? try(compute_config.value.node_role_arn, aws_iam_role.eks_auto[0].arn, null) : null
node_role_arn = compute_config.value.node_pools != null ? try(aws_iam_role.eks_auto[0].arn, compute_config.value.node_role_arn) : null
Copy link

@matheuscscp matheuscscp Jul 24, 2025

Choose a reason for hiding this comment

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

If compute_config.value.node_role_arn is specified (module input), then is it guaranteed that aws_iam_role.eks_auto[0].arn will be null?

Copy link
Member Author

Choose a reason for hiding this comment

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

it will not be null - this would throw an error if create_node_iam_role = false which is what try() catches and moves down the chain to compute_config.value.node_role_arn

Choose a reason for hiding this comment

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

From

resource "aws_iam_role" "eks_auto" {
  count = local.create_node_iam_role ? 1 : 0

and

locals {
  create_node_iam_role = local.create && var.create_node_iam_role && local.auto_mode_enabled

and

  auto_mode_enabled = try(var.compute_config.enabled, false)

I think this change is still not right. If I understand correctly, the compute_config.value.node_role_arn module input will never be used. For this to be correct you need to modify local.create_node_iam_role to be true only if compute_config.value.node_role_arn is not specified.

Copy link

@matheuscscp matheuscscp Jul 24, 2025

Choose a reason for hiding this comment

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

Make it like this:

locals {
  create_node_iam_role = local.create && var.create_node_iam_role && local.auto_mode_enabled && 
  var.compute_config.node_role_arn != null && var.compute_config.node_role_arn != ""

Copy link
Member Author

Choose a reason for hiding this comment

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

You can think its not right, but I can tell you it is 😬

the previous form for the initial v21 release did not work because try() only falls down the chain when it encounters errors. Plucking a value off compute_config.value.node_role_arn does not throw an error because of the new variable optional attributes; it simply returns a null and never moves down the chain

Choose a reason for hiding this comment

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

So if I set var.compute_config.node_role_arn to a value then I also have to set var.create_node_iam_role to false, is that the intended use?

Choose a reason for hiding this comment

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

Makes sense!

Choose a reason for hiding this comment

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

You can think its not right, but I can tell you it is 😬

Wow, easy there

Copy link
Member Author

Choose a reason for hiding this comment

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

#3429 and this one are very bad regressions, we need fixes ASAP.

right back at ya 😉

Choose a reason for hiding this comment

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

Thanks for the fixes! 🙏

@matheuscscp
Copy link

LGTM! 🚀

@bryantbiggs bryantbiggs merged commit 97d4ebb into terraform-aws-modules:master Jul 24, 2025
20 checks passed
@bryantbiggs bryantbiggs deleted the fix/auto-mode branch July 24, 2025 14:31
antonbabenko pushed a commit that referenced this pull request Jul 24, 2025
## [21.0.1](v21.0.0...v21.0.1) (2025-07-24)

### Bug Fixes

* Correct logic to try to use module created IAM role before falli… ([#3433](#3433)) ([97d4ebb](97d4ebb))
@antonbabenko
Copy link
Member

This PR is included in version 21.0.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 Aug 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants