terraform plan) can potentially see values stored there.
Example: simplified Terraform state JSON containing a secret
Ephemeral values require Terraform 1.10+. If you’re preparing for the Terraform Associate exam or upgrading environments, confirm your Terraform version supports ephemeral features.

- Ephemeral values exist only in memory during Terraform operations (init, plan, apply) and are never written to plan or state files.
- They are recalculated every run and discarded immediately after use, preventing secrets from persisting in state.
ephemeral = true (you can also mark it sensitive = true to hide CLI/UI output):
sensitive = truehides the value in CLI/console output.ephemeral = trueensures the value is not written to plans or state files.- Use both for defense-in-depth.

- locals (they inherit ephemeral markers)
- provider blocks (ephemeral provider credentials)
- ephemeral resources (see the next section)
- ephemeral variables and outputs (module-level ephemeral data)
- provisioner blocks (e.g., connection credentials—use cautiously)
- write-only arguments on managed resource types (to pass secrets securely)
Ephemeral Resources
Terraform also supports ephemeral resources: a block type that behaves like a data source but whose retrieved values are kept only in memory and never written to state. Terraform “opens” the ephemeral resource during execution, uses the value, and then “closes” it to discard the secret.
- Fetch secrets from Vault or another secret manager without persisting them to state.
- Read temporary or short-lived credentials that exist only during execution.
- Retrieve dynamic tokens that change frequently (even between plan and apply).
Write-only Arguments
Write-only arguments provide a way to securely pass ephemeral values into managed resources during an operation while preventing those arguments from being persisted into Terraform state. Providers mark specific resource arguments as write-only; often a companion*_wo_version attribute is provided to help Terraform detect updates without storing the secret.

password_wo is the write-only argument and password_wo_version signals updates:
- They let you use ephemeral values with ordinary managed resources without storing secrets in state.
- Providers define which arguments are write-only; behavior varies by provider.
- The companion version attribute (
*_wo_version) signals resource updates without storing the secret value. - Not all resources support write-only arguments—consult provider docs.
| Feature | Persists in State? | Typical Use Case |
|---|---|---|
ephemeral variable or local | No | Provider credentials, temporary tokens |
ephemeral resource | No | Fetch secrets from secret stores at runtime |
Write-only argument (*_wo) | No (argument excluded) | Pass ephemeral secrets into managed resources |
| Regular resource argument | Yes | Static or non-sensitive configuration |
Provider support varies: check your provider’s documentation to see whether it implements ephemeral resources or write-only arguments (and which arguments are supported). These features are provider-dependent.
Summary
- Ephemeral values exist only in memory during Terraform operations and are never written to plan or state files.
- Use
ephemeral = true(optionally combined withsensitive = true) for variables, locals, provider credentials, outputs, etc., where supported. - Ephemeral resources (
ephemeral "<provider>_<resource>" "<name>") fetch runtime data and keep it only in memory—ideal for secrets from Vault or similar stores. - Write-only arguments allow ephemeral values to be passed to managed resources without persisting the secret in state; they often require a companion version attribute to track updates.
- Combine ephemeral features with environment variables, encrypted remote state, least-privilege access, and external secret managers for defense-in-depth.
- Terraform documentation (official)
- HashiCorp Vault documentation
- Terraform Associate certification course (example)