Skip to content

Instantly share code, notes, and snippets.

@rjosephwright
Created January 10, 2023 16:06
Show Gist options
  • Save rjosephwright/f1485cddcc12dd651ec96558ac7601c6 to your computer and use it in GitHub Desktop.
Save rjosephwright/f1485cddcc12dd651ec96558ac7601c6 to your computer and use it in GitHub Desktop.
Terraform wrapper for Helm chart with additional resources
variable "helm_values" {
type = any
default = {
abc = "xyz"
}
}
variable "namespace" {
type = string
}
# Other variables omitted...
# Uses the Kubernetes provider. Note helm can already create
# the namespace for the release, but this is just for an example.
resource "kubernetes_namespace" "it" {
metadata = {
name = var.namespace
}
}
# Uses Helm provider.
resource "helm_release" "it" {
chart = var.helm_chart
name = var.helm_release
# Using output of kubernetes_namespace resource enforces
# ordering, rather than passing in var.namespace.
namespace = one(kubernetes_namespace.it.metadata[*].name)
repository = var.helm_repository
values = [yamlencode(var.helm_values)]
version = var.helm_chart_version
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment