A pipeline passes a short-lived access token into a root module, where it is used only in a provider block. The pipeline saves the plan with terraform plan -out and uploads it as a build artifact. The requirement is that the token must not be written into that plan file. What should the module author do?
Choose one.
Ephemeral input variables (Terraform 1.10 and later) are available during the run but omitted from plan and state files.
A saved plan records the values of input variables so apply can reproduce them. Marking the variable ephemeral tells Terraform to keep the value out of plan and state files; it must then be supplied again at apply time. Provider configuration is an allowed place to reference an ephemeral variable. Sensitive only hides display, and the method of supplying a value does not change what the plan stores.
- Identify the artefact to protect: the saved plan file.
- Recall that saved plans store variable values unless they are ephemeral.
- Confirm the token is used in an allowed ephemeral context: a provider block.
- Reject display-only or delivery-only changes.
Exam tip: Use ephemeral = true when a variable's value must stay out of plan and state files.
Terraform Professional (002): Turning Requirements into Predictable, Secure Configuration — the lesson that teaches this.