output "key_id" { description = "The key. Give this ID to the services that should encrypt with it." value = google_kms_crypto_key.this.id } output "verify" { description = "Encrypt, switch the key version off, watch decrypt fail, switch it back on. Run as a key administrator." value = <<-EOT printf hello > plain.txt gcloud kms encrypt --location ${var.location} --keyring ${google_kms_key_ring.this.name} --key ${google_kms_crypto_key.this.name} --plaintext-file plain.txt --ciphertext-file secret.enc gcloud kms keys versions disable 1 --location ${var.location} --keyring ${google_kms_key_ring.this.name} --key ${google_kms_crypto_key.this.name} gcloud kms decrypt --location ${var.location} --keyring ${google_kms_key_ring.this.name} --key ${google_kms_crypto_key.this.name} --ciphertext-file secret.enc --plaintext-file - # must fail, the version is disabled gcloud kms keys versions enable 1 --location ${var.location} --keyring ${google_kms_key_ring.this.name} --key ${google_kms_crypto_key.this.name} EOT }