Terraform-provider-helm: helm_release and local charts not working

Created on 28 Jan 2019  路  7Comments  路  Source: hashicorp/terraform-provider-helm

Terraform Version

Terraform v0.11.11

  • provider.azurerm v1.21.0
  • provider.helm v0.7.0
  • provider.kubernetes v1.5.0

Affected Resource(s)

Local repository in terraform module
/app/azure/test/.terraform/modules/8c130587e9bf283da478d0d9bb7548c6 would be the full path to the root of the charts

Terraform Configuration Files

resource "helm_release" "istio" {
  name       = "istio"
  repository = "${path.module}"
  chart      = "istio"
  namespace  = "istio-system"
}

Panic Output

  • helm_release.istio: failed to resolve "istio", Could not find protocol handler for:

Expected Behavior

Helm charts to be found

Actual Behavior

Not picking up the fact that this is a local directory. Also tried file:// prefix but this just resulted in:

  • helm_release.istio: failed to resolve "istio", Could not find protocol handler for: file

Steps to Reproduce

  1. terraform apply

Most helpful comment

We found that setting chart with absolute path (with path.module) works only if we don't move our project folder around. If another developer checks out our terraform project and the path.module will be different thus terraform will force to create a new resource.

All 7 comments

I'm using relative paths ala chart = "./istio" (and no repository) and it seems to work. It only deploys charts in a path relative to the tf configuration.

Not sure how easy it would be to give a relative path given the chart is in a module.

Don't you have an absolute path ready with ${path.module}?

resource "helm_release" "istio" {
  name       = "istio"
  # NOTE: actual subpath after ${path.module} depends on module structure
  chart = "${path.module}/istio"
  namespace  = "istio-system"
}

If your module contains a chart repository (and not just a chart) you can use helm_repository to create the chart and then reference it by name.

This is what mine looks like.

resource "helm_release" "istio_bootstrap" {
  name       = "istio"
  namespace  = "${var.istio_namespace}"
  chart      = "./istio-1.1.0-snapshot.3/install/kubernetes/helm/istio"
  depends_on = ["null_resource.istio_download"]
  timeout    = 1200
  values     = ["${var.istio_bootstrap_configuration}"]
}

Thanks Lucas & Aaron. It was me being dumb, I had repository defined as a relative path in another project and copied it across. But, just setting chart with absolute path works perfectly

We found that setting chart with absolute path (with path.module) works only if we don't move our project folder around. If another developer checks out our terraform project and the path.module will be different thus terraform will force to create a new resource.

@duanshiqiang we found this and used the lifecycles to ignore these changes.

# Chart is embedded in module and so path will change each time module path changes
  # it will still update when chart version is changed
  lifecycle {
    ignore_changes = ["chart"]
  }

This makes renaming the chart folder tricky but this happens less than a new modules path. Especially in a CI/CD

Was this page helpful?
0 / 5 - 0 ratings