hashicorp / terraform-provider-helm

Terraform Helm provider
https://www.terraform.io/docs/providers/helm/
Mozilla Public License 2.0
998 stars 369 forks source link

--set-file functionality #628

Closed afedulov closed 1 month ago

afedulov commented 3 years ago

Description

Some charts explicitly rely on configuration being provided via the --set-file option:

https://github.com/helm/charts/blob/master/stable/grafana/templates/dashboards-json-configmap.yaml

There was already an issue with a proposed workaround, but as you can see in the example chart above, it is not universally applicable: https://github.com/hashicorp/terraform-provider-helm/issues/240

afedulov commented 3 years ago

I would really appreciate if someone could maybe provide some insights into how to workaround this limitation.

aareet commented 3 years ago

@afedulov you could use the file function to work around this

nkorandla01 commented 2 years ago

any update on this? i'm also running into this with data dog helm chart because they allow --set-file only.

ckyoog commented 2 years ago

Ran into this issue too. Surprised that the set_file is not supported yet. Does the helm provider has a totally different architecture than the helm itself? Otherwise, why is that, such a native feature is not supported yet? Would the internal of the set_file not be as simple as this:

ckyoog commented 2 years ago

Oh, just realized that the helm provider has never been working with file-path. Even for the values file, it also needs the user to make the values file inlined. Maybe this explains why the set_file has not been supported -- the helm provider doesn't know how to handle file-path, or intends not to.

Tchoupinax commented 2 years ago

Hello,

Sorry to dig up this post but the issue is still opened and no solution found. For exemple, Linkerd requires need files for the installation.

helm install linkerd2 \
  --set-file identityTrustAnchorsPEM=ca.crt \
  --set-file identity.issuer.tls.crtPEM=issuer.crt \
  --set-file identity.issuer.tls.keyPEM=issuer.key \
  --set identity.issuer.crtExpiry=$exp \
  linkerd/linkerd2

What is the reason to not implement set-file in terraform provider?

Thank you and have a nice day!

kristjankullerkann commented 2 years ago

@afedulov you could use the file function to work around this

This works fine, thanks!

An example based on linkerd:

resource "kubernetes_namespace_v1" "linkerd" {
  metadata {
    annotations = {
      "linkerd.io/inject" = "disabled"
    }

    labels = {
      "linkerd.io/is-control-plane"          = "true"
      "config.linkerd.io/admission-webhooks" = "disabled"
      "linkerd.io/control-plane-ns"          = "linkerd"
    }

    name = "linkerd"
  }
}

resource "helm_release" "linkerd" {
  name       = "linkerd2"
  repository = "https://helm.linkerd.io/stable"
  chart      = "linkerd2"
  version    = "2.11.4"
  namespace  = kubernetes_namespace_v1.linkerd.metadata[0].name

  set {
    name  = "installNamespace"
    value = "false"
  }

  set {
    name  = "identityTrustAnchorsPEM"
    value = file("linkerd/ca.crt")
  }

  set {
    name  = "identity.issuer.tls.crtPEM"
    value = file("linkerd/issuer.crt")
  }

  set {
    name  = "identity.issuer.tls.keyPEM"
    value = file("linkerd/issuer.key")
  }
}

Note - terraform fails to install linkerd with helm if namespace is not create in advance.

julienmuller-forge commented 1 year ago

Hello,

I have the same need, but with non utf8 binary file(namely, a pdf file). Works fine with Helm's --set-file, but terraform provider's set complains :

set {
    name  = "app.document"
    value = file("document.pdf")
  }
Call to function "file" failed: contents of "document.pdf" are not valid UTF-8; use the filebase64 function to obtain the Base64 encoded contents or the
│ other file functions (e.g. filemd5, filesha256) to obtain file hashing results instead.

Any thought ?

DigitalCreationsCo commented 1 year ago

@julienmuller-forge Terraform has some built in functions you can try to convert file type: https://developer.hashicorp.com/terraform/language/functions

smtarslanturk commented 1 year ago

how can i set one key to 3 value like below

OPTION 1: set { name = "env.plugins" value = "xxxx,yyyy,zzzz" type = "string" }

OPTION 2: set { name = "env.plugins" value = "{xxxx,yyyy,zzzz}" type = "string" }

OPTION 3: set { name = "env.plugins[0]" value = "XXXX" type = "string" } set { name = "env.plugins[1]" value = "YYYY" type = "string" } set { name = "env.plugins[2]" value = "ZZZZZ" type = "string" }

the above 3 options do not work correctly and i get error when i try to terraform apply

thank you

Anbu42 commented 1 year ago

Function file does not always work, see issue

github-actions[bot] commented 2 months ago

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!