Terraform-provider-helm: Error `chart.metadata is required` when using modules with same name as helm release

Created on 28 May 2020  Â·  6Comments  Â·  Source: hashicorp/terraform-provider-helm

I am using following project structure:

$ tree        
.
├── filebeat
│   └── main.tf
└── main.tf

1 directory, 2 files

When i run terraform apply i will get a chart.metadata is required.

When i change the name of the module directory....

$ mv filebeat filebeat-module

...and change the module source...

module "filebeat" {
  source = "./filebeat-module"
}

...and run terraform apply again it works:

Terraform Version and Provider Version

$ terraform -v
Terraform v0.12.25

Provider Version

provider "helm" {
  version = "1.2.1"
}

Affected Resource(s)

  • helm_release

Terraform Configuration Files

In ./main.tf:

module "filebeat" {
  source = "./filebeat"
}

In ./filebeat/main.tf:

provider "helm" {
  version = "1.2.1"
}

resource "helm_release" "filebeat" {
  name       = "filebeat"
  namespace  = "logging"
  repository = "https://helm.elastic.co"
  chart      = "filebeat"
  version    = "7.7.0"
}

Debug Output

$ terraform apply --auto-approve
module.filebeat.helm_release.filebeat: Creating...

Error: validation: chart.metadata is required

  on filebeat/main.tf line 5, in resource "helm_release" "filebeat":
   5: resource "helm_release" "filebeat" {

Steps to Reproduce

  1. terraform init
  2. terraform apply
bug upstream-helm

Most helpful comment

I got into this again. Apparently, I have a subdirectory named flux in the directory with the rest of the terraform files. And helm_release named flux as well. So I renamed the flux directory and it did the trick.

All 6 comments

I don't think it's related to module, as I have just got the same error without using modules.

I switched away from

repository = data.helm_repository.reponame.metadata[0].name

to a direct url

repository = "https://charts.fluxcd.io"

Terraform wanted to apply this change (why?)
and now I get this

Error: validation: chart.metadata is required

It seems it is connected to https://github.com/helm/helm/issues/7862.

Here the explanation:

But, inside the function LocateChart that finds the chart it looks on the local filesystem before checking if a repo is explicitly set. If the local chart is there that is used.

I did run helm repo update and then terraform apply again - the issue has gone.
So it most certainly is related to the abovementioned issue.

Thanks!

I got into this again. Apparently, I have a subdirectory named flux in the directory with the rest of the terraform files. And helm_release named flux as well. So I renamed the flux directory and it did the trick.

I got into this again. Apparently, I have a subdirectory named flux in the directory with the rest of the terraform files. And helm_release named flux as well. So I renamed the flux directory and it did the trick.

IT WORKS!

I got into this again. Apparently, I have a subdirectory named flux in the directory with the rest of the terraform files. And helm_release named flux as well. So I renamed the flux directory and it did the trick.

IT WORKS!

Exactly, im storing chart in s3 and i had to change the chart name because of a local directory named the same.... For me this is utter bullsh.... If im pointing to a repository for a place where it should look for a chart im expecting it wont look for it anywhere else. And the error "validation: chart.metadata is required" says nothing 0_o For some reason in mentioned "bug report", few posts above they seem to describe this behavior as intended 0_o

Was this page helpful?
0 / 5 - 0 ratings