A configuration using the default local backend provisions a database whose randomly generated password is exposed as an output. A reviewer asks whether the password is protected at rest in the state file. What should the practitioner tell them?
resource "random_password" "db" {
length = 20
}
output "db_password" {
value = random_password.db.result
sensitive = true
}- AMarking the output 'sensitive = true' encrypts the value inside terraform.tfstate, so it is protected at rest.
- BThe password never reaches state because 'random_password' keeps generated secrets only in provider memory.
- CThe local backend hashes all output values before writing them, so only an irreversible digest is stored.
- DThe value is stored as plaintext in terraform.tfstate, so the file must be treated as a secret and access to it restricted. Correct
Why A is wrong: The 'sensitive' flag only hides the value from CLI output; it does not encrypt anything written to state, so this overstates its effect.
Why B is wrong: Resource attributes, including generated passwords, are always persisted to state so Terraform can detect drift, so this is incorrect.
Why C is wrong: The local backend performs no hashing of values; it records real attribute values verbatim, so no irreversible digest is produced.
Why D is correct: The local backend writes state as plaintext JSON, so the generated password appears in clear text and the file itself must be guarded.