Ask Your Question
3

How can a list be passed to helm using the terraform helm_release provider?

asked 2022-08-23 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-11 19:00:00 +0000

djk gravatar image

In order to pass a list to helm using the terraform helm_release provider, you can use the list type in your values block. Here is an example:

resource "helm_release" "my_release" {
  name       = "my-release"
  repository = "https://charts.example.com/"
  chart      = "my-chart"

  values = {
    my_list = list("item1", "item2", "item3")
  }
}

In this example, we are passing a list called my_list that contains three items to the helm chart. Note that we are using the list function to create the list with the three items. You can replace the items with variables or other expressions if needed.

Once you have your list defined in the values block, you can access it in your helm chart templates using the lookup function. For example, to iterate over the list in a range block, you can use the following code:

{{- range $i, $item := (lookup .Values "my_list") }}
  {{ printf "Item %d: %s" $i $item }}
{{- end }}

This will output the three items in the list with their corresponding index.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-08-23 11:00:00 +0000

Seen: 10 times

Last updated: May 11 '21