Terraform Associate 004 ยท Dependencies, validation and sensitive data
Ephemeral values, write-only arguments and Vault
Ephemeral variables/resources, write-only arguments that never reach state, Vault provider and dynamic secrets, avoiding hard-coded credentials (4h).
Key points
- Ephemeral values exist only during one operation and are omitted from state and plan files (ephemeral variables and child module outputs, the ephemeral block, write-only arguments).
- A write-only argument (name usually ends in _wo, paired with _wo_version) hands a temporary value to a managed resource without storing it.
- Fetching secrets at run time, for example from Vault, avoids hard-coding credentials.
Source: https://developer.hashicorp.com/terraform/language/manage-sensitive-data
Practice questions
Are values produced by an ephemeral resource stored in the state or plan file?
- No, they exist only during the operation
- Yes, but encrypted
- Yes, but only in the plan file
- Only if the output is marked sensitive
Show answer
Answer: A. No, they exist only during the operation
Terraform does not store ephemeral resources in state or plan files; they exist only for the current operation.
Where may an ephemeral resource's value be referenced?
- A write-only argument of a managed resource
- A locals block
- A variable block with ephemeral = true
- An ordinary (non write-only) resource argument
- A root module output with ephemeral = true
Show answer
Answer: A. A write-only argument of a managed resource, B. A locals block, C. A variable block with ephemeral = true
Allowed: write-only arguments, locals, ephemeral variables and other contexts. An ordinary resource argument is rejected, and root module outputs cannot be ephemeral.
A write-only argument is saved in state like any other argument but is hidden in CLI output.
Show answer
Answer: False
False. Write-only arguments are never persisted to plan or state files; hiding display is what sensitive does.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
