terraform-provider-helm icon indicating copy to clipboard operation
terraform-provider-helm copied to clipboard

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

Open r3kzi opened this issue 4 years ago • 8 comments

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

r3kzi avatar May 28 '20 13:05 r3kzi

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

netflash avatar May 29 '20 03:05 netflash

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.

r3kzi avatar May 29 '20 07:05 r3kzi

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!

netflash avatar May 29 '20 07:05 netflash

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.

netflash avatar Jun 04 '20 12:06 netflash

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!

vsfedorenko avatar Sep 08 '20 12:09 vsfedorenko

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

KrzesloSzatan avatar Sep 10 '20 18:09 KrzesloSzatan

Jumped into the same issue, renaming the folder does the trick! Thanks for saving my day!

bjrara avatar Mar 27 '21 01:03 bjrara

Jumped into the same issue, renaming the folder does the trick! Thanks for saving my day!

Exact same here, got a directory named elasticsearch, renamed and error disappeared!

marcoooo avatar Sep 08 '22 13:09 marcoooo

Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you!

github-actions[bot] avatar Sep 09 '23 00:09 github-actions[bot]