Skip to content

Commit

Permalink
Fix: Using set sometimes gets Helm provider confused (#6)
Browse files Browse the repository at this point in the history
Add option to pass values without using set

Co-authored-by: eranelbaz <[email protected]>
  • Loading branch information
roni-frantchi and eranelbaz authored Aug 4, 2021
1 parent a23146d commit 1d8a470
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ No Modules.
| k8s\_service\_account\_name | The k8s cluster-autoscaler service account name | `string` | `"cluster-autoscaler"` | no |
| mod\_dependency | Dependence variable binds all AWS resources allocated by this module, dependent modules reference this variable | `bool` | `null` | no |
| settings | Additional settings which will be passed to the Helm chart values, see https://hub.helm.sh/charts/stable/cluster-autoscaler | `map(any)` | `{}` | no |
| values | Additional yaml encoded values which will be passed to the Helm chart, see https://hub.helm.sh/charts/stable/cluster-autoscaler | `string` | `""` | no |

## Outputs

Expand Down
47 changes: 18 additions & 29 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,24 @@ resource "helm_release" "cluster_autoscaler" {
version = var.helm_chart_version
repository = var.helm_repo_url

set {
name = "awsRegion"
value = data.aws_region.current.name
}

set {
name = "autoDiscovery.clusterName"
value = var.cluster_name
}

set {
name = "rbac.create"
value = "true"
}

set {
name = "rbac.serviceAccount.create"
value = "true"
}

set {
name = "rbac.serviceAccount.name"
value = var.k8s_service_account_name
}

set {
name = "rbac.serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
value = aws_iam_role.cluster_autoscaler[0].arn
}
values = [
yamlencode({
"awsRegion" : data.aws_region.current.name,
"autoDiscovery" : {
"clusterName" : var.cluster_name
},
"rbac" : {
"create" : true,
"serviceAccount" : {
"create" : true,
"name" : var.k8s_service_account_name
"annotations" : {
"eks.amazonaws.com/role-arn" : aws_iam_role.cluster_autoscaler[0].arn
}
}
}
}),
var.values]

dynamic "set" {
for_each = var.settings
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,9 @@ variable "settings" {
default = {}
description = "Additional settings which will be passed to the Helm chart values, see https://hub.helm.sh/charts/stable/cluster-autoscaler"
}

variable "values" {
type = string
default = ""
description = "Additional yaml encoded values which will be passed to the Helm chart, see https://hub.helm.sh/charts/stable/cluster-autoscaler"
}

0 comments on commit 1d8a470

Please sign in to comment.