TF-Associate-004 - Terraform configuration - Section 4h

Understand best practices for managing sensitive data, including secrets management with Vault.

Marking values sensitive suppresses them in output, but they are still stored in plaintext in state, so state must be protected. Candidates should understand sourcing secrets from a system such as Vault rather than committing them, and why sensitive does not encrypt state.

sensitive argumentsecrets in state are plaintextHashiCorp Vault providerprotecting state files

Practice question for this objective

Free sampleTerraform configurationmedium

A module exposes a generated database password through an output and marks that output with sensitive = true. A colleague expects that the value will now be encrypted where Terraform records it and hidden everywhere. Which statement most accurately describes what sensitive = true actually does?

output "db_password" {
  value     = random_password.db.result
  sensitive = true
}
  • AIt encrypts the output value inside the state file and redacts it from CLI output, so the plaintext never appears in state or on screen.
  • BIt prevents the output from being written to state at all, so the value exists only transiently during the run and cannot be read afterwards.
  • CIt blocks other configurations from reading the output through a remote state data source, restricting access to the declaring module only.
  • DIt redacts the value from plan, apply, and output display, but the value is still stored in plaintext in the state file. Correct
Marking an output sensitive redacts it from CLI display but does not encrypt it or remove it from the plaintext state file. The sensitive argument on an output tells Terraform to hide the value in plan, apply, and terraform output, and to propagate the sensitive marking to expressions that use it. It does not encrypt state or prevent persistence, so the underlying value remains readable to anyone who can open the state file.

Why A is wrong: Tempting because sensitive sounds like encryption, but Terraform state stores sensitive values in plaintext; the flag only affects display, so this overstates the protection.

Why B is wrong: Tempting if a candidate assumes hiding implies exclusion, but outputs are always persisted to state; sensitive does not stop the value being recorded there.

Why C is wrong: Tempting because it sounds like an access control, but sensitive imposes no cross configuration read restriction; a remote state data source can still consume the value.

Why D is correct: Correct: the sensitive flag suppresses the value in CLI output and marks it as sensitive downstream, yet Terraform writes it to state as plaintext, so the state file must still be protected by other means.

See more TF-Associate-004 practice questions, answers explained.

More in this domain

Back to all Terraform configuration objectives, or the TF-Associate-004 cert hub.

Examworthy is not affiliated with or endorsed by HashiCorp. Original, blueprint-aligned practice material only.