Skip to content

Commit

Permalink
Allowing override for irsa role name
Browse files Browse the repository at this point in the history
  • Loading branch information
nxf5025 committed Jul 12, 2022
1 parent 6a1e412 commit 0222b7d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/irsa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <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 |
| <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 |
| <a name="input_create_kubernetes_namespace"></a> [create\_kubernetes\_namespace](#input\_create\_kubernetes\_namespace) | Should the module create the namespace | `bool` | `true` | no |
| <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 |
| <a name="input_irsa_iam_policies"></a> [irsa\_iam\_policies](#input\_irsa\_iam\_policies) | IAM Policies for IRSA IAM role | `list(string)` | `[]` | no |
Expand Down
4 changes: 2 additions & 2 deletions modules/irsa/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ resource "kubernetes_service_account_v1" "irsa" {
resource "aws_iam_role" "irsa" {
count = var.irsa_iam_policies != null ? 1 : 0

name = format("%s-%s-%s", var.addon_context.eks_cluster_id, trim(var.kubernetes_service_account, "-*"), "irsa")
name = var.addon_context.irsa_iam_role_name != null ? var.addon_context.irsa_iam_role_name : format("%s-%s-%s", var.addon_context.eks_cluster_id, trim(var.kubernetes_service_account, "-*"), "irsa")
description = "AWS IAM Role for the Kubernetes service account ${var.kubernetes_service_account}."
assume_role_policy = jsonencode({
"Version" : "2012-10-17",
Expand All @@ -46,7 +46,7 @@ resource "aws_iam_role" "irsa" {

tags = merge(
{
"Name" = format("%s-%s-%s", var.addon_context.eks_cluster_id, trim(var.kubernetes_service_account, "-*"), "irsa"),
"Name" = var.addon_context.irsa_iam_role_name != null ? var.addon_context.irsa_iam_role_name : format("%s-%s-%s", var.addon_context.eks_cluster_id, trim(var.kubernetes_service_account, "-*"), "irsa"),
},
var.addon_context.tags
)
Expand Down
1 change: 1 addition & 0 deletions modules/irsa/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ variable "addon_context" {
eks_oidc_issuer_url = string
eks_oidc_provider_arn = string
tags = map(string)
irsa_iam_role_name = optional(string)
irsa_iam_role_path = optional(string)
irsa_iam_permissions_boundary = optional(string)
})
Expand Down

0 comments on commit 0222b7d

Please sign in to comment.