Question 170
An approved Terraform change must be executed safely. Two independent changes are requested: first, supply planned environment-specific input values in a direct apply; second, understand why an unsuccessful apply may still have changed some resources. Which pair of measures fulfills both?
Explanation
Correct Answer
For the first criterion, variable files set input variables for that run; their contents do not overwrite provider schemas or module source code; this behavior should be assessed against the concrete need to supply planned environment-specific input values in a direct apply and understand why an unsuccessful apply may still have changed some resources; this directly addresses the need to supply planned environment-specific input values in a direct apply. For the separate second criterion, terraform may have completed earlier provider operations before a later step fails; state can record successful actions, so investigate the next plan rather than assuming a full rollback; this behavior should be assessed against the concrete need to supply planned environment-specific input values in a direct apply and understand why an unsuccessful apply may still have changed some resources; this fulfills the need to understand why an unsuccessful apply may still have changed some resources. Together they cover the independent tasks of supply planned environment-specific input values in a direct apply and understand why an unsuccessful apply may still have changed some resources without exchanging the responsibilities of these features.
Incorrect Answers
The second measure does meet the understand why an unsuccessful apply may still have changed some resources requirement, but the first is designed for another concern: The CLI adds a replacement request to the plan it creates; a saved plan should instead be prepared with the replacement request at planning time; this behavior should be assessed against the concrete need to supply planned environment-specific input values in a direct apply and understand why an unsuccessful apply may still have changed some resources. That first component is designed to force a targeted resource to be replaced during an ordinary apply, which does not accomplish the requested task to supply planned environment-specific input values in a direct apply, even though the other measure satisfies understand why an unsuccessful apply may still have changed some resources.
The first measure is intended to execute the exact plan artifact rather than replan with new input values: Applying a saved plan uses its captured decisions and state assumptions; a changed state can invalidate it instead of silently applying a different plan; this behavior should be assessed against the concrete need to supply planned environment-specific input values in a direct apply and understand why an unsuccessful apply may still have changed some resources. The second measure is intended to avoid leaking provider settings and input values through artifacts: Plan files are not sanitized public reports; their embedded values and backend details require protective storage and restricted access; this behavior should be assessed against the concrete need to supply planned environment-specific input values in a direct apply and understand why an unsuccessful apply may still have changed some resources. Neither is the directly designated method for the separate goals of supply planned environment-specific input values in a direct apply and understand why an unsuccessful apply may still have changed some resources in this review.
The first measure meets the requirement to supply planned environment-specific input values in a direct apply, but its partner serves a different role: The run fails if required input cannot be obtained in noninteractive mode; this avoids jobs hanging on missing variables; this behavior should be assessed against the concrete need to supply planned environment-specific input values in a direct apply and understand why an unsuccessful apply may still have changed some resources. That second component is designed to prevent the run from waiting for interactive variable input, so the still-missing criterion is to understand why an unsuccessful apply may still have changed some resources, while the first criterion remains supply planned environment-specific input values in a direct apply.