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

Question 230

A reviewer has to approve a two-part design: detect unsupported resource arguments or incorrect types; additionally, enforce environment-specific prerequisites that static validation cannot prove. Which option pairs the correct mechanisms?

  1. Recognize provider schema validation + Run terraform validate after init
  2. Run terraform validate -json for machine consumption + Use preconditions for runtime assumptions
  3. Recognize provider schema validation + Use preconditions for runtime assumptions
  4. Use terraform plan for state-dependent checking + Use preconditions for runtime assumptions
  5. Recognize provider schema validation + Check for missing required variable values at planning time
  6. Use terraform fmt -check for formatting enforcement + Interpret a clean validate as limited assurance

Explanation

Correct Answer

C:

For the first criterion, provider plugins supply schemas used for structural checking; passing validation does not mean the remote API will accept every eventual requested operation; this behavior should be assessed against the concrete need to detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove; this directly addresses the need to detect unsupported resource arguments or incorrect types. For the separate second criterion, 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 detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove; this fulfills the need to enforce environment-specific prerequisites that static validation cannot prove. Together they cover the independent tasks of detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to detect unsupported resource arguments or incorrect types, but its partner serves a different role: 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 detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. That second component is designed to check configuration consistency independently of managed infrastructure operations, so the still-missing criterion is to enforce environment-specific prerequisites that static validation cannot prove, while the first criterion remains detect unsupported resource arguments or incorrect types.

B:

The second measure does meet the enforce environment-specific prerequisites that static validation cannot prove requirement, but the first is designed for another concern: 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 detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. That first component is designed to obtain structured diagnostics in automation, which does not accomplish the requested task to detect unsupported resource arguments or incorrect types, even though the other measure satisfies enforce environment-specific prerequisites that static validation cannot prove.

D:

The second measure does meet the enforce environment-specific prerequisites that static validation cannot prove requirement, but the first is designed for another concern: 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 detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. That first component is designed to detect proposed infrastructure differences as well as dynamic provider evaluations, which does not accomplish the requested task to detect unsupported resource arguments or incorrect types, even though the other measure satisfies enforce environment-specific prerequisites that static validation cannot prove.

E:

The first measure meets the requirement to detect unsupported resource arguments or incorrect types, but its partner serves a different role: A variable declaration may be structurally valid even though a specific run has not supplied its required input; planning or applying requests those values when needed; this behavior should be assessed against the concrete need to detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. That second component is designed to understand why validation alone may pass with no values supplied, so the still-missing criterion is to enforce environment-specific prerequisites that static validation cannot prove, while the first criterion remains detect unsupported resource arguments or incorrect types.

F:

The first measure is intended to detect code style deviations without rewriting files: 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 detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. The second measure is intended to avoid inferring a successful future apply from successful static checks: 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 detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove. Neither is the directly designated method for the separate goals of detect unsupported resource arguments or incorrect types and enforce environment-specific prerequisites that static validation cannot prove in this review.

Question 231

A Terraform rollout has separate acceptance criteria: load an explicit environment input file and propose state reconciliation for external changes without correcting real resources. Which combined approach directly satisfies the two criteria?

  1. Use terraform plan -var-file=env.tfvars + Use terraform plan -refresh-only
  2. Use terraform plan -var='name=value' + Use terraform plan -refresh-only
  3. Use terraform plan -var-file=env.tfvars + Use terraform plan -detailed-exitcode
  4. Use terraform plan -replace=ADDRESS + Read ~ as in-place update intent

Explanation

Correct Answer

A:

For the first 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 load an explicit environment input file and propose state reconciliation for external changes without correcting real resources; this directly addresses the need to load an explicit environment input file. For the separate second criterion, 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 load an explicit environment input file and propose state reconciliation for external changes without correcting real resources; this fulfills the need to propose state reconciliation for external changes without correcting real resources. Together they cover the independent tasks of load an explicit environment input file and propose state reconciliation for external changes without correcting real resources without exchanging the responsibilities of these features.

Incorrect Answers

B:

The second measure does meet the propose state reconciliation for external changes without correcting real resources requirement, but the first is designed for another concern: 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 load an explicit environment input file and propose state reconciliation for external changes without correcting real resources. That first component is designed to override an input variable for one planned run, which does not accomplish the requested task to load an explicit environment input file, even though the other measure satisfies propose state reconciliation for external changes without correcting real resources.

C:

The first measure meets the requirement to load an explicit environment input file, but its partner serves a different role: 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 load an explicit environment input file and propose state reconciliation for external changes without correcting real resources. That second component is designed to distinguish clean plans from plans with proposed changes in CI, so the still-missing criterion is to propose state reconciliation for external changes without correcting real resources, while the first criterion remains load an explicit environment input file.

D:

The first measure is intended to request replacement of a particular managed instance: 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 load an explicit environment input file and propose state reconciliation for external changes without correcting real resources. The second measure is intended to distinguish modification of an existing object from creation or destruction: 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 load an explicit environment input file and propose state reconciliation for external changes without correcting real resources. Neither is the directly designated method for the separate goals of load an explicit environment input file and propose state reconciliation for external changes without correcting real resources in this review.

Question 232

An approved Terraform change must be executed safely. The team must both force a targeted resource to be replaced during an ordinary apply and prevent two runs from racing to write incompatible snapshots. Which paired choice implements those distinct goals?

  1. Use terraform apply -replace=ADDRESS for an intentional rebuild + Avoid concurrent applies against shared state
  2. Use terraform apply -input=false in unattended execution + Keep sensitive saved plans secure
  3. Use terraform apply -replace=ADDRESS for an intentional rebuild + Run terraform apply to execute current configuration
  4. Run a new plan after unexpected apply behavior + Avoid concurrent applies against shared state

Explanation

Correct Answer

A:

For the first criterion, 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 force a targeted resource to be replaced during an ordinary apply and prevent two runs from racing to write incompatible snapshots; this directly addresses the need to force a targeted resource to be replaced during an ordinary apply. For the separate second criterion, a locking-capable backend serializes state modifications; even with a lock, proper approvals and pipeline serialization remain important; this behavior should be assessed against the concrete need to force a targeted resource to be replaced during an ordinary apply and prevent two runs from racing to write incompatible snapshots; this fulfills the need to prevent two runs from racing to write incompatible snapshots. Together they cover the independent tasks of force a targeted resource to be replaced during an ordinary apply and prevent two runs from racing to write incompatible snapshots without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to prevent the run from waiting for interactive variable input: 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 force a targeted resource to be replaced during an ordinary apply and prevent two runs from racing to write incompatible snapshots. 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 force a targeted resource to be replaced during an ordinary apply and prevent two runs from racing to write incompatible snapshots. Neither is the directly designated method for the separate goals of force a targeted resource to be replaced during an ordinary apply and prevent two runs from racing to write incompatible snapshots in this review.

C:

The first measure meets the requirement to force a targeted resource to be replaced during an ordinary apply, but its partner serves a different role: Without a saved plan argument, apply creates a plan and normally requests approval before performing it; provider APIs then implement the proposed operations; this behavior should be assessed against the concrete need to force a targeted resource to be replaced during an ordinary apply and prevent two runs from racing to write incompatible snapshots. That second component is designed to generate and carry out the necessary actions for managed infrastructure, so the still-missing criterion is to prevent two runs from racing to write incompatible snapshots, while the first criterion remains force a targeted resource to be replaced during an ordinary apply.

D:

The second measure does meet the prevent two runs from racing to write incompatible snapshots requirement, but the first is designed for another concern: 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 force a targeted resource to be replaced during an ordinary apply and prevent two runs from racing to write incompatible snapshots. That first component is designed to reconcile the state and observed API results before taking further action, which does not accomplish the requested task to force a targeted resource to be replaced during an ordinary apply, even though the other measure satisfies prevent two runs from racing to write incompatible snapshots.

Question 233

A reviewer has to approve a two-part design: reselect newer eligible provider and module packages; additionally, skip backend initialization for a specific preparation task. Which option pairs the correct mechanisms?

  1. Run terraform init in the root module directory + Use terraform init -backend=false cautiously
  2. Use terraform init -upgrade + Use terraform init -backend=false cautiously
  3. Inspect .terraform/ as generated local metadata + Use terraform init -reconfigure
  4. Use terraform init -upgrade + Use terraform init -input=false in automation
  5. Use terraform init -backend-config=FILE + Use terraform init -backend=false cautiously

Explanation

Correct Answer

B:

For the first criterion, 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 and skip backend initialization for a specific preparation task; this directly addresses the need to reselect newer eligible provider and module packages. For the separate second criterion, 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 and skip backend initialization for a specific preparation task; this fulfills the need to skip backend initialization for a specific preparation task. Together they cover the independent tasks of reselect newer eligible provider and module packages and skip backend initialization for a specific preparation task without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the skip backend initialization for a specific preparation task requirement, but the first is designed for another concern: Init configures the selected backend and installs required providers and child modules; it is safe to repeat but may need additional flags after backend changes; this behavior should be assessed against the concrete need to reselect newer eligible provider and module packages and skip backend initialization for a specific preparation task. That first component is designed to initialize the working directory and fetch dependencies, which does not accomplish the requested task to reselect newer eligible provider and module packages, even though the other measure satisfies skip backend initialization for a specific preparation task.

C:

The first measure is intended to recognize initialization artifacts rather than versioned source: 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 and skip backend initialization for a specific preparation task. The second measure is intended to discard the previously remembered backend configuration without migrating state: 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 reselect newer eligible provider and module packages and skip backend initialization for a specific preparation task. Neither is the directly designated method for the separate goals of reselect newer eligible provider and module packages and skip backend initialization for a specific preparation task in this review.

D:

The first measure meets the requirement to reselect newer eligible provider and module packages, but its partner serves a different role: 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 reselect newer eligible provider and module packages and skip backend initialization for a specific preparation task. That second component is designed to disallow interactive answers during initialization, so the still-missing criterion is to skip backend initialization for a specific preparation task, while the first criterion remains reselect newer eligible provider and module packages.

E:

The second measure does meet the skip backend initialization for a specific preparation task requirement, but the first is designed for another concern: 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 reselect newer eligible provider and module packages and skip backend initialization for a specific preparation task. That first component is designed to supply missing backend settings during initialization, which does not accomplish the requested task to reselect newer eligible provider and module packages, even though the other measure satisfies skip backend initialization for a specific preparation task.

Question 234

A Terraform rollout has separate acceptance criteria: check configuration consistency independently of managed infrastructure operations and detect code style deviations without rewriting files. Which combined approach directly satisfies the two criteria?

  1. Run terraform validate -json for machine consumption + Interpret a clean validate as limited assurance
  2. Check for missing required variable values at planning time + Use terraform fmt -check for formatting enforcement
  3. Run terraform validate after init + Use terraform fmt -check for formatting enforcement
  4. Run terraform validate after init + Check expression references for validity
  5. Use terraform plan for state-dependent checking + Use terraform fmt -check for formatting enforcement
  6. Run terraform validate after init + Recognize provider schema validation

Explanation

Correct Answer

C:

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 detect code style deviations without rewriting files; this directly addresses the need to check configuration consistency independently of managed infrastructure operations. For the separate second criterion, 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 detect code style deviations without rewriting files; this fulfills the need to detect code style deviations without rewriting files. Together they cover the independent tasks of check configuration consistency independently of managed infrastructure operations and detect code style deviations without rewriting files without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure is intended to obtain structured diagnostics in automation: 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 detect code style deviations without rewriting files. The second measure is intended to avoid inferring a successful future apply from successful static checks: 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 detect code style deviations without rewriting files. Neither is the directly designated method for the separate goals of check configuration consistency independently of managed infrastructure operations and detect code style deviations without rewriting files in this review.

B:

The second measure does meet the detect code style deviations without rewriting files requirement, but the first is designed for another concern: A variable declaration may be structurally valid even though a specific run has not supplied its required input; planning or applying requests those values when needed; this behavior should be assessed against the concrete need to check configuration consistency independently of managed infrastructure operations and detect code style deviations without rewriting files. That first component is designed to understand why validation alone may pass with no values supplied, which does not accomplish the requested task to check configuration consistency independently of managed infrastructure operations, even though the other measure satisfies detect code style deviations without rewriting files.

D:

The first measure meets the requirement to check configuration consistency independently of managed infrastructure operations, but its partner serves a different role: 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 check configuration consistency independently of managed infrastructure operations and detect code style deviations without rewriting files. That second component is designed to catch references to undeclared blocks and invalid attributes where detectable, so the still-missing criterion is to detect code style deviations without rewriting files, while the first criterion remains check configuration consistency independently of managed infrastructure operations.

E:

The second measure does meet the detect code style deviations without rewriting files requirement, but the first is designed for another concern: 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 detect code style deviations without rewriting files. That first component is designed to detect proposed infrastructure differences as well as dynamic provider evaluations, which does not accomplish the requested task to check configuration consistency independently of managed infrastructure operations, even though the other measure satisfies detect code style deviations without rewriting files.

F:

The first measure meets the requirement to check configuration consistency independently of managed infrastructure operations, but its partner serves a different role: Provider plugins supply schemas used for structural checking; passing validation does not mean the remote API will accept every eventual requested operation; this behavior should be assessed against the concrete need to check configuration consistency independently of managed infrastructure operations and detect code style deviations without rewriting files. That second component is designed to detect unsupported resource arguments or incorrect types, so the still-missing criterion is to detect code style deviations without rewriting files, while the first criterion remains check configuration consistency independently of managed infrastructure operations.

Question 235

An operator is preparing a controlled Terraform change. The team must both request replacement of a particular managed instance and omit the usual state refresh while creating an ordinary plan. Which paired choice implements those distinct goals?

  1. Understand a (known after apply) value + Use terraform show tfplan
  2. Use terraform plan -replace=ADDRESS + Use terraform plan -detailed-exitcode
  3. Use terraform plan -out=tfplan + Use terraform plan -refresh=false carefully
  4. Use terraform plan -replace=ADDRESS + Use terraform plan -refresh=false carefully

Explanation

Correct Answer

D:

For the first criterion, 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 request replacement of a particular managed instance and omit the usual state refresh while creating an ordinary plan; this directly addresses the need to request replacement of a particular managed instance. For the separate second criterion, skipping remote refresh can produce an inaccurate plan when out-of-band changes have occurred; it is not a drift-detection strategy; this behavior should be assessed against the concrete need to request replacement of a particular managed instance and omit the usual state refresh while creating an ordinary plan; this fulfills the need to omit the usual state refresh while creating an ordinary plan. Together they cover the independent tasks of request replacement of a particular managed instance and omit the usual state refresh while creating an ordinary plan without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure is intended to interpret an attribute whose value is not available during planning: Computed provider attributes may be unknown until resource creation; terraform carries unknown values through dependent expressions rather than fabricating them; this behavior should be assessed against the concrete need to request replacement of a particular managed instance and omit the usual state refresh while creating an ordinary plan. The second measure is intended to render a saved execution plan in readable form: 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 request replacement of a particular managed instance and omit the usual state refresh while creating an ordinary plan. Neither is the directly designated method for the separate goals of request replacement of a particular managed instance and omit the usual state refresh while creating an ordinary plan in this review.

B:

The first measure meets the requirement to request replacement of a particular managed instance, but its partner serves a different role: 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 request replacement of a particular managed instance and omit the usual state refresh while creating an ordinary plan. That second component is designed to distinguish clean plans from plans with proposed changes in CI, so the still-missing criterion is to omit the usual state refresh while creating an ordinary plan, while the first criterion remains request replacement of a particular managed instance.

C:

The second measure does meet the omit the usual state refresh while creating an ordinary plan 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 request replacement of a particular managed instance and omit the usual state refresh while creating an ordinary plan. That first component is designed to save a plan for later explicit approval and application, which does not accomplish the requested task to request replacement of a particular managed instance, even though the other measure satisfies omit the usual state refresh while creating an ordinary plan.

Question 236

An engineer is deciding how to apply a previously saved plan. Two independent changes are requested: first, generate and carry out the necessary actions for managed infrastructure; second, skip the interactive approval prompt when the pipeline already has gates. Which pair of measures fulfills both?

  1. Run terraform apply to execute current configuration + Avoid concurrent applies against shared state
  2. Run a new plan after unexpected apply behavior + Use terraform apply -auto-approve for controlled automation
  3. Use terraform apply -replace=ADDRESS for an intentional rebuild + Run terraform apply tfplan for an approved saved plan
  4. Run terraform apply to execute current configuration + Use terraform apply -auto-approve for controlled automation

Explanation

Correct Answer

D:

For the first criterion, without a saved plan argument, apply creates a plan and normally requests approval before performing it; provider APIs then implement the proposed operations; this behavior should be assessed against the concrete need to generate and carry out the necessary actions for managed infrastructure and skip the interactive approval prompt when the pipeline already has gates; this directly addresses the need to generate and carry out the necessary actions for managed infrastructure. For the separate second criterion, 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 generate and carry out the necessary actions for managed infrastructure and skip the interactive approval prompt when the pipeline already has gates; this fulfills the need to skip the interactive approval prompt when the pipeline already has gates. Together they cover the independent tasks of generate and carry out the necessary actions for managed infrastructure and skip the interactive approval prompt when the pipeline already has gates without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to generate and carry out the necessary actions for managed infrastructure, but its partner serves a different role: A locking-capable backend serializes state modifications; even with a lock, proper approvals and pipeline serialization remain important; this behavior should be assessed against the concrete need to generate and carry out the necessary actions for managed infrastructure and skip the interactive approval prompt when the pipeline already has gates. That second component is designed to prevent two runs from racing to write incompatible snapshots, so the still-missing criterion is to skip the interactive approval prompt when the pipeline already has gates, while the first criterion remains generate and carry out the necessary actions for managed infrastructure.

B:

The second measure does meet the skip the interactive approval prompt when the pipeline already has gates requirement, but the first is designed for another concern: 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 generate and carry out the necessary actions for managed infrastructure and skip the interactive approval prompt when the pipeline already has gates. That first component is designed to reconcile the state and observed API results before taking further action, which does not accomplish the requested task to generate and carry out the necessary actions for managed infrastructure, even though the other measure satisfies skip the interactive approval prompt when the pipeline already has gates.

C:

The first measure is intended to force a targeted resource to be replaced during an ordinary apply: 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 generate and carry out the necessary actions for managed infrastructure and skip the interactive approval prompt when the pipeline already has gates. The second 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 generate and carry out the necessary actions for managed infrastructure and skip the interactive approval prompt when the pipeline already has gates. Neither is the directly designated method for the separate goals of generate and carry out the necessary actions for managed infrastructure and skip the interactive approval prompt when the pipeline already has gates in this review.

Question 237

A Terraform rollout has separate acceptance criteria: initialize the working directory and fetch dependencies and copy existing state when changing storage backends. Which combined approach directly satisfies the two criteria?

  1. Use terraform init -lockfile=readonly + Use terraform init -migrate-state
  2. Run terraform init in the root module directory + Use terraform init -migrate-state
  3. Run terraform init in the root module directory + Use terraform init -reconfigure
  4. Inspect .terraform/ as generated local metadata + Use terraform init -migrate-state
  5. Use terraform init -backend=false cautiously + Use terraform init -get=false

Explanation

Correct Answer

B:

For the first criterion, init configures the selected backend and installs required providers and child modules; it is safe to repeat but may need additional flags after backend changes; this behavior should be assessed against the concrete need to initialize the working directory and fetch dependencies and copy existing state when changing storage backends; this directly addresses the need to initialize the working directory and fetch dependencies. For the separate second criterion, 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 initialize the working directory and fetch dependencies and copy existing state when changing storage backends; this fulfills the need to copy existing state when changing storage backends. Together they cover the independent tasks of initialize the working directory and fetch dependencies and copy existing state when changing storage backends without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the copy existing state when changing storage backends requirement, but the first is designed for another concern: 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 initialize the working directory and fetch dependencies and copy existing state when changing storage backends. That first component is designed to enforce a committed provider selection without lockfile edits, which does not accomplish the requested task to initialize the working directory and fetch dependencies, even though the other measure satisfies copy existing state when changing storage backends.

C:

The first measure meets the requirement to initialize the working directory and fetch dependencies, but its partner serves a different role: 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 initialize the working directory and fetch dependencies and copy existing state when changing storage backends. That second component is designed to discard the previously remembered backend configuration without migrating state, so the still-missing criterion is to copy existing state when changing storage backends, while the first criterion remains initialize the working directory and fetch dependencies.

D:

The second measure does meet the copy existing state when changing storage backends requirement, but the first is designed for another concern: 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 initialize the working directory and fetch dependencies and copy existing state when changing storage backends. That first component is designed to recognize initialization artifacts rather than versioned source, which does not accomplish the requested task to initialize the working directory and fetch dependencies, even though the other measure satisfies copy existing state when changing storage backends.

E:

The first measure is intended to skip backend initialization for a specific preparation task: 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 initialize the working directory and fetch dependencies and copy existing state when changing storage backends. The second measure is intended to skip installing child modules in a prepared directory: 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 initialize the working directory and fetch dependencies and copy existing state when changing storage backends. Neither is the directly designated method for the separate goals of initialize the working directory and fetch dependencies and copy existing state when changing storage backends in this review.

Question 238

A CI pipeline must archive reviewable execution decisions. Two independent changes are requested: first, preview the actions needed to reconcile the declared configuration; second, render a saved execution plan in readable form. Which pair of measures fulfills both?

  1. Run terraform plan without applying + Use terraform show tfplan
  2. Run terraform plan without applying + Use terraform show -json tfplan
  3. Read ~ as in-place update intent + Use terraform show tfplan
  4. Run terraform plan without applying + Understand a (known after apply) value
  5. Use terraform plan -refresh=false carefully + Use terraform show tfplan
  6. Use terraform plan -var-file=env.tfvars + Use terraform plan -var='name=value'

Explanation

Correct Answer

A:

For the first criterion, 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 preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form; this directly addresses the need to preview the actions needed to reconcile the declared configuration. For the separate second criterion, 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 preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form; this fulfills the need to render a saved execution plan in readable form. Together they cover the independent tasks of preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure meets the requirement to preview the actions needed to reconcile the declared configuration, but its partner serves a different role: 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 preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form. That second component is designed to export machine-readable plan details for a policy tool, so the still-missing criterion is to render a saved execution plan in readable form, while the first criterion remains preview the actions needed to reconcile the declared configuration.

C:

The second measure does meet the render a saved execution plan in readable form requirement, but the first is designed for another concern: 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 preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form. That first component is designed to distinguish modification of an existing object from creation or destruction, which does not accomplish the requested task to preview the actions needed to reconcile the declared configuration, even though the other measure satisfies render a saved execution plan in readable form.

D:

The first measure meets the requirement to preview the actions needed to reconcile the declared configuration, but its partner serves a different role: Computed provider attributes may be unknown until resource creation; terraform carries unknown values through dependent expressions rather than fabricating them; this behavior should be assessed against the concrete need to preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form. That second component is designed to interpret an attribute whose value is not available during planning, so the still-missing criterion is to render a saved execution plan in readable form, while the first criterion remains preview the actions needed to reconcile the declared configuration.

E:

The second measure does meet the render a saved execution plan in readable form requirement, but the first is designed for another concern: Skipping remote refresh can produce an inaccurate plan when out-of-band changes have occurred; it is not a drift-detection strategy; this behavior should be assessed against the concrete need to preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form. That first component is designed to omit the usual state refresh while creating an ordinary plan, which does not accomplish the requested task to preview the actions needed to reconcile the declared configuration, even though the other measure satisfies render a saved execution plan in readable form.

F:

The first measure is intended to load an explicit environment input file: 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 preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form. The second measure is intended to override an input variable for one planned run: 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 preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form. Neither is the directly designated method for the separate goals of preview the actions needed to reconcile the declared configuration and render a saved execution plan in readable form in this review.

Question 239

A deployment script must avoid unintended interactive prompts. A reviewer must determine how to understand why an unsuccessful apply may still have changed some resources. Which action is the appropriate choice?

  1. Use terraform apply -var-file=prod.tfvars
  2. Run terraform apply tfplan for an approved saved plan
  3. Use terraform apply -input=false in unattended execution
  4. Check apply output for partial failure

Explanation

Correct Answer

D:

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 understand why an unsuccessful apply may still have changed some resources. This directly supports the task to understand why an unsuccessful apply may still have changed some resources during a cross-team handoff.

Incorrect Answers

A:

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 understand why an unsuccessful apply may still have changed some resources. The stated requirement is to understand why an unsuccessful apply may still have changed some resources, not to supply planned environment-specific input values in a direct apply; this alternative addresses a different control or phase.

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 understand why an unsuccessful apply may still have changed some resources. That can be useful when the aim is to execute the exact plan artifact rather than replan with new input values, but it does not directly deliver the requested ability to understand why an unsuccessful apply may still have changed some resources.

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 understand why an unsuccessful apply may still have changed some resources. The distinction matters here: using that mechanism to prevent the run from waiting for interactive variable input would still leave the objective to understand why an unsuccessful apply may still have changed some resources unmet.

Question 240

A checked-out repository is being prepared on a new workstation. The team must both enforce a committed provider selection without lockfile edits and fetch externally sourced child module code. Which paired choice implements those distinct goals?

  1. Run terraform init in the root module directory + Reinitialize after adding a module source
  2. Use terraform init -migrate-state + Use terraform init -backend-config=FILE
  3. Use terraform init -reconfigure + Reinitialize after adding a module source
  4. Use terraform init -lockfile=readonly + Reinitialize after adding a module source
  5. Use terraform init -lockfile=readonly + Use terraform init -input=false in automation

Explanation

Correct Answer

D:

For the first criterion, 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 enforce a committed provider selection without lockfile edits and fetch externally sourced child module code; this directly addresses the need to enforce a committed provider selection without lockfile edits. For the separate second criterion, 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 enforce a committed provider selection without lockfile edits and fetch externally sourced child module code; this fulfills the need to fetch externally sourced child module code. Together they cover the independent tasks of enforce a committed provider selection without lockfile edits and fetch externally sourced child module code without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the fetch externally sourced child module code requirement, but the first is designed for another concern: Init configures the selected backend and installs required providers and child modules; it is safe to repeat but may need additional flags after backend changes; this behavior should be assessed against the concrete need to enforce a committed provider selection without lockfile edits and fetch externally sourced child module code. That first component is designed to initialize the working directory and fetch dependencies, which does not accomplish the requested task to enforce a committed provider selection without lockfile edits, even though the other measure satisfies fetch externally sourced child module code.

B:

The first measure is intended to copy existing state when changing storage backends: 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 enforce a committed provider selection without lockfile edits and fetch externally sourced child module code. The second measure is intended to supply missing backend settings during initialization: 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 enforce a committed provider selection without lockfile edits and fetch externally sourced child module code. Neither is the directly designated method for the separate goals of enforce a committed provider selection without lockfile edits and fetch externally sourced child module code in this review.

C:

The second measure does meet the fetch externally sourced child module code requirement, but the first is designed for another concern: 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 enforce a committed provider selection without lockfile edits and fetch externally sourced child module code. That first component is designed to discard the previously remembered backend configuration without migrating state, which does not accomplish the requested task to enforce a committed provider selection without lockfile edits, even though the other measure satisfies fetch externally sourced child module code.

E:

The first measure meets the requirement to enforce a committed provider selection without lockfile edits, but its partner serves a different role: 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 enforce a committed provider selection without lockfile edits and fetch externally sourced child module code. That second component is designed to disallow interactive answers during initialization, so the still-missing criterion is to fetch externally sourced child module code, while the first criterion remains enforce a committed provider selection without lockfile edits.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests