Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allowing override for irsa role name #764

Merged

Conversation

nxf5025
Copy link
Contributor

@nxf5025 nxf5025 commented Jul 12, 2022

What does this PR do?

Gives the ability to override the IRSA IAM role name.

Motivation

In some cases we'd like to use a custom role name instead of the current default
Closes #333

More

  • Yes, I have tested the PR using my local account setup (Provide any test evidence report under Additional Notes)
  • Yes, I have added a new example under examples to support my PR
  • Yes, I have created another PR for add-ons under add-ons repo (if applicable)
  • Yes, I have updated the docs for this feature
  • Yes, I ran pre-commit run -a with this PR

Note: Not all the PRs required examples and docs except a new pattern or add-on added.

For Moderators

  • E2E Test successfully complete before merge?

Additional Notes

@nxf5025 nxf5025 temporarily deployed to EKS Blueprints Test July 12, 2022 19:20 Inactive
@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

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

we can use:

Suggested change
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")
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"))

@@ -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"),
Copy link
Contributor

Choose a reason for hiding this comment

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

The role name is no longer controlled through tag Name like previously so we can just remove this tag

@nxf5025 nxf5025 force-pushed the feature/adding-override-for-irsa-role-name branch from 0222b7d to 6199558 Compare July 14, 2022 13:00
@nxf5025 nxf5025 temporarily deployed to EKS Blueprints Test July 14, 2022 13:00 Inactive
Copy link
Contributor

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

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

thanks for the change @nxf5025 🎉

@bryantbiggs bryantbiggs merged commit c3882d9 into aws-ia:main Jul 14, 2022
allamand pushed a commit to allamand/terraform-aws-eks-blueprints that referenced this pull request Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: String length check needed for aws_iam_role.irsa name in module kubernetes-addons
2 participants