Terraform: Error: Output refers to sensitive values — a root module output containing sensitive data must be explicitly marked as sensitive
An output (or module output) exposes a value derived from a sensitive variable/attribute without sensitive = true.
Error: Output refers to sensitive valuesTo reduce the risk of accidentally exporting sensitive data that was intended to be only internal, Terraform requires that any root module output containing sensitive data be explicitly marked as sensitiveError: Output refers to sensitive values: Expressions used in outputs can only refer to sensitive values if the sensitive attribute is trueError: Invalid for_each argument ... Sensitive values, or values derived from sensitive values, cannot be used as for_each arguments Meaning
Add sensitive = true to the output, or use nonsensitive() only when you're sure the value isn't secret. Sensitivity propagates through expressions; for_each keys can't be sensitive (separate error). Terraform still stores values in state — protect state.
Common causes
- Output built from a sensitive variable/resource attribute (passwords, keys)
- Module output exposing sensitive data
- Missing
sensitive = true for_eachusing sensitive values- Interpolating sensitive values in unrelated outputs
⚡ Quick fix
output "db_password" { value = random_password.db.result sensitive = true }nonsensitive()only for known-safe values- Avoid secrets in outputs; use a secrets manager
Detailed fix by platform
Terraform
output "token" { value = aws_iam_access_key.k.secret sensitive = true }
How to diagnose
- Value — Sensitive source?
- Output — sensitive true?
- State — Protected?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Error building ARM Config: obtain subscription from Azure CLI Terraform: Error: building AzureRM Client: obtaining subscription ID / Please run 'az login' to setup account
- Error loading state: AccessDenied (S3 backend) Terraform: Error: Failed to load state: AccessDenied: Access Denied / Error refreshing state: AccessDenied status code: 403
- Invalid AWS Region Terraform: Error: Invalid AWS Region: us-east-3 / Error: configuring Terraform AWS Provider: validating provider credentials: operation error STS: GetCallerIdentity
Most viewed in Terraform
- Error acquiring the state lock Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked
- Inconsistent dependency lock file Terraform: Error: Inconsistent dependency lock file — provider x: required by this configuration but no version is selected
- Reference to undeclared resource Terraform: Error: Reference to undeclared resource / Reference to undeclared input variable
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026