title: How can I print out sensitive values from terraform state?
body: <p>Goal: I want to print out a sensitive value of <code>foo_resource.name.sensitive_field</code>.</p>
  <p>Originally I attempted to create an <a href="https://www.terraform.io/cli/commands/output" rel="nofollow noreferrer">output</a>:</p>
  <pre><code>output &quot;password&quot; {
    value       = foo_resource.name.sensitive_field
  }
  </code></pre>
  <p>and I got</p>
  <pre><code> Error: Output refers to sensitive values
  │ 
  │   on main.tf line 186:
  │  186: output &quot;password&quot; {
  │ 
  │ To 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 sensitive, to confirm your intent.
  │ 
  │ If you do intend to export this data, annotate the output value as sensitive by adding the following argument:
  │     sensitive = true
  ╵
  </code></pre>
  <p>so I added <code>sensitive = true</code> to it:</p>
  <pre><code>output &quot;password&quot; {
    value       = foo_resource.name.sensitive_field
    sensitive = true
  }
  </code></pre>
  <p>and then when I run it again I got:</p>
  <pre><code>$ terraform output
  password = &lt;sensitive&gt;
  </code></pre>