HashiCorp Terraform Associate (HashiCorp Certified: Terraform Associate) Practice Test 18

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?

  1. Use terraform apply -var-file=prod.tfvars + Check apply output for partial failure
  2. Use terraform apply -replace=ADDRESS for an intentional rebuild + Check apply output for partial failure
  3. Run terraform apply tfplan for an approved saved plan + Keep sensitive saved plans secure
  4. Use terraform apply -var-file=prod.tfvars + Use terraform apply -input=false in unattended execution

Explanation

Correct Answer

A:

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

B:

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.

C:

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.

D:

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.

Question 171

An engineer is deleting one disposable Terraform deployment. A reviewer must determine how to bypass interactive confirmation for a controlled teardown job. Which action is the appropriate choice?

  1. Preserve required records before teardown
  2. Use terraform destroy -auto-approve only with safeguards
  3. Use terraform destroy -target=ADDRESS cautiously
  4. Understand prevent_destroy during planned deletion

Explanation

Correct Answer

B:

Automatic approval suppresses the prompt but not provider deletion restrictions or external dependencies; the operation remains destructive; this behavior should be assessed against the concrete need to bypass interactive confirmation for a controlled teardown job. This directly supports the task to bypass interactive confirmation for a controlled teardown job during a cross-team handoff.

Incorrect Answers

A:

State is a management map, not a full backup of application data or cloud resources; deletion may be irreversible without separate backups; this behavior should be assessed against the concrete need to bypass interactive confirmation for a controlled teardown job. The stated requirement is to bypass interactive confirmation for a controlled teardown job, not to avoid assuming Terraform can restore deleted provider objects from state alone; this alternative addresses a different control or phase.

C:

Targeting is intended for exceptional recovery, not routine architecture management; the rest of the state can remain dependent on objects that were removed; this behavior should be assessed against the concrete need to bypass interactive confirmation for a controlled teardown job. The distinction matters here: using that mechanism to limit a teardown to a selected resource or dependency subset would still leave the objective to bypass interactive confirmation for a controlled teardown job unmet.

D:

The lifecycle setting can make a normal destroy plan fail for a protected block; removing the block altogether removes the guard from evaluation; this behavior should be assessed against the concrete need to bypass interactive confirmation for a controlled teardown job. It may support a related workflow, but the question specifically requires the mechanism for bypass interactive confirmation for a controlled teardown job rather than recognize a guard against destructive changes while the resource block remains configured.

Question 172

The immediate Terraform task is to check configuration meaning after enforcing consistent style. Which method handles that task most directly?

  1. Use terraform fmt -write=false
  2. Run terraform fmt -recursive
  3. Run terraform fmt -diff
  4. Apply style checks to module directories
  5. Run terraform validate separately

Explanation

Correct Answer

E:

Validate checks references, argument types, and other configuration rules; nicely formatted HCL may still be invalid or operationally wrong; this behavior should be assessed against the concrete need to check configuration meaning after enforcing consistent style. This directly supports the task to check configuration meaning after enforcing consistent style during a platform review.

Incorrect Answers

A:

Disabling write avoids persisting formatting edits while retaining the formatting analysis; it is not a semantic validation of the resource schema; this behavior should be assessed against the concrete need to check configuration meaning after enforcing consistent style. It may support a related workflow, but the question specifically requires the mechanism for check configuration meaning after enforcing consistent style rather than inspect formatting requirements without modifying files.

B:

Recursive mode traverses child directories rather than just the current location; it is useful in repositories containing multiple roots and modules; this behavior should be assessed against the concrete need to check configuration meaning after enforcing consistent style. The stated requirement is to check configuration meaning after enforcing consistent style, not to format Terraform configurations in nested directories; this alternative addresses a different control or phase.

C:

Diff mode shows the before-and-after formatting changes; it cannot indicate whether a proposed resource change is safe; this behavior should be assessed against the concrete need to check configuration meaning after enforcing consistent style. That can be useful when the aim is to display the textual adjustments a formatter would make, but it does not directly deliver the requested ability to check configuration meaning after enforcing consistent style.

D:

Module source code is Terraform configuration and can be formatted with the same tool; formatting never pins which module release is used; this behavior should be assessed against the concrete need to check configuration meaning after enforcing consistent style. The distinction matters here: using that mechanism to enforce a consistent codebase without changing module behavior would still leave the objective to check configuration meaning after enforcing consistent style unmet.

Question 173

A reviewer has to approve a two-part design: make infrastructure edits traceable and reviewable; additionally, ensure independent deployments do not accidentally share object bindings. Which option pairs the correct mechanisms?

  1. Preview changes with terraform plan + Keep environment state separated
  2. Write the desired configuration first + Put automated tests before apply approvals
  3. Use version control alongside the workflow + Avoid applying an outdated reviewed plan
  4. Use version control alongside the workflow + Keep environment state separated

Explanation

Correct Answer

D:

For the first criterion, git captures code changes and supports peer review; Terraform state and provider API results remain separate operational concerns; this behavior should be assessed against the concrete need to make infrastructure edits traceable and reviewable and ensure independent deployments do not accidentally share object bindings; this directly addresses the need to make infrastructure edits traceable and reviewable. For the separate second criterion, multiple root working directories or CLI workspaces can carry different states; the isolation of state prevents Terraform from treating two environments as one inventory; this behavior should be assessed against the concrete need to make infrastructure edits traceable and reviewable and ensure independent deployments do not accidentally share object bindings; this fulfills the need to ensure independent deployments do not accidentally share object bindings. Together they cover the independent tasks of make infrastructure edits traceable and reviewable and ensure independent deployments do not accidentally share object bindings without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the ensure independent deployments do not accidentally share object bindings requirement, but the first is designed for another concern: Planning compares desired configuration with current state and provider observations; no planned infrastructure actions are applied by the plan command; this behavior should be assessed against the concrete need to make infrastructure edits traceable and reviewable and ensure independent deployments do not accidentally share object bindings. That first component is designed to inspect intended create, change, and delete actions before execution, which does not accomplish the requested task to make infrastructure edits traceable and reviewable, even though the other measure satisfies ensure independent deployments do not accidentally share object bindings.

B:

The first measure is intended to establish the intended infrastructure before Terraform evaluates changes: Resource blocks, variables, and modules define the target arrangement; running the CLI without an intended configuration cannot infer a team's architecture goals; this behavior should be assessed against the concrete need to make infrastructure edits traceable and reviewable and ensure independent deployments do not accidentally share object bindings. The second measure is intended to reduce risk by verifying syntax and policy before deploying: Formatting, validation, and policy checks can gate promotion; they do not guarantee real cloud capacity or authorization at execution time; this behavior should be assessed against the concrete need to make infrastructure edits traceable and reviewable and ensure independent deployments do not accidentally share object bindings. Neither is the directly designated method for the separate goals of make infrastructure edits traceable and reviewable and ensure independent deployments do not accidentally share object bindings in this review.

C:

The first measure meets the requirement to make infrastructure edits traceable and reviewable, but its partner serves a different role: Saved plans encode assumptions about the state snapshot and inputs; if the state changes, applying a stale plan may be rejected rather than silently reinterpreted; this behavior should be assessed against the concrete need to make infrastructure edits traceable and reviewable and ensure independent deployments do not accidentally share object bindings. That second component is designed to ensure the approved actions still correspond to current state, so the still-missing criterion is to ensure independent deployments do not accidentally share object bindings, while the first criterion remains make infrastructure edits traceable and reviewable.

Question 174

In an automated release, the requested result is to reselect newer eligible provider and module packages. What should the engineer select?

  1. Inspect .terraform/ as generated local metadata
  2. Use terraform init -upgrade
  3. Use terraform init -backend=false cautiously
  4. Use terraform init -lockfile=readonly

Explanation

Correct Answer

B:

Upgrade requests reconsideration of versions within declared constraints; it changes dependency selections, not infrastructure objects by itself; this behavior should be assessed against the concrete need to reselect newer eligible provider and module packages. This directly supports the task to reselect newer eligible provider and module packages during a module implementation.

Incorrect Answers

A:

The directory can hold installed modules, provider metadata, and backend configuration; it should normally be excluded from Git and may contain sensitive settings; this behavior should be assessed against the concrete need to reselect newer eligible provider and module packages. That can be useful when the aim is to recognize initialization artifacts rather than versioned source, but it does not directly deliver the requested ability to reselect newer eligible provider and module packages.

C:

Disabling backend setup avoids configuring remote state, but some later operations require an initialized backend; it does not create a temporary safe state automatically; this behavior should be assessed against the concrete need to reselect newer eligible provider and module packages. It may support a related workflow, but the question specifically requires the mechanism for reselect newer eligible provider and module packages rather than skip backend initialization for a specific preparation task.

D:

Read-only dependency locking catches selection drift in automated builds; the lock file applies to providers rather than pinning arbitrary local module directories; this behavior should be assessed against the concrete need to reselect newer eligible provider and module packages. The stated requirement is to reselect newer eligible provider and module packages, not to enforce a committed provider selection without lockfile edits; this alternative addresses a different control or phase.

Question 175

A reviewer wants to distinguish syntax validation from runtime checks. The team must both check configuration consistency independently of managed infrastructure operations and avoid inferring a successful future apply from successful static checks. Which paired choice implements those distinct goals?

  1. Run terraform validate after init + Interpret a clean validate as limited assurance
  2. Use terraform plan for state-dependent checking + Use variable validation for input contracts
  3. Run terraform validate after init + Run terraform validate -json for machine consumption
  4. Use terraform fmt -check for formatting enforcement + Interpret a clean validate as limited assurance

Explanation

Correct Answer

A:

For the first criterion, validate checks syntax, types, and provider-schema rules without generating a cloud execution plan; initialization is normally required so schemas and modules are present; this behavior should be assessed against the concrete need to check configuration consistency independently of managed infrastructure operations and avoid inferring a successful future apply from successful static checks; this directly addresses the need to check configuration consistency independently of managed infrastructure operations. For the separate second criterion, provider API authorization, remote conflicts, and real infrastructure drift can still produce failures; validation checks supported configuration structure rather than deployment success; this behavior should be assessed against the concrete need to check configuration consistency independently of managed infrastructure operations and avoid inferring a successful future apply from successful static checks; this fulfills the need to avoid inferring a successful future apply from successful static checks. Together they cover the independent tasks of check configuration consistency independently of managed infrastructure operations and avoid inferring a successful future apply from successful static checks without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to detect proposed infrastructure differences as well as dynamic provider evaluations: Plan evaluates the current infrastructure context and produces intended actions; validate cannot establish whether remote permissions and quotas will permit those actions; this behavior should be assessed against the concrete need to check configuration consistency independently of managed infrastructure operations and avoid inferring a successful future apply from successful static checks. The second measure is intended to reject invalid user-supplied values with a targeted message: The validation rule belongs to the variable declaration and returns a Boolean; it is distinct from the CLI's whole-configuration validation subcommand; this behavior should be assessed against the concrete need to check configuration consistency independently of managed infrastructure operations and avoid inferring a successful future apply from successful static checks. Neither is the directly designated method for the separate goals of check configuration consistency independently of managed infrastructure operations and avoid inferring a successful future apply from successful static checks in this review.

C:

The first measure meets the requirement to check configuration consistency independently of managed infrastructure operations, but its partner serves a different role: JSON output allows tooling to read validation findings systematically; it does not change whether the configuration will be applied; this behavior should be assessed against the concrete need to check configuration consistency independently of managed infrastructure operations and avoid inferring a successful future apply from successful static checks. That second component is designed to obtain structured diagnostics in automation, so the still-missing criterion is to avoid inferring a successful future apply from successful static checks, while the first criterion remains check configuration consistency independently of managed infrastructure operations.

D:

The second measure does meet the avoid inferring a successful future apply from successful static checks requirement, but the first is designed for another concern: fmt -check exits nonzero when files need canonical formatting; it is a style check, not a replacement for Terraform semantic validation; this behavior should be assessed against the concrete need to check configuration consistency independently of managed infrastructure operations and avoid inferring a successful future apply from successful static checks. That first component is designed to detect code style deviations without rewriting files, which does not accomplish the requested task to check configuration consistency independently of managed infrastructure operations, even though the other measure satisfies avoid inferring a successful future apply from successful static checks.

Question 176

An operator is preparing a controlled Terraform change. Two independent changes are requested: first, export machine-readable plan details for a policy tool; second, override an input variable for one planned run. Which pair of measures fulfills both?

  1. Use terraform show -json tfplan + Use terraform plan -replace=ADDRESS
  2. Use terraform plan -detailed-exitcode + Run terraform plan without applying
  3. Use terraform plan -out=tfplan + Use terraform plan -var='name=value'
  4. Use terraform show -json tfplan + Use terraform plan -var='name=value'

Explanation

Correct Answer

D:

For the first criterion, jSON output exposes structured planned values and actions; the output can contain sensitive values even when terminal formatting hides them; this behavior should be assessed against the concrete need to export machine-readable plan details for a policy tool and override an input variable for one planned run; this directly addresses the need to export machine-readable plan details for a policy tool. For the separate second criterion, cLI variable arguments supply run-specific values; they do not permanently modify the variable declaration or backend configuration; this behavior should be assessed against the concrete need to export machine-readable plan details for a policy tool and override an input variable for one planned run; this fulfills the need to override an input variable for one planned run. Together they cover the independent tasks of export machine-readable plan details for a policy tool and override an input variable for one planned run without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to export machine-readable plan details for a policy tool, but its partner serves a different role: The flag adds a replacement instruction to planning for an addressed resource; it is preferable to legacy manual taint workflows for deliberate replacement; this behavior should be assessed against the concrete need to export machine-readable plan details for a policy tool and override an input variable for one planned run. That second component is designed to request replacement of a particular managed instance, so the still-missing criterion is to override an input variable for one planned run, while the first criterion remains export machine-readable plan details for a policy tool.

B:

The first measure is intended to distinguish clean plans from plans with proposed changes in CI: The option uses exit code 0 for no differences, 2 for differences, and 1 for errors; a nonzero value is not always an execution failure; this behavior should be assessed against the concrete need to export machine-readable plan details for a policy tool and override an input variable for one planned run. The second measure is intended to preview the actions needed to reconcile the declared configuration: Plan evaluates dependencies and current state and reports create/update/replace/delete intentions; it normally performs no desired resource changes; this behavior should be assessed against the concrete need to export machine-readable plan details for a policy tool and override an input variable for one planned run. Neither is the directly designated method for the separate goals of export machine-readable plan details for a policy tool and override an input variable for one planned run in this review.

C:

The second measure does meet the override an input variable for one planned run requirement, but the first is designed for another concern: A saved plan captures selections and inputs for later use; it may include secrets and backend settings, so the artifact requires access controls; this behavior should be assessed against the concrete need to export machine-readable plan details for a policy tool and override an input variable for one planned run. That first component is designed to save a plan for later explicit approval and application, which does not accomplish the requested task to export machine-readable plan details for a policy tool, even though the other measure satisfies override an input variable for one planned run.

Question 177

An engineer is deciding how to apply a previously saved plan. A reviewer must determine how to reconcile the state and observed API results before taking further action. Which action is the appropriate choice?

  1. Keep sensitive saved plans secure
  2. Use terraform apply -replace=ADDRESS for an intentional rebuild
  3. Use terraform apply -input=false in unattended execution
  4. Run a new plan after unexpected apply behavior

Explanation

Correct Answer

D:

A subsequent plan refreshes tracked objects and identifies outstanding changes; blindly rerunning unrelated commands may hide the failure's scope; this behavior should be assessed against the concrete need to reconcile the state and observed API results before taking further action. This directly supports the task to reconcile the state and observed API results before taking further action during a cross-team handoff.

Incorrect Answers

A:

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 reconcile the state and observed API results before taking further action. The distinction matters here: using that mechanism to avoid leaking provider settings and input values through artifacts would still leave the objective to reconcile the state and observed API results before taking further action unmet.

B:

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 reconcile the state and observed API results before taking further action. It may support a related workflow, but the question specifically requires the mechanism for reconcile the state and observed API results before taking further action rather than force a targeted resource to be replaced during an ordinary apply.

C:

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 reconcile the state and observed API results before taking further action. The stated requirement is to reconcile the state and observed API results before taking further action, not to prevent the run from waiting for interactive variable input; this alternative addresses a different control or phase.

Question 178

A reviewer has to approve a two-part design: avoid deleting resources belonging to a different environment; additionally, avoid assuming Terraform can restore deleted provider objects from state alone. Which option pairs the correct mechanisms?

  1. Check the selected workspace before destroying + Preserve required records before teardown
  2. Understand cloud deletion protections + Preserve required records before teardown
  3. Use terraform destroy for a managed deployment + Remove a resource from state without destroying it
  4. Check the selected workspace before destroying + Inspect dependencies during teardown

Explanation

Correct Answer

A:

For the first criterion, terraform operates on the selected state and current configuration; similar resource names in separate states can refer to entirely different real objects; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment and avoid assuming Terraform can restore deleted provider objects from state alone; this directly addresses the need to avoid deleting resources belonging to a different environment. For the separate second criterion, state is a management map, not a full backup of application data or cloud resources; deletion may be irreversible without separate backups; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment and avoid assuming Terraform can restore deleted provider objects from state alone; this fulfills the need to avoid assuming Terraform can restore deleted provider objects from state alone. Together they cover the independent tasks of avoid deleting resources belonging to a different environment and avoid assuming Terraform can restore deleted provider objects from state alone without exchanging the responsibilities of these features.

Incorrect Answers

B:

The second measure does meet the avoid assuming Terraform can restore deleted provider objects from state alone requirement, but the first is designed for another concern: Some services reject deletes while protection, retention, or dependencies remain; changing the HCL declaration alone does not override service-side restrictions; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment and avoid assuming Terraform can restore deleted provider objects from state alone. That first component is designed to distinguish provider API refusal from Terraform syntax issues, which does not accomplish the requested task to avoid deleting resources belonging to a different environment, even though the other measure satisfies avoid assuming Terraform can restore deleted provider objects from state alone.

C:

The first measure is intended to plan and delete resources tracked by the current configuration and state: Destroy requests deletion of Terraform-managed objects in the selected state; it does not search all cloud resources or remove unmanaged objects; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment and avoid assuming Terraform can restore deleted provider objects from state alone. The second measure is intended to stop Terraform management while leaving a real object intact: terraform state rm or a supported removed block can forget an object; it is different from instructing a provider to delete infrastructure; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment and avoid assuming Terraform can restore deleted provider objects from state alone. Neither is the directly designated method for the separate goals of avoid deleting resources belonging to a different environment and avoid assuming Terraform can restore deleted provider objects from state alone in this review.

D:

The first measure meets the requirement to avoid deleting resources belonging to a different environment, but its partner serves a different role: Terraform reverses dependency relationships where necessary to delete objects safely; explicit and implicit graph edges influence safe order; this behavior should be assessed against the concrete need to avoid deleting resources belonging to a different environment and avoid assuming Terraform can restore deleted provider objects from state alone. That second component is designed to understand why child objects may be destroyed before prerequisites, so the still-missing criterion is to avoid assuming Terraform can restore deleted provider objects from state alone, while the first criterion remains avoid deleting resources belonging to a different environment.

Question 179

A Terraform rollout has separate acceptance criteria: enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries. Which combined approach directly satisfies the two criteria?

  1. Avoid treating formatting as infrastructure planning + Separate fmt from provider installation
  2. Run terraform fmt -diff + Use terraform fmt -write=false
  3. Apply style checks to module directories + Separate fmt from provider installation
  4. Use standard indentation and alignment from fmt + Separate fmt from provider installation
  5. Apply style checks to module directories + Run terraform fmt -check in CI

Explanation

Correct Answer

C:

For the first criterion, module source code is Terraform configuration and can be formatted with the same tool; formatting never pins which module release is used; this behavior should be assessed against the concrete need to enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries; this directly addresses the need to enforce a consistent codebase without changing module behavior. For the separate second criterion, formatting reads local HCL and does not initialize backends or download provider packages; dependency preparation remains the role of init; this behavior should be assessed against the concrete need to enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries; this fulfills the need to avoid expecting style normalization to fetch plugin binaries. Together they cover the independent tasks of enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the avoid expecting style normalization to fetch plugin binaries requirement, but the first is designed for another concern: A formatted file must still be evaluated by terraform plan to reveal resource changes; formatting commands do not contact APIs to execute changes; this behavior should be assessed against the concrete need to enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries. That first component is designed to recognize that whitespace changes are not a plan for cloud operations, which does not accomplish the requested task to enforce a consistent codebase without changing module behavior, even though the other measure satisfies avoid expecting style normalization to fetch plugin binaries.

B:

The first measure is intended to display the textual adjustments a formatter would make: Diff mode shows the before-and-after formatting changes; it cannot indicate whether a proposed resource change is safe; this behavior should be assessed against the concrete need to enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries. The second measure is intended to inspect formatting requirements without modifying files: Disabling write avoids persisting formatting edits while retaining the formatting analysis; it is not a semantic validation of the resource schema; this behavior should be assessed against the concrete need to enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries. Neither is the directly designated method for the separate goals of enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries in this review.

D:

The second measure does meet the avoid expecting style normalization to fetch plugin binaries requirement, but the first is designed for another concern: Canonical layout gives team members predictable formatting; hand-crafted alignment rules are not necessary to make Terraform parse HCL correctly; this behavior should be assessed against the concrete need to enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries. That first component is designed to reduce noisy diff conflicts across contributors, which does not accomplish the requested task to enforce a consistent codebase without changing module behavior, even though the other measure satisfies avoid expecting style normalization to fetch plugin binaries.

E:

The first measure meets the requirement to enforce a consistent codebase without changing module behavior, but its partner serves a different role: Check mode reports whether formatting changes are needed and can fail a pipeline; it does not itself rewrite source files; this behavior should be assessed against the concrete need to enforce a consistent codebase without changing module behavior and avoid expecting style normalization to fetch plugin binaries. That second component is designed to detect files whose formatting differs from Terraform conventions, so the still-missing criterion is to avoid expecting style normalization to fetch plugin binaries, while the first criterion remains enforce a consistent codebase without changing module behavior.

Question 180

A Terraform rollout has separate acceptance criteria: prepare backend, providers, and external module dependencies and inspect intended create, change, and delete actions before execution. Which combined approach directly satisfies the two criteria?

  1. Apply reviewed changes with terraform apply + Preview changes with terraform plan
  2. Initialize the working directory before planning + Put automated tests before apply approvals
  3. Keep environment state separated + Avoid applying an outdated reviewed plan
  4. Initialize the working directory before planning + Preview changes with terraform plan

Explanation

Correct Answer

D:

For the first criterion, terraform init sets up the directory so subsequent validation, planning, and applying can use the correct plugins and backend; initialization itself does not deploy resources; this behavior should be assessed against the concrete need to prepare backend, providers, and external module dependencies and inspect intended create, change, and delete actions before execution; this directly addresses the need to prepare backend, providers, and external module dependencies. For the separate second criterion, planning compares desired configuration with current state and provider observations; no planned infrastructure actions are applied by the plan command; this behavior should be assessed against the concrete need to prepare backend, providers, and external module dependencies and inspect intended create, change, and delete actions before execution; this fulfills the need to inspect intended create, change, and delete actions before execution. Together they cover the independent tasks of prepare backend, providers, and external module dependencies and inspect intended create, change, and delete actions before execution without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the inspect intended create, change, and delete actions before execution requirement, but the first is designed for another concern: Apply coordinates provider operations and updates state after effects are known; it needs valid authentication and can still fail if the API rejects an operation; this behavior should be assessed against the concrete need to prepare backend, providers, and external module dependencies and inspect intended create, change, and delete actions before execution. That first component is designed to execute the actions Terraform has selected for managed infrastructure, which does not accomplish the requested task to prepare backend, providers, and external module dependencies, even though the other measure satisfies inspect intended create, change, and delete actions before execution.

B:

The first measure meets the requirement to prepare backend, providers, and external module dependencies, but its partner serves a different role: Formatting, validation, and policy checks can gate promotion; they do not guarantee real cloud capacity or authorization at execution time; this behavior should be assessed against the concrete need to prepare backend, providers, and external module dependencies and inspect intended create, change, and delete actions before execution. That second component is designed to reduce risk by verifying syntax and policy before deploying, so the still-missing criterion is to inspect intended create, change, and delete actions before execution, while the first criterion remains prepare backend, providers, and external module dependencies.

C:

The first measure is intended to ensure independent deployments do not accidentally share object bindings: Multiple root working directories or CLI workspaces can carry different states; the isolation of state prevents Terraform from treating two environments as one inventory; this behavior should be assessed against the concrete need to prepare backend, providers, and external module dependencies and inspect intended create, change, and delete actions before execution. The second measure is intended to ensure the approved actions still correspond to current state: Saved plans encode assumptions about the state snapshot and inputs; if the state changes, applying a stale plan may be rejected rather than silently reinterpreted; this behavior should be assessed against the concrete need to prepare backend, providers, and external module dependencies and inspect intended create, change, and delete actions before execution. Neither is the directly designated method for the separate goals of prepare backend, providers, and external module dependencies and inspect intended create, change, and delete actions before execution in this review.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests