mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-01-17 17:22:13 +01:00
feat: Apply distinct() on role arns to ensure no duplicated roles in aws-auth configmap (#2097)
This commit is contained in:
38
main.tf
38
main.tf
@@ -356,21 +356,33 @@ resource "aws_eks_identity_provider_config" "this" {
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
node_iam_role_arns_non_windows = compact(concat(
|
node_iam_role_arns_non_windows = distinct(
|
||||||
[for group in module.eks_managed_node_group : group.iam_role_arn],
|
compact(
|
||||||
[for group in module.self_managed_node_group : group.iam_role_arn if group.platform != "windows"],
|
concat(
|
||||||
var.aws_auth_node_iam_role_arns_non_windows,
|
[for group in module.eks_managed_node_group : group.iam_role_arn],
|
||||||
))
|
[for group in module.self_managed_node_group : group.iam_role_arn if group.platform != "windows"],
|
||||||
|
var.aws_auth_node_iam_role_arns_non_windows,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
node_iam_role_arns_windows = compact(concat(
|
node_iam_role_arns_windows = distinct(
|
||||||
[for group in module.self_managed_node_group : group.iam_role_arn if group.platform == "windows"],
|
compact(
|
||||||
var.aws_auth_node_iam_role_arns_windows,
|
concat(
|
||||||
))
|
[for group in module.self_managed_node_group : group.iam_role_arn if group.platform == "windows"],
|
||||||
|
var.aws_auth_node_iam_role_arns_windows,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
fargate_profile_pod_execution_role_arns = compact(concat(
|
fargate_profile_pod_execution_role_arns = distinct(
|
||||||
[for group in module.fargate_profile : group.fargate_profile_pod_execution_role_arn],
|
compact(
|
||||||
var.aws_auth_fargate_profile_pod_execution_role_arns,
|
concat(
|
||||||
))
|
[for group in module.fargate_profile : group.fargate_profile_pod_execution_role_arn],
|
||||||
|
var.aws_auth_fargate_profile_pod_execution_role_arns,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
aws_auth_configmap_data = {
|
aws_auth_configmap_data = {
|
||||||
mapRoles = yamlencode(concat(
|
mapRoles = yamlencode(concat(
|
||||||
|
|||||||
@@ -185,10 +185,10 @@ output "aws_auth_configmap_yaml" {
|
|||||||
description = "[DEPRECATED - use `var.manage_aws_auth_configmap`] Formatted yaml output for base aws-auth configmap containing roles used in cluster node groups/fargate profiles"
|
description = "[DEPRECATED - use `var.manage_aws_auth_configmap`] Formatted yaml output for base aws-auth configmap containing roles used in cluster node groups/fargate profiles"
|
||||||
value = templatefile("${path.module}/templates/aws_auth_cm.tpl",
|
value = templatefile("${path.module}/templates/aws_auth_cm.tpl",
|
||||||
{
|
{
|
||||||
eks_managed_role_arns = compact([for group in module.eks_managed_node_group : group.iam_role_arn])
|
eks_managed_role_arns = distinct(compact([for group in module.eks_managed_node_group : group.iam_role_arn]))
|
||||||
self_managed_role_arns = compact([for group in module.self_managed_node_group : group.iam_role_arn if group.platform != "windows"])
|
self_managed_role_arns = distinct(compact([for group in module.self_managed_node_group : group.iam_role_arn if group.platform != "windows"]))
|
||||||
win32_self_managed_role_arns = compact([for group in module.self_managed_node_group : group.iam_role_arn if group.platform == "windows"])
|
win32_self_managed_role_arns = distinct(compact([for group in module.self_managed_node_group : group.iam_role_arn if group.platform == "windows"]))
|
||||||
fargate_profile_pod_execution_role_arns = compact([for group in module.fargate_profile : group.fargate_profile_pod_execution_role_arn])
|
fargate_profile_pod_execution_role_arns = distinct(compact([for group in module.fargate_profile : group.fargate_profile_pod_execution_role_arn]))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user