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.…