Menu

Terraform's sensitive = true doesn't protect your secrets. Here's what does
📰

Terraform's sensitive = true doesn't protect your secrets. Here's what does

DEV Community: terraform·DevOps in Practice·3 days ago
#L7dxDHAs
#devtoterraform#devto#dev#terraform#value
Long article (673 words) — no AI summary yet.
Reading 0:00
15s threshold

Marking a Terraform output sensitive = true feels like protection. It isn't, at least not where it matters. Here's a two-minute proof, and what to do instead. Everything below is from a real run on Terraform 1.17.

The proof

A random database password, returned by an output marked sensitive:

resource "random_password" "db" { length = 16 }

output "db_password" { value = random_password . db . result sensitive = true }

Enter fullscreen mode

Exit fullscreen mode

After terraform apply , the CLI hides it:

$ terraform output db_password = < sensitive >

Enter fullscreen mode

Exit fullscreen mode

Now read the state file:

$ jq -r '.resources[0].instances[0].attributes.result' terraform.tfstate fqK5VEtF+v:imR-u

Enter fullscreen mode

Exit fullscreen mode

There's the password, in plain text.

What sensitive actually does

sensitive = true is a display setting.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.