2
helm ls
NAME    NAMESPACE   REVISION    UPDATED                 STATUS  CHART       APP VERSION
portworx    default     1       2022-08-25 06:01:24.991655337 +0000 UTC deployed 
    

Can someone help me in updating the above helm resources using terraform ?

resource "helm_release" "portworx" {
  chart         = "https://raw.githubusercontent.com/IBM/charts/master/repo/community/"
  name          = "portworx"
  reuse_values  = true
  dependency_update= true
  force_update  = true
  recreate_pods = false
  wait          = true
  max_history   = 1
}

I have written above code but instead of updating the chart it is trying to create again. Can someone please help me on this ?

Marko E
  • 13,362
  • 2
  • 19
  • 28
aman chhabra
  • 45
  • 1
  • 6

1 Answers1

1

To answer your question, that should be fairly easy to do, just use version argument [1] in the helm_resource:

resource "helm_release" "portworx" {
  chart             = "https://raw.githubusercontent.com/IBM/charts/master/repo/community/"
  name              = "portworx"
  reuse_values      = true
  dependency_update = true
  force_update      = true
  recreate_pods     = false
  wait              = true
  max_history       = 1
  version           = "2.9.1"
}

[1] https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release#version

Marko E
  • 13,362
  • 2
  • 19
  • 28
  • Can you please explain what is the importance of dependency_update parameter here ? – aman chhabra Sep 01 '22 at 12:33
  • Well, I just copied it over from your question and added the `version` field. – Marko E Sep 01 '22 at 12:45
  • Can we divide this code into modules and call from resources from other folder ? – aman chhabra Sep 05 '22 at 17:52
  • You can modularize almost anything in terraform, so I would say yes. – Marko E Sep 05 '22 at 17:55
  • I would suggest asking a new question with as many detalis as possible. – Marko E Sep 05 '22 at 18:05
  • Can't be do this update without version variable so that it pick the latest version – aman chhabra Sep 06 '22 at 15:23
  • When `version` is not specified, the chart will install the latest version: https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release#version. However, it depends on when you installed it the first time as from then on there can be updates so that version you have installed locally is no longer the latest. – Marko E Sep 06 '22 at 21:20
  • But it is not getting updated to latest – aman chhabra Sep 08 '22 at 07:43
  • When I tried without version and it ran the upgrade but I don't see any changes in helm chart version – aman chhabra Sep 08 '22 at 08:03
  • Unfortunately this does not work -- at least not with the provider versions 2.6 through 2.7. What version did it work on? (Some resources are updated, not all, especially not charts found in requiremenst.yaml). –  Nov 09 '22 at 17:54
  • Dang. I'm wrong. And I can't undo my vote. Mea culpa. –  Nov 09 '22 at 18:26
  • Ah well, thank you for downvoting anyway. Also it wasn't about what the version is doing or not but about updating the version, so there is that also. – Marko E Nov 09 '22 at 18:35