HashiCorp Terraform Associate (004) · Section 4 · 24% of the exam
Understand best practices for managing sensitive data, including secrets management with Vault
One of the objectives of the HashiCorp Certified: Terraform Associate (004) exam, in the section “Terraform configuration”. Here is what it covers, the points to remember and a question to try.
What it covers
Secrets leak through configuration files, version control, logs, plan files and above all state. This lesson covers what sensitive really does, how ephemeral values and write-only arguments keep secrets out of state, and how HashiCorp Vault supplies secrets and short-lived credentials to Terraform.
Points to remember
- State holds secrets in plain text; protect it with a remote, encrypted, access-controlled backend.
sensitive = truehides values in CLI and UI output only; the value is still in state and plan files.ephemeralvariables and resources (1.10+) and write-only arguments (1.11+) keep values out of state and plan.- Write-only arguments end in
_woby convention and pair with a_wo_versionargument to trigger an update. - Ephemeral values can only be used in write-only arguments, provider and provisioner config, locals, ephemeral blocks, and ephemeral variables or child outputs.
Try a question
A configuration reads a secret with data "vault_kv_secret_v2" and uses it in a normal resource argument. The team wants to know where the secret value is stored. What is the correct answer?
- AIn state, because data source results are recorded there
- BOnly in Vault, while Terraform keeps just a reference to the secret path
- COnly in the plan output, which is removed from disk after apply
- DNowhere, because data sources are ephemeral by default in Terraform
Show the answer
A. A Vault data source returns the secret to Terraform, which saves it in state like any other attribute. An ephemeral resource used with a write-only argument avoids this.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Managing sensitive data and secrets with Vault teaches this objective (about 45 minutes), and 17 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.
More in this section
- Use and differentiate
resourceanddatablocks - Refer to resource attributes and create cross-resource references
- Use variables and outputs
- Understand and use complex types
- Write dynamic configuration using expressions and functions
- Define resource dependencies in configuration
- Validate configuration using custom conditions