Data Source: helm_template

Render chart templates locally.

helm_template renders chart templates locally and exposes the rendered manifests in the data source attributes. helm_template mimics the functionality of the helm template command.

The arguments aim to be identical to the helm_release resource.

For further details on the helm template command, refer to the Helm documentation.

Example Usage

Render all chart templates

The following example renders all templates of the mariadb chart of the official Helm stable repository. Concatenated manifests are exposed as output variable mariadb_instance_manifest.

data "helm_template" "mariadb_instance" {
  name       = "mariadb-instance"
  namespace  = "default"
  repository = "https://charts.helm.sh/stable"

  chart   = "mariadb"
  version = "7.1.0"

  set {
    name  = "service.port"
    value = "13306"
  }

  set_sensitive {
    name = "rootUser.password"
    value = "s3cr3t!"
  }
}

resource "local_file" "mariadb_manifests" {
  for_each = data.helm_template.mariadb_instance.manifests

  filename = "./${each.key}"
  content  = each.value
}

output "mariadb_instance_manifest" {
  value = data.helm_template.mariadb_instance.manifest
}

output "mariadb_instance_manifests" {
  value = data.helm_template.mariadb_instance.manifests
}

output "mariadb_instance_notes" {
  value = data.helm_template.mariadb_instance.notes
}

Render selected chart templates

The following example renders only the templates master-statefulset.yaml and master-svc.yaml of the mariadb chart of the official Helm stable repository.

data "helm_template" "mariadb_instance" {
  name       = "mariadb-instance"
  namespace  = "default"
  repository = "https://charts.helm.sh/stable"

  chart   = "mariadb"
  version = "7.1.0"

  show_only = [
    "templates/master-statefulset.yaml",
    "templates/master-svc.yaml",
  ]

  set {
    name  = "service.port"
    value = "13306"
  }

  set_sensitive {
    name = "rootUser.password"
    value = "s3cr3t!"
  }
}

resource "local_file" "mariadb_manifests" {
  for_each = data.helm_template.mariadb_instance.manifests

  filename = "./${each.key}"
  content  = each.value
}

output "mariadb_instance_manifest" {
  value = data.helm_template.mariadb_instance.manifest
}

output "mariadb_instance_manifests" {
  value = data.helm_template.mariadb_instance.manifests
}

output "mariadb_instance_notes" {
  value = data.helm_template.mariadb_instance.notes
}

Argument Reference

The following arguments are supported:

The following attributes are specific to the helm_template data source and not available in the helm_release resource:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported: