Skip to content

Commit c3882d9

Browse files
authored
feat: Allowing override for irsa role name (#764)
1 parent a55402f commit c3882d9

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

modules/irsa/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ No modules.
4949

5050
| Name | Description | Type | Default | Required |
5151
|------|-------------|------|---------|:--------:|
52-
| <a name="input_addon_context"></a> [addon\_context](#input\_addon\_context) | Input configuration for the addon | <pre>object({<br> aws_caller_identity_account_id = string<br> aws_caller_identity_arn = string<br> aws_eks_cluster_endpoint = string<br> aws_partition_id = string<br> aws_region_name = string<br> eks_cluster_id = string<br> eks_oidc_issuer_url = string<br> eks_oidc_provider_arn = string<br> tags = map(string)<br> irsa_iam_role_path = optional(string)<br> irsa_iam_permissions_boundary = optional(string)<br> })</pre> | n/a | yes |
52+
| <a name="input_addon_context"></a> [addon\_context](#input\_addon\_context) | Input configuration for the addon | <pre>object({<br> aws_caller_identity_account_id = string<br> aws_caller_identity_arn = string<br> aws_eks_cluster_endpoint = string<br> aws_partition_id = string<br> aws_region_name = string<br> eks_cluster_id = string<br> eks_oidc_issuer_url = string<br> eks_oidc_provider_arn = string<br> tags = map(string)<br> irsa_iam_role_name = optional(string)<br> irsa_iam_role_path = optional(string)<br> irsa_iam_permissions_boundary = optional(string)<br> })</pre> | n/a | yes |
5353
| <a name="input_create_kubernetes_namespace"></a> [create\_kubernetes\_namespace](#input\_create\_kubernetes\_namespace) | Should the module create the namespace | `bool` | `true` | no |
5454
| <a name="input_create_kubernetes_service_account"></a> [create\_kubernetes\_service\_account](#input\_create\_kubernetes\_service\_account) | Should the module create the Service Account | `bool` | `true` | no |
5555
| <a name="input_irsa_iam_policies"></a> [irsa\_iam\_policies](#input\_irsa\_iam\_policies) | IAM Policies for IRSA IAM role | `list(string)` | `[]` | no |

modules/irsa/main.tf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resource "kubernetes_service_account_v1" "irsa" {
2020
resource "aws_iam_role" "irsa" {
2121
count = var.irsa_iam_policies != null ? 1 : 0
2222

23-
name = format("%s-%s-%s", var.addon_context.eks_cluster_id, trim(var.kubernetes_service_account, "-*"), "irsa")
23+
name = try(var.addon_context.irsa_iam_role_name, format("%s-%s-%s", var.addon_context.eks_cluster_id, trim(var.kubernetes_service_account, "-*"), "irsa"))
2424
description = "AWS IAM Role for the Kubernetes service account ${var.kubernetes_service_account}."
2525
assume_role_policy = jsonencode({
2626
"Version" : "2012-10-17",
@@ -44,12 +44,7 @@ resource "aws_iam_role" "irsa" {
4444
force_detach_policies = true
4545
permissions_boundary = var.addon_context.irsa_iam_permissions_boundary
4646

47-
tags = merge(
48-
{
49-
"Name" = format("%s-%s-%s", var.addon_context.eks_cluster_id, trim(var.kubernetes_service_account, "-*"), "irsa"),
50-
},
51-
var.addon_context.tags
52-
)
47+
tags = var.addon_context.tags
5348
}
5449

5550
resource "aws_iam_role_policy_attachment" "irsa" {

modules/irsa/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ variable "addon_context" {
3838
eks_oidc_issuer_url = string
3939
eks_oidc_provider_arn = string
4040
tags = map(string)
41+
irsa_iam_role_name = optional(string)
4142
irsa_iam_role_path = optional(string)
4243
irsa_iam_permissions_boundary = optional(string)
4344
})

0 commit comments

Comments
 (0)