terraform-provider-kubernetes icon indicating copy to clipboard operation
terraform-provider-kubernetes copied to clipboard

kubernetes_secret not updated.

Open motizzz opened this issue 4 years ago • 2 comments
trafficstars

Hi, we start using Kubernetes provider version: 2.3.0 and we noticed that when we destroy random_password the kubernetes_secret data pass value wont changed to "".

in Kubernetes provider version: 2.0.2 it works as expected

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 0.15.5
Kubernetes provider version: 2.3.0 and higher  
Kubernetes version: 1.18

Affected Resource(s)

  • kubernetes_secret

Terraform Configuration Files

variable "pass" {}
variable "zone" {}
variable "project_id" {}
variable "cluster_name" {}


data "google_client_config" "default" {
}

data "google_container_cluster" "cluster" {
  name     = var.cluster_name
  location = var.zone
  project  = var.project_id
}

provider "kubernetes" {
  version                = "2.3.0"
  host                   = "https://${data.google_container_cluster.cluster.endpoint}"
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(data.google_container_cluster.cluster.master_auth.0.cluster_ca_certificate)
}

resource "random_password" "pass" {
  count = var.pass ? 1 : 0
  length = 16
}

resource "kubernetes_secret" "pass" {
  metadata {
    name = "pass"
  }
  data = {
    pass = element(concat(random_password.pass.*.result, tolist([""])), 0)
  }
}


Steps to Reproduce

  1. terraform apply -var pass=true -var zone=us-central1-c -var project_id=my-project -var cluster_name=cluster-foo
  2. terraform apply -var pass=false -var zone=us-central1-c -var project_id=my-project -var cluster_name=cluster-foo

Expected Behavior

What should have happened? kubernetes_secret pass should changed to empty string ""

Actual Behavior

What actually happened? password stay in secret

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

motizzz avatar Aug 03 '21 08:08 motizzz

I am facing the same issue when adding a new key/value in a secret and trying to update with terraform apply. Terraform doesn't output any error and it exits with an OK code.

sambonbonne avatar Sep 14 '21 07:09 sambonbonne

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!

github-actions[bot] avatar Sep 19 '22 00:09 github-actions[bot]

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Nov 18 '22 02:11 github-actions[bot]