Skip to content

Commit

Permalink
Feat: allow var.name to be set to empty (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: cloudpossebot <[email protected]>
  • Loading branch information
korenyoni and cloudpossebot authored Oct 6, 2021
1 parent d47de4a commit 37e8543
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
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"
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"
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

0 comments on commit 37e8543

Please sign in to comment.