Skip to content

Instantly share code, notes, and snippets.

@Akaame
Last active July 31, 2021 06:54
Show Gist options
  • Save Akaame/9b4288d004b125f3f182f3e113607b51 to your computer and use it in GitHub Desktop.
Save Akaame/9b4288d004b125f3f182f3e113607b51 to your computer and use it in GitHub Desktop.
locals {
psql_ui_path = "github.com/zalando/postgres-operator/ui/manifests"
}
terraform {
required_providers {
kustomization = {
source = "kbst/kustomization"
version = "0.5.0"
}
}
}
provider "kustomization" {
kubeconfig_path = "~/.kube/config"
}
provider "kubernetes" {
config_path = "~/.kube/config"
}
resource "kubernetes_namespace" "ha-psql" {
metadata {
name = "ha-psql"
}
}
data "kustomization_overlay" "psql-ui" {
resources = [ local.psql_ui_path ]
patches {
patch = <<-EOF
- op: replace
path: /metadata/namespace
value: ${kubernetes_namespace.ha-psql.metadata.0.name}
EOF
# change the value to static "ha-psql" it works
# As it is it throw error: value depends on resource attributes that cannot be determined until apply
target = {
namespace = "default"
}
}
}
resource "kustomization_resource" "psql-ui" {
for_each = data.kustomization_overlay.psql-ui.ids
manifest = data.kustomization_overlay.psql-ui.manifests[each.value]
depends_on = [
data.kustomization_overlay.psql-ui
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment