Skip to content

Commit 97d4ebb

Browse files
authored
fix: Correct logic to try to use module created IAM role before falli… (#3433)
1 parent b7eabbd commit 97d4ebb

File tree

8 files changed

+17
-20
lines changed

8 files changed

+17
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
430430
| <a name="input_iam_role_permissions_boundary"></a> [iam\_role\_permissions\_boundary](#input\_iam\_role\_permissions\_boundary) | ARN of the policy that is used to set the permissions boundary for the IAM role | `string` | `null` | no |
431431
| <a name="input_iam_role_tags"></a> [iam\_role\_tags](#input\_iam\_role\_tags) | A map of additional tags to add to the IAM role created | `map(string)` | `{}` | no |
432432
| <a name="input_iam_role_use_name_prefix"></a> [iam\_role\_use\_name\_prefix](#input\_iam\_role\_use\_name\_prefix) | Determines whether the IAM role name (`iam_role_name`) is used as a prefix | `bool` | `true` | no |
433-
| <a name="input_identity_providers"></a> [identity\_providers](#input\_identity\_providers) | Map of cluster identity provider configurations to enable for the cluster. Note - this is different/separate from IRSA | <pre>map(object({<br/> client_id = string<br/> groups_claim = optional(string)<br/> groups_prefix = optional(string)<br/> identity_provider_config_name = optional(string) # will fall back to map key<br/> issuer_url = string<br/> required_claims = optional(map(string))<br/> username_claim = optional(string)<br/> username_prefix = optional(string)<br/> }))</pre> | `null` | no |
433+
| <a name="input_identity_providers"></a> [identity\_providers](#input\_identity\_providers) | Map of cluster identity provider configurations to enable for the cluster. Note - this is different/separate from IRSA | <pre>map(object({<br/> client_id = string<br/> groups_claim = optional(string)<br/> groups_prefix = optional(string)<br/> identity_provider_config_name = optional(string) # will fall back to map key<br/> issuer_url = string<br/> required_claims = optional(map(string))<br/> username_claim = optional(string)<br/> username_prefix = optional(string)<br/> tags = optional(map(string), {})<br/> }))</pre> | `null` | no |
434434
| <a name="input_include_oidc_root_ca_thumbprint"></a> [include\_oidc\_root\_ca\_thumbprint](#input\_include\_oidc\_root\_ca\_thumbprint) | Determines whether to include the root CA thumbprint in the OpenID Connect (OIDC) identity provider's server certificate(s) | `bool` | `true` | no |
435435
| <a name="input_ip_family"></a> [ip\_family](#input\_ip\_family) | The IP family used to assign Kubernetes pod and service addresses. Valid values are `ipv4` (default) and `ipv6`. You can only specify an IP family when you create a cluster, changing this value will force a new cluster to be created | `string` | `"ipv4"` | no |
436436
| <a name="input_kms_key_administrators"></a> [kms\_key\_administrators](#input\_kms\_key\_administrators) | A list of IAM ARNs for [key administrators](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html#key-policy-default-allow-administrators). If no value is provided, the current caller identity is used to ensure at least one key admin is available | `list(string)` | `[]` | no |

examples/eks-managed-node-group/eks-al2023.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module "eks_al2023" {
2-
# source = "terraform-aws-modules/eks/aws"
3-
# version = "~> 20.0"
4-
source = "../.."
2+
source = "terraform-aws-modules/eks/aws"
3+
version = "~> 21.0"
54

65
name = "${local.name}-al2023"
76
kubernetes_version = "1.33"

examples/eks-managed-node-group/eks-bottlerocket.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module "eks_bottlerocket" {
2-
# source = "terraform-aws-modules/eks/aws"
3-
# version = "~> 20.0"
4-
source = "../.."
2+
source = "terraform-aws-modules/eks/aws"
3+
version = "~> 21.0"
54

65
name = "${local.name}-bottlerocket"
76
kubernetes_version = "1.33"

examples/self-managed-node-group/eks-al2023.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module "eks_al2023" {
2-
# source = "terraform-aws-modules/eks/aws"
3-
# version = "~> 20.0"
4-
source = "../.."
2+
source = "terraform-aws-modules/eks/aws"
3+
version = "~> 21.0"
54

65
name = "${local.name}-al2023"
76
kubernetes_version = "1.33"

examples/self-managed-node-group/eks-bottlerocket.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module "eks_bottlerocket" {
2-
# source = "terraform-aws-modules/eks/aws"
3-
# version = "~> 20.0"
4-
source = "../.."
2+
source = "terraform-aws-modules/eks/aws"
3+
version = "~> 21.0"
54

65
name = "${local.name}-bottlerocket"
76
kubernetes_version = "1.33"

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ resource "aws_eks_cluster" "this" {
6262
content {
6363
enabled = compute_config.value.enabled
6464
node_pools = compute_config.value.node_pools
65-
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
65+
node_role_arn = compute_config.value.node_pools != null ? try(aws_iam_role.eks_auto[0].arn, compute_config.value.node_role_arn) : null
6666
}
6767
}
6868

@@ -444,7 +444,7 @@ data "tls_certificate" "this" {
444444
# Not available on outposts
445445
count = local.create_oidc_provider && var.include_oidc_root_ca_thumbprint ? 1 : 0
446446

447-
url = local.dualstack_oidc_issuer_url
447+
url = aws_eks_cluster.this[0].identity[0].oidc[0].issuer
448448
}
449449

450450
resource "aws_iam_openid_connect_provider" "oidc_provider" {
@@ -453,7 +453,7 @@ resource "aws_iam_openid_connect_provider" "oidc_provider" {
453453

454454
client_id_list = distinct(compact(concat(["sts.amazonaws.com"], var.openid_connect_audiences)))
455455
thumbprint_list = concat(local.oidc_root_ca_thumbprint, var.custom_oidc_thumbprints)
456-
url = local.dualstack_oidc_issuer_url
456+
url = aws_eks_cluster.this[0].identity[0].oidc[0].issuer
457457

458458
tags = merge(
459459
{ Name = "${var.name}-eks-irsa" },
@@ -856,7 +856,7 @@ resource "aws_eks_identity_provider_config" "this" {
856856
client_id = each.value.client_id
857857
groups_claim = each.value.groups_claim
858858
groups_prefix = each.value.groups_prefix
859-
identity_provider_config_name = try(each.value.identity_provider_config_name, each.key)
859+
identity_provider_config_name = coalesce(each.value.identity_provider_config_name, each.key)
860860
issuer_url = each.value.issuer_url
861861
required_claims = each.value.required_claims
862862
username_claim = each.value.username_claim

outputs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
locals {
2-
# https://github.com/aws/containers-roadmap/issues/2038#issuecomment-2278450601
3-
dualstack_oidc_issuer_url = try(replace(replace(aws_eks_cluster.this[0].identity[0].oidc[0].issuer, "https://oidc.eks.", "https://oidc-eks."), ".amazonaws.com/", ".api.aws/"), null)
2+
43
}
54

65
################################################################################
@@ -59,7 +58,8 @@ output "cluster_oidc_issuer_url" {
5958

6059
output "cluster_dualstack_oidc_issuer_url" {
6160
description = "Dual-stack compatible URL on the EKS cluster for the OpenID Connect identity provider"
62-
value = local.dualstack_oidc_issuer_url
61+
# https://github.com/aws/containers-roadmap/issues/2038#issuecomment-2278450601
62+
value = try(replace(replace(aws_eks_cluster.this[0].identity[0].oidc[0].issuer, "https://oidc.eks.", "https://oidc-eks."), ".amazonaws.com/", ".api.aws/"), null)
6363
}
6464

6565
output "cluster_version" {

variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ variable "identity_providers" {
660660
required_claims = optional(map(string))
661661
username_claim = optional(string)
662662
username_prefix = optional(string)
663+
tags = optional(map(string), {})
663664
}))
664665
default = null
665666
}

0 commit comments

Comments
 (0)