Is it possible to edit existing Kubernetes resources using Terraform?

1/30/2020

I am trying to deploy a Kubernetes cluster using Terraform. In order to install nginx on my cluster, I wrote this inside my .tf file:

resource "helm_release" "ingress" {
    name      = "ingress"
    chart     = "stable/nginx-ingress"
     namespace = "kube-system"

    set {
        name = "controller.replicaCount"
        value = "1"
    }
    depends_on = [azurerm_kubernetes_cluster.k8s]
}

Everything works fine, nginx gets deployed, but I want to mount a configmap on the deployment. I'm pretty sure I can't do that before the nginx deployment gets created by Terraform, so I am wondering if I can do it after. The configmap is also created with Terraform:

resource "kubernetes_config_map" "nginx" {
  metadata {
    name = "my-name"
    namespace = "kube-system"
  }
  data = {
    "my-field" = "${file("${path.module}/C:/my_configmap.yaml")}"
  }
}
-- Daniel
kubernetes
terraform
terraform-provider-azure

0 Answers