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: allow var.name to be set to empty #11

Merged
merged 5 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
korenyoni marked this conversation as resolved.
Show resolved Hide resolved

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`.




Expand Down Expand Up @@ -440,14 +465,16 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
### Contributors

<!-- markdownlint-disable -->
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![RB][nitrocode_avatar]][nitrocode_homepage]<br/>[RB][nitrocode_homepage] |
|---|---|
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![RB][nitrocode_avatar]][nitrocode_homepage]<br/>[RB][nitrocode_homepage] | [![Yonathan Koren][korenyoni_avatar]][korenyoni_homepage]<br/>[Yonathan Koren][korenyoni_homepage] |
|---|---|---|
<!-- markdownlint-restore -->

[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]
Expand Down
27 changes: 27 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
korenyoni marked this conversation as resolved.
Show resolved Hide resolved

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:
Expand All @@ -138,3 +163,5 @@ contributors:
github: "osterman"
- name: "RB"
github: "nitrocode"
- name: "Yonathan Koren"
github: "korenyoni"
4 changes: 3 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down