terraform-provider-helm: Getting Wrong Error: chart [...] version [...] not found in [...] repository

Terraform, Provider, Kubernetes and Helm Versions

Terraform version: 0.14.8
Provider version: 2.0.3
Kubernetes version: 1.19.1
Helm version: 3.5.2

Affected Resource(s)

  • helm_release

Terraform Configuration Files

terraform {
  required_providers {
    helm = {
      source  = "hashicorp/helm"
      version = "2.0.3"
    }
  }
}

provider "helm" {
  kubernetes {
    config_path = "~/.kube/config"
  }
}

resource "helm_release" "nginx_ingress" {
  name       = "nginx-ingress"
  repository = "https://kubernetes.github.io/ingress-nginx"
  chart      = "nginx-ingress"
  version    = "3.24.0"
  namespace  = "kube-system"

  values = [
    file("helm/nginx-ingress/values.yml")
  ]
}

Debug Output

For full log see:

I cannot find any useful information there but:

2021-03-13T03:19:40.079Z [DEBUG] plugin: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/helm/2.0.3/linux_amd64/terraform-provider-helm_v2.0.3_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/helm/2.0.3/linux_amd64/terraform-provider-helm_v2.0.3_x5]
2021-03-13T03:19:40.081Z [DEBUG] plugin: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/helm/2.0.3/linux_amd64/terraform-provider-helm_v2.0.3_x5 pid=13458
2021-03-13T03:19:40.082Z [DEBUG] plugin: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/helm/2.0.3/linux_amd64/terraform-provider-helm_v2.0.3_x5
2021-03-13T03:19:40.147Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: configuring server automatic mTLS: timestamp=2021-03-13T03:19:40.147Z
2021-03-13T03:19:40.223Z [DEBUG] plugin.terraform-provider-helm_v2.0.3_x5: plugin address: address=/tmp/plugin426193591 network=unix timestamp=2021-03-13T03:19:40.223Z
2021-03-13T03:19:40.223Z [DEBUG] plugin: using plugin: version=5
2021-03-13T03:19:40.301Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: 2021/03/13 03:19:40 [DEBUG] [resourceDiff: nginx-ingress] Start: timestamp=2021-03-13T03:19:40.300Z
2021/03/13 03:19:40 [WARN] Provider "registry.terraform.io/hashicorp/helm" produced an invalid plan for helm_release.nginx_ingress, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .atomic: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .lint: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .verify: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .wait: planned value cty.True does not match config value cty.NullVal(cty.Bool)
      - .cleanup_on_fail: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .replace: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .timeout: planned value cty.NumberIntVal(300) does not match config value cty.NullVal(cty.Number)
      - .dependency_update: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .disable_webhooks: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .force_update: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .disable_crd_hooks: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .skip_crds: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .disable_openapi_validation: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .recreate_pods: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .reuse_values: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .create_namespace: planned value cty.False does not match config value cty.NullVal(cty.Bool)
      - .max_history: planned value cty.NumberIntVal(0) does not match config value cty.NullVal(cty.Number)
ty.NullVal(cty.Bool)
      - .reset_values: planned value cty.False does not match config value cty.NullVal(cty.Bool)
helm_release.nginx_ingress: Creating...
2021/03/13 03:19:40 [DEBUG] EvalApply: ProviderMeta config value set
2021/03/13 03:19:40 [DEBUG] helm_release.nginx_ingress: applying the planned Create change
2021-03-13T03:19:40.367Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: 2021/03/13 03:19:40 [DEBUG] setting computed for "metadata" from ComputedKeys: timestamp=2021-03-13T03:19:40.366Z
2021-03-13T03:19:40.367Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: 2021/03/13 03:19:40 [DEBUG] [resourceReleaseCreate: nginx-ingress] Started: timestamp=2021-03-13T03:19:40.367Z
2021-03-13T03:19:40.367Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: 2021/03/13 03:19:40 [DEBUG] [resourceReleaseCreate: nginx-ingress] Getting helm configuration: timestamp=2021-03-13T03:19:40.367Z
2021-03-13T03:19:40.367Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: 2021/03/13 03:19:40 [DEBUG] [INFO] GetHelmConfiguration start: timestamp=2021-03-13T03:19:40.367Z
2021-03-13T03:19:40.367Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: 2021/03/13 03:19:40 [DEBUG] Using kubeconfig: /home/runner/.kube/config: timestamp=2021-03-13T03:19:40.367Z
2021-03-13T03:19:40.367Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: 2021/03/13 03:19:40 [INFO] Successfully initialized kubernetes config: timestamp=2021-03-13T03:19:40.367Z
2021-03-13T03:19:40.367Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: 2021/03/13 03:19:40 [DEBUG] [INFO] GetHelmConfiguration success: timestamp=2021-03-13T03:19:40.367Z
2021-03-13T03:19:40.367Z [INFO]  plugin.terraform-provider-helm_v2.0.3_x5: 2021/03/13 03:19:40 [DEBUG] [resourceReleaseCreate: nginx-ingress] Getting chart: timestamp=2021-03-13T03:19:40.367Z
2021/03/13 03:19:40 [DEBUG] helm_release.nginx_ingress: apply errored, but we're indicating that via the Error pointer rather than returning it: chart "nginx-ingress" version "3.24.0" not found in https://kubernetes.github.io/ingress-nginx repository

Error: chart "nginx-ingress" version "3.24.0" not found in https://kubernetes.github.io/ingress-nginx repository

  on main.tf line 16, in resource "helm_release" "nginx_ingress":
  16: resource "helm_release" "nginx_ingress" {


2021-03-13T03:19:40.404Z [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-03-13T03:19:40.405Z [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/helm/2.0.3/linux_amd64/terraform-provider-helm_v2.0.3_x5 pid=13458
2021-03-13T03:19:40.405Z [DEBUG] plugin: plugin exited
Error: Terraform exited with code 1.
Error: Process completed with exit code 1.

Steps to Reproduce

  1. Use https://kubernetes.github.io/ingress-nginx as a helm_release repository with chart nginx-ingress and version 3.24.0
  2. See https://github.com/pathob/tf_helm/blob/main/main.tf
  3. See https://github.com/pathob/tf_helm/blob/main/.github/workflows/test.yml
  4. See https://github.com/pathob/tf_helm/runs/2095542326?check_suite_focus=true

Expected Behavior

  1. Terraform should find the chart like e.g. with using repository https://helm.nginx.com/stable and chart nginx-ingress and version 0.8.0 (but there is something else odd with this chart);
  2. See https://github.com/pathob/tf_helm/blob/working/main.tf
  3. See https://github.com/pathob/tf_helm/blob/working/.github/workflows/test.yml
  4. See https://github.com/pathob/tf_helm/runs/2093139142?check_suite_focus=true

Actual Behavior

Terraform cannot find the chart like mentioned in the expected behaviour, although I’m using the same chart / version / repo with Helm / Helmfile and the chart with that version in that repo definetly exists, see https://kubernetes.github.io/ingress-nginx/index.yaml

Workaround

I’m currently using the full chart URL as the chart without repo and version like so: https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-3.24.0/ingress-nginx-3.24.0.tgz

Important Factoids

I think none.

References

I think none.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 25
  • Comments: 18

Most upvoted comments

I was having the same issue trying to install the consul. Usually to do that manually I run:

helm repo add hashicorp https://helm.releases.hashicorp.com
helm install hashicorp/consul

so the naive approach for me was to use following resource configuration:

resource "helm_release" "consul" {
  name             = "consul"
  repository       = "https://helm.releases.hashicorp.com"
  chart            = "hashicorp/consul"
}

It fails with the same error everyone else is having so I tried to “bruteforce” it and found the way to make it work:

resource "helm_release" "default" {
  name             = "consul"
  repository       = "https://helm.releases.hashicorp.com"
  chart            = "consul"
}

The more I think of it the more sense it makes. When I run helm repo ls it returns:

NAME                            URL
hashicorp                       https://helm.releases.hashicorp.com

so to install the chart from that specific repo I have to prefix my chart name with a repo name, hashicorp/consul, while Terraform Helm provider does not need that prefix.

I was getting the same error. My work around was to do away with the repository and version arguments.

Instead of this

resource "helm_release" "nginx_ingress" {
  name       = "nginx-ingress"
  repository = "https://kubernetes.github.io/ingress-nginx"
  chart      = "nginx-ingress"
  version    = "3.24.0"
  namespace  = "kube-system"

  values = [
    file("helm/nginx-ingress/values.yml")
  ]
}

I retrieved the install link from Artifacthub and supplied that to the chart argument

resource "helm_release" "nginx_ingress" {
  name       = "nginx-ingress"
  chart      = "https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-3.24.0/ingress-nginx-3.24.0.tgz"
  namespace  = "kube-system"

  values = [
    file("helm/nginx-ingress/values.yml")
  ]
}

Also note that the version is part of the install link, so no need to specify the version argument as well. More about the chart argument here.

I’ll double post instead of edit because I think it may be useful to other people.

When using the format:

resource "helm_release" "prometheus_stack" {
  name       = "ps"
  namespace  = "monitoring"
  repository = "https://prometheus-community.github.io/helm-charts"
  chart      = "prometheus-community/kube-prometheus-stack"
  version    = "18.0.13"
}

It fails with the mentioned error:

Error: failed to download "https://github.com/prometheus-community/helm-charts/releases/download/kube-prometheus-stack-18.0.13/kube-prometheus-stack-18.0.13.tgz" at version "18.0.13" (hint: running `helm repo update` may help)

But, if you manually add your repo with helm:

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

And change your code to rely on your local list:

resource "helm_release" "prometheus_stack" {
  name       = "ps"
  namespace  = "monitoring"
  chart      = "prometheus-community/kube-prometheus-stack"
  version    = "18.0.13"
}

It works perfectly. So it seems that whatever is the problem, is when terraform tries to add the repository.

I was to just post this comment, but I decided to try another thing. Just to see if I could reproduce the problem, I deleted the prometheus-community repository from the ~/.config/helm/repositories.yaml file. And then I tried again with the first method:

resource "helm_release" "prometheus_stack" {
  name       = "ps"
  namespace  = "monitoring"
  repository = "https://prometheus-community.github.io/helm-charts"
  chart      = "prometheus-community/kube-prometheus-stack"
  version    = "18.0.13"
}

And it worked as expected.

Then, again to see if I can reproduce some problem, I added the repo again to the ~/.config/helm/repositories.yaml file:

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

And applied again with the last format, and it still worked as expected.

So it seems that messing with the ~/.config/helm/repositories.yaml file can fix the problem, even when theoretically terraform doesn’t use it, since all the information is in the code.

My conclusion is, I know nothing.

Hello @pathob ! My workaround is to downgrade to 1.3.2 https://registry.terraform.io/providers/hashicorp/helm/1.3.2/docs/data-sources/repository and using helm_repository data resource.

EDIT: Ignore this post… this was working locally because Terraform Helm was using my local Helm configuration which has the configuration for ChartMuseum. Check this post instead https://github.com/hashicorp/terraform-provider-helm/issues/707#issuecomment-844548333

👎

I can confirm that this solution worked for me. Using a private ChartMuseum repository with basic HTTP auth and it does not with the provider versions

terraform: 0.12.31
helm: 2.1.2

Not working

helm provider: 2.1.2

helm_release xxx {
  repository          = "https://chartmuseum.domain.com/"
  repository_username = data.aws_secretsmanager_secret_version.chartmuseum_credentials["username"].secret_string
  repository_password = data.aws_secretsmanager_secret_version.chartmuseum_credentials["password"].secret_string
}

Working

helm provider: 1.3.2

helm_release xxx {
  repository = data.helm_repository.chartmuseum.metadata[0].name
}

data helm_repository chartmuseum {
  name     = "chartmuseum"
  URL      = "https://chartmuseum.domain.com/"
  username = data.aws_secretsmanager_secret_version.chartmuseum_credentials["username"].secret_string
  password = data.aws_secretsmanager_secret_version.chartmuseum_credentials["password"].secret_string
}

Hello @pathob ! My workaround is to downgrade to 1.3.2 https://registry.terraform.io/providers/hashicorp/helm/1.3.2/docs/data-sources/repository and using helm_repository data resource.