From 37e8543cf14b844bb71db359b2152634438238bf Mon Sep 17 00:00:00 2001 From: Yonatan Koren Date: Wed, 6 Oct 2021 12:47:49 -0400 Subject: [PATCH] Feat: allow `var.name` to be set to empty (#11) Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> --- README.md | 31 +++++++++++++++++++++++++++++-- README.yaml | 27 +++++++++++++++++++++++++++ main.tf | 4 +++- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b37a4e8..db22f64 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,31 @@ module "helm_release" { } ``` +If `var.service_account_name` is set, then `var.name` can be set to "" in order to achieve a shorter name for the IAM +Role created for the ServiceAccount: + +```hcl +module "helm_release" { + source = "cloudposse/helm-release/aws" + # Cloud Posse recommends pinning every module to a specific version + # version = "x.x.x" + + name = "" + + create_namespace = true + kubernetes_namespace = "echo" + + service_account_name = "echo" + service_account_namespace = "echo" + + iam_role_enabled = true + ... +} +``` + +This will result in an IAM role with a name such as: `eg-uw2-dev-echo@echo` instead of `eg-uw2-dev-echo-echo@echo`. +Additionally, if `var.name` is empty, the name used for the Helm Release will be that of `var.chart`. + @@ -440,14 +465,16 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply ### Contributors -| [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![RB][nitrocode_avatar]][nitrocode_homepage]
[RB][nitrocode_homepage] | -|---|---| +| [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![RB][nitrocode_avatar]][nitrocode_homepage]
[RB][nitrocode_homepage] | [![Yonathan Koren][korenyoni_avatar]][korenyoni_homepage]
[Yonathan Koren][korenyoni_homepage] | +|---|---|---| [osterman_homepage]: https://github.com/osterman [osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png [nitrocode_homepage]: https://github.com/nitrocode [nitrocode_avatar]: https://img.cloudposse.com/150x150/https://github.com/nitrocode.png + [korenyoni_homepage]: https://github.com/korenyoni + [korenyoni_avatar]: https://img.cloudposse.com/150x150/https://github.com/korenyoni.png [![README Footer][readme_footer_img]][readme_footer_link] [![Beacon][beacon]][website] diff --git a/README.yaml b/README.yaml index 3a145ed..a024332 100644 --- a/README.yaml +++ b/README.yaml @@ -118,6 +118,31 @@ usage: |- } ``` + If `var.service_account_name` is set, then `var.name` can be set to "" in order to achieve a shorter name for the IAM + Role created for the ServiceAccount: + + ```hcl + module "helm_release" { + source = "cloudposse/helm-release/aws" + # Cloud Posse recommends pinning every module to a specific version + # version = "x.x.x" + + name = "" + + create_namespace = true + kubernetes_namespace = "echo" + + service_account_name = "echo" + service_account_namespace = "echo" + + iam_role_enabled = true + ... + } + ``` + + This will result in an IAM role with a name such as: `eg-uw2-dev-echo@echo` instead of `eg-uw2-dev-echo-echo@echo`. + Additionally, if `var.name` is empty, the name used for the Helm Release will be that of `var.chart`. + # Example usage examples: |- Here is an example of using this module: @@ -138,3 +163,5 @@ contributors: github: "osterman" - name: "RB" github: "nitrocode" + - name: "Yonathan Koren" + github: "korenyoni" diff --git a/main.tf b/main.tf index 9cb2d03..dd4f676 100644 --- a/main.tf +++ b/main.tf @@ -35,7 +35,9 @@ module "eks_iam_role" { resource "helm_release" "this" { count = local.enabled ? 1 : 0 - name = module.this.name + # Allows var.name to be empty, which is allowed to be the case for this module since var.name is optional in eks-iam-role. + # For more information, see: https://github.com/cloudposse/terraform-aws-eks-iam-role + name = coalesce(module.this.name, var.chart) chart = var.chart description = var.description