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

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.

Question 181

An engineer needs to skip installing child modules in a prepared directory as part of an automated release. Which option is the best fit?

  1. Inspect .terraform/ as generated local metadata
  2. Use terraform init -reconfigure
  3. Use terraform init -migrate-state
  4. Use terraform init -get=false

Explanation

Correct Answer

D:

This option avoids module download/update during initialization; it is appropriate only when required modules are already available; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory. This directly supports the task to skip installing child modules in a prepared directory during an infrastructure audit.

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 skip installing child modules in a prepared directory. The distinction matters here: using that mechanism to recognize initialization artifacts rather than versioned source would still leave the objective to skip installing child modules in a prepared directory unmet.

B:

Reconfiguration initializes the directory against the new backend settings; it is not a replacement for migrating state that must be preserved; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory. It may support a related workflow, but the question specifically requires the mechanism for skip installing child modules in a prepared directory rather than discard the previously remembered backend configuration without migrating state.

C:

Migration attempts to move state into the newly configured backend; backups and confirmation are important before switching active state locations; this behavior should be assessed against the concrete need to skip installing child modules in a prepared directory. The stated requirement is to skip installing child modules in a prepared directory, not to copy existing state when changing storage backends; this alternative addresses a different control or phase.

Question 182

A continuous-integration job must catch configuration defects. The requirement is to obtain structured diagnostics in automation. Which Terraform mechanism directly meets this requirement?

  1. Use variable validation for input contracts
  2. Interpret a clean validate as limited assurance
  3. Check expression references for validity
  4. Run terraform validate -json for machine consumption

Explanation

Correct Answer

D:

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 obtain structured diagnostics in automation. This directly supports the task to obtain structured diagnostics in automation during a planned migration.

Incorrect Answers

A:

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 obtain structured diagnostics in automation. That can be useful when the aim is to reject invalid user-supplied values with a targeted message, but it does not directly deliver the requested ability to obtain structured diagnostics in automation.

B:

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 obtain structured diagnostics in automation. The distinction matters here: using that mechanism to avoid inferring a successful future apply from successful static checks would still leave the objective to obtain structured diagnostics in automation unmet.

C:

Terraform validates the structure of expressions against known configuration objects; values only resolved by providers may remain unknown until later phases; this behavior should be assessed against the concrete need to obtain structured diagnostics in automation. It may support a related workflow, but the question specifically requires the mechanism for obtain structured diagnostics in automation rather than catch references to undeclared blocks and invalid attributes where detectable.

Question 183

A CI pipeline must archive reviewable execution decisions. A reviewer must determine how to distinguish modification of an existing object from creation or destruction. Which action is the appropriate choice?

  1. Use terraform plan -refresh-only
  2. Read ~ as in-place update intent
  3. Use terraform plan -var-file=env.tfvars
  4. Read -/+ as replacement intent

Explanation

Correct Answer

B:

The plan symbol indicates updating a tracked resource without replacing its identity; whether a particular field supports this depends on the provider; this behavior should be assessed against the concrete need to distinguish modification of an existing object from creation or destruction. This directly supports the task to distinguish modification of an existing object from creation or destruction during a cross-team handoff.

Incorrect Answers

A:

Refresh-only mode updates Terraform's view to remote reality when applied; it does not make cloud objects conform to the old configuration; this behavior should be assessed against the concrete need to distinguish modification of an existing object from creation or destruction. The stated requirement is to distinguish modification of an existing object from creation or destruction, not to propose state reconciliation for external changes without correcting real resources; this alternative addresses a different control or phase.

C:

An explicitly selected tfvars file feeds input values into that run; a .tfvars file is not a provider dependency lock; this behavior should be assessed against the concrete need to distinguish modification of an existing object from creation or destruction. The distinction matters here: using that mechanism to load an explicit environment input file would still leave the objective to distinguish modification of an existing object from creation or destruction unmet.

D:

Some argument changes cannot be updated remotely and require a new object; replacement can have downtime implications unless ordering or architecture mitigates it; this behavior should be assessed against the concrete need to distinguish modification of an existing object from creation or destruction. It may support a related workflow, but the question specifically requires the mechanism for distinguish modification of an existing object from creation or destruction rather than recognize a planned destroy-and-create operation rather than an in-place edit.

Question 184

The immediate Terraform task is to prevent the run from waiting for interactive variable input. Which method handles that task most directly?

  1. Use terraform apply -auto-approve for controlled automation
  2. Run terraform apply tfplan for an approved saved plan
  3. Use terraform apply -input=false in unattended execution
  4. Keep sensitive saved plans secure

Explanation

Correct Answer

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 prevent the run from waiting for interactive variable input. This directly supports the task to prevent the run from waiting for interactive variable input during a platform review.

Incorrect Answers

A:

The option removes the manual confirmation stage; it is not an alternative to reviewing changes, securing credentials, or verifying policies; this behavior should be assessed against the concrete need to prevent the run from waiting for interactive variable input. It may support a related workflow, but the question specifically requires the mechanism for prevent the run from waiting for interactive variable input rather than skip the interactive approval prompt when the pipeline already has gates.

B:

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 prevent the run from waiting for interactive variable input. The stated requirement is to prevent the run from waiting for interactive variable input, not to execute the exact plan artifact rather than replan with new input values; this alternative addresses a different control or phase.

D:

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 prevent the run from waiting for interactive variable input. The distinction matters here: using that mechanism to avoid leaking provider settings and input values through artifacts would still leave the objective to prevent the run from waiting for interactive variable input unmet.

Question 185

During an infrastructure audit, the team must accomplish all of these distinct aims: (1) recognize a guard against destructive changes while the resource block remains configured; (2) avoid deleting resources belonging to a different environment. Select exactly the two relevant mechanisms. Choose TWO.

  1. Check the selected workspace before destroying
  2. Understand prevent_destroy during planned deletion
  3. Use terraform destroy for a managed deployment
  4. Use terraform destroy -target=ADDRESS cautiously
  5. Understand cloud deletion protections
  6. Preserve required records before teardown

Explanation

Correct Answers

A:

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 recognize a guard against destructive changes while the resource block remains configured and avoid deleting resources belonging to a different environment. This matches the distinct objective to avoid deleting resources belonging to a different environment; the remaining chosen features address recognize a guard against destructive changes while the resource block remains configured.

B:

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 recognize a guard against destructive changes while the resource block remains configured and avoid deleting resources belonging to a different environment. This matches the distinct objective to recognize a guard against destructive changes while the resource block remains configured; the remaining chosen features address avoid deleting resources belonging to a different environment.

Incorrect Answers

C:

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 recognize a guard against destructive changes while the resource block remains configured and avoid deleting resources belonging to a different environment. Its main application is to plan and delete resources tracked by the current configuration and state; the checklist instead asks for recognize a guard against destructive changes while the resource block remains configured; and avoid deleting resources belonging to a different environment. None of those distinct criteria specifically calls for this alternative.

D:

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 recognize a guard against destructive changes while the resource block remains configured and avoid deleting resources belonging to a different environment. Its main application is to limit a teardown to a selected resource or dependency subset; the checklist instead asks for recognize a guard against destructive changes while the resource block remains configured; and avoid deleting resources belonging to a different environment. None of those distinct criteria specifically calls for this alternative.

E:

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 recognize a guard against destructive changes while the resource block remains configured and avoid deleting resources belonging to a different environment. Its main application is to distinguish provider API refusal from Terraform syntax issues; the checklist instead asks for recognize a guard against destructive changes while the resource block remains configured; and avoid deleting resources belonging to a different environment. None of those distinct criteria specifically calls for this alternative.

F:

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 recognize a guard against destructive changes while the resource block remains configured and avoid deleting resources belonging to a different environment. Its main application is to avoid assuming Terraform can restore deleted provider objects from state alone; the checklist instead asks for recognize a guard against destructive changes while the resource block remains configured; and avoid deleting resources belonging to a different environment. None of those distinct criteria specifically calls for this alternative.

Question 186

An engineer needs to rewrite Terraform files into canonical HCL style as part of a planned migration. Which option is the best fit?

  1. Run terraform fmt in the working directory
  2. Separate fmt from provider installation
  3. Run terraform fmt -check in CI
  4. Run terraform fmt -diff

Explanation

Correct Answer

A:

The formatter adjusts layout and spacing according to Terraform conventions; it does not modify remote infrastructure or update state; this behavior should be assessed against the concrete need to rewrite Terraform files into canonical HCL style. This directly supports the task to rewrite Terraform files into canonical HCL style during a maintenance request.

Incorrect Answers

B:

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 rewrite Terraform files into canonical HCL style. The distinction matters here: using that mechanism to avoid expecting style normalization to fetch plugin binaries would still leave the objective to rewrite Terraform files into canonical HCL style unmet.

C:

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 rewrite Terraform files into canonical HCL style. It may support a related workflow, but the question specifically requires the mechanism for rewrite Terraform files into canonical HCL style rather than detect files whose formatting differs from Terraform conventions.

D:

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 rewrite Terraform files into canonical HCL style. The stated requirement is to rewrite Terraform files into canonical HCL style, not to display the textual adjustments a formatter would make; this alternative addresses a different control or phase.

Question 187

An engineer needs to prepare backend, providers, and external module dependencies as part of an automated release. Which option is the best fit?

  1. Validate configuration before requesting a plan
  2. Avoid applying an outdated reviewed plan
  3. Use version control alongside the workflow
  4. Initialize the working directory before planning

Explanation

Correct Answer

D:

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. This directly supports the task to prepare backend, providers, and external module dependencies during an infrastructure audit.

Incorrect Answers

A:

Validation checks the HCL configuration against available schemas; it is useful in CI but cannot replace a plan based on actual state and provider data; this behavior should be assessed against the concrete need to prepare backend, providers, and external module dependencies. The stated requirement is to prepare backend, providers, and external module dependencies, not to identify structural issues early in a workflow; this alternative addresses a different control or phase.

B:

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. That can be useful when the aim is to ensure the approved actions still correspond to current state, but it does not directly deliver the requested ability to prepare backend, providers, and external module dependencies.

C:

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 prepare backend, providers, and external module dependencies. The distinction matters here: using that mechanism to make infrastructure edits traceable and reviewable would still leave the objective to prepare backend, providers, and external module dependencies unmet.

Question 188

A checked-out repository is being prepared on a new workstation. The requirement is to disallow interactive answers during initialization. Which Terraform mechanism directly meets this requirement?

  1. Reinitialize after adding a module source
  2. Use terraform init -backend-config=FILE
  3. Use terraform init -get=false
  4. Use terraform init -input=false in automation

Explanation

Correct Answer

D:

Noninteractive jobs fail instead of waiting for a prompt when required values cannot be supplied; this supports predictable CI behavior; this behavior should be assessed against the concrete need to disallow interactive answers during initialization. This directly supports the task to disallow interactive answers during initialization during a planned migration.

Incorrect Answers

A:

Init downloads module packages from their sources; merely declaring a module block does not put remote module code onto disk; this behavior should be assessed against the concrete need to disallow interactive answers during initialization. It may support a related workflow, but the question specifically requires the mechanism for disallow interactive answers during initialization rather than fetch externally sourced child module code.

B:

Partial backend configuration can be completed from a separate file; values supplied this way may still be recorded in local Terraform metadata or saved plans; this behavior should be assessed against the concrete need to disallow interactive answers during initialization. The stated requirement is to disallow interactive answers during initialization, not to supply missing backend settings during initialization; this alternative addresses a different control or phase.

C:

This option avoids module download/update during initialization; it is appropriate only when required modules are already available; this behavior should be assessed against the concrete need to disallow interactive answers during initialization. That can be useful when the aim is to skip installing child modules in a prepared directory, but it does not directly deliver the requested ability to disallow interactive answers during initialization.

Question 189

During a module implementation, one task is to obtain structured diagnostics in automation, while another is to detect proposed infrastructure differences as well as dynamic provider evaluations. Select the matching pair of techniques.

  1. Interpret a clean validate as limited assurance + Use terraform plan for state-dependent checking
  2. Run terraform validate -json for machine consumption + Use terraform plan for state-dependent checking
  3. Run terraform validate -json for machine consumption + Use variable validation for input contracts
  4. Check expression references for validity + Use preconditions for runtime assumptions

Explanation

Correct Answer

B:

For the first criterion, 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 obtain structured diagnostics in automation and detect proposed infrastructure differences as well as dynamic provider evaluations; this directly addresses the need to obtain structured diagnostics in automation. For the separate second criterion, 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 obtain structured diagnostics in automation and detect proposed infrastructure differences as well as dynamic provider evaluations; this fulfills the need to detect proposed infrastructure differences as well as dynamic provider evaluations. Together they cover the independent tasks of obtain structured diagnostics in automation and detect proposed infrastructure differences as well as dynamic provider evaluations without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the detect proposed infrastructure differences as well as dynamic provider evaluations requirement, but the first is designed for another concern: 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 obtain structured diagnostics in automation and detect proposed infrastructure differences as well as dynamic provider evaluations. That first component is designed to avoid inferring a successful future apply from successful static checks, which does not accomplish the requested task to obtain structured diagnostics in automation, even though the other measure satisfies detect proposed infrastructure differences as well as dynamic provider evaluations.

C:

The first measure meets the requirement to obtain structured diagnostics in automation, but its partner serves a different role: 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 obtain structured diagnostics in automation and detect proposed infrastructure differences as well as dynamic provider evaluations. That second component is designed to reject invalid user-supplied values with a targeted message, so the still-missing criterion is to detect proposed infrastructure differences as well as dynamic provider evaluations, while the first criterion remains obtain structured diagnostics in automation.

D:

The first measure is intended to catch references to undeclared blocks and invalid attributes where detectable: Terraform validates the structure of expressions against known configuration objects; values only resolved by providers may remain unknown until later phases; this behavior should be assessed against the concrete need to obtain structured diagnostics in automation and detect proposed infrastructure differences as well as dynamic provider evaluations. The second measure is intended to enforce environment-specific prerequisites that static validation cannot prove: A lifecycle precondition can validate context-dependent values before acting on a resource; a general syntax check alone cannot confirm runtime facts; this behavior should be assessed against the concrete need to obtain structured diagnostics in automation and detect proposed infrastructure differences as well as dynamic provider evaluations. Neither is the directly designated method for the separate goals of obtain structured diagnostics in automation and detect proposed infrastructure differences as well as dynamic provider evaluations in this review.

Question 190

A reviewer has to approve a two-part design: distinguish clean plans from plans with proposed changes in CI; additionally, load an explicit environment input file. Which option pairs the correct mechanisms?

  1. Use terraform plan -detailed-exitcode + Use terraform show tfplan
  2. Use terraform show -json tfplan + Run terraform plan without applying
  3. Use terraform plan -detailed-exitcode + Use terraform plan -var-file=env.tfvars
  4. Use terraform plan -out=tfplan + Use terraform plan -var-file=env.tfvars

Explanation

Correct Answer

C:

For the first criterion, 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 distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file; this directly addresses the need to distinguish clean plans from plans with proposed changes in CI. For the separate second criterion, an explicitly selected tfvars file feeds input values into that run; a .tfvars file is not a provider dependency lock; this behavior should be assessed against the concrete need to distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file; this fulfills the need to load an explicit environment input file. Together they cover the independent tasks of distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to distinguish clean plans from plans with proposed changes in CI, but its partner serves a different role: Show decodes the saved plan for review; it does not run the provider operations represented by the plan; this behavior should be assessed against the concrete need to distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file. That second component is designed to render a saved execution plan in readable form, so the still-missing criterion is to load an explicit environment input file, while the first criterion remains distinguish clean plans from plans with proposed changes in CI.

B:

The first measure is intended to export machine-readable plan details for a policy tool: 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 distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file. 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 distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file. Neither is the directly designated method for the separate goals of distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file in this review.

D:

The second measure does meet the load an explicit environment input file 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 distinguish clean plans from plans with proposed changes in CI and load an explicit environment input file. That first component is designed to save a plan for later explicit approval and application, which does not accomplish the requested task to distinguish clean plans from plans with proposed changes in CI, even though the other measure satisfies load an explicit environment input file.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests