HashiCorp Terraform Associate 004 (HashiCorp Certified: Terraform Associate (004)) Practice Test 41

Question 400

A change proposal relies on Remote backend locking capabilities for the task to select shared state storage with appropriate concurrency semantics. Which limitation specifically applies to it?

  1. A configuration-only validation step typically does not need to change state.
  2. Not every backend supports locking in the same way.
  3. Incorrectly breaking an active lock risks competing state modifications.
  4. Remote storage and locking are related but distinct capabilities.

Explanation

Correct Answer

D:

For Remote backend locking capabilities in the task to select shared state storage with appropriate concurrency semantics, the important caution is: Remote storage and locking are related but distinct capabilities. The reason this matters is its actual behavior: Supported remote backends can coordinate locking around updates to common state.

Incorrect Answers

A:

The proposed warning belongs to Lock acquisition before writes, which serves the different goal to avoid racing state mutations when several operators run Terraform, rather than to Remote backend locking capabilities: Terraform tries to obtain a state lock when the chosen backend supports it. The question concerns Remote backend locking capabilities acting to select shared state storage with appropriate concurrency semantics, not a limit of Lock acquisition before writes.

B:

The proposed warning belongs to Terraform state locking, which serves the different goal to prevent two concurrent runs from writing the same state snapshot, rather than to Remote backend locking capabilities: A backend with locking support serializes operations that could corrupt shared state. The question concerns Remote backend locking capabilities acting to select shared state storage with appropriate concurrency semantics, not a limit of Terraform state locking.

C:

The proposed warning belongs to terraform force-unlock, which serves the different goal to remove a stale lock only after confirming that no valid run owns it, rather than to Remote backend locking capabilities: force-unlock accepts a lock ID and bypasses normal waiting for an abandoned lock. The question concerns Remote backend locking capabilities acting to select shared state storage with appropriate concurrency semantics, not a limit of terraform force-unlock.

Question 401

Before adopting Module outputs with repeated instances to read values from every instance created by a counted or keyed module call, which statement sets an accurate boundary?

  1. A repeated module call is not the same value shape as a single module output object.
  2. Internal child locals and resource attributes remain encapsulated by default.
  3. An input declared in the child is not implicitly available as var.name in the parent.
  4. A variable with the same name in two modules is a separate declaration.
  5. They are not automatically exposed through a module output reference.

Explanation

Correct Answer

A:

For Module outputs with repeated instances in the task to read values from every instance created by a counted or keyed module call, the important caution is: A repeated module call is not the same value shape as a single module output object. The reason this matters is its actual behavior: Counted module outputs use numeric indices; for_each module outputs use instance keys.

Incorrect Answers

B:

The proposed warning belongs to Child module output scope, which serves the different goal to expose specific child values to its parent with an output block, rather than to Module outputs with repeated instances: The parent can use module.child.output_name only when the child explicitly declares that output. The question concerns Module outputs with repeated instances acting to read values from every instance created by a counted or keyed module call, not a limit of Child module output scope.

C:

The proposed warning belongs to Child module input variable, which serves the different goal to pass a caller-defined value into a reusable child module, rather than to Module outputs with repeated instances: The child declares a variable and the parent's module block assigns a value to that argument. The question concerns Module outputs with repeated instances acting to read values from every instance created by a counted or keyed module call, not a limit of Child module input variable.

D:

The proposed warning belongs to Root variable namespace, which serves the different goal to distinguish CLI-supplied root inputs from child inputs, rather than to Module outputs with repeated instances: CLI -var arguments set variables declared in the root module; child values pass through module call arguments. The question concerns Module outputs with repeated instances acting to read values from every instance created by a counted or keyed module call, not a limit of Root variable namespace.

E:

The proposed warning belongs to Module local values, which serves the different goal to compute module-specific intermediate values without exporting them, rather than to Module outputs with repeated instances: Local values belong to the defining module and are referenced through local.name in that scope. The question concerns Module outputs with repeated instances acting to read values from every instance created by a counted or keyed module call, not a limit of Module local values.

Question 402

A design uses HCP Terraform auditability to retain run and change history for collaboration and review. Which qualification applies to the named mechanism?

  1. Publishing a module is different from executing a workspace run.
  2. A recorded run history is not the same as versioned source code approval.
  3. The target provider and cloud identity federation must be configured correctly.
  4. Per-workspace values and precedence must be reviewed when there are overlaps.
  5. HCP Terraform health assessments require Standard or Premium edition and an eligible workspace; detection itself does not automatically correct drift.

Explanation

Correct Answer

B:

For HCP Terraform auditability in the task to retain run and change history for collaboration and review, the important caution is: A recorded run history is not the same as versioned source code approval. The reason this matters is its actual behavior: Workspace run histories help teams trace proposed and executed infrastructure operations.

Incorrect Answers

A:

The proposed warning belongs to HCP Terraform private module registry, which serves the different goal to share approved reusable modules within an organization, rather than to HCP Terraform auditability: A private registry distributes versioned modules to organization workspaces and teams. The question concerns HCP Terraform auditability acting to retain run and change history for collaboration and review, not a limit of HCP Terraform private module registry.

C:

The proposed warning belongs to HCP Terraform dynamic provider credentials, which serves the different goal to avoid long-lived static cloud credentials in workspace variables, rather than to HCP Terraform auditability: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. The question concerns HCP Terraform auditability acting to retain run and change history for collaboration and review, not a limit of HCP Terraform dynamic provider credentials.

D:

The proposed warning belongs to HCP Terraform variable sets, which serves the different goal to share reusable variables across selected workspaces, rather than to HCP Terraform auditability: Variable sets can provide common Terraform or environment variables to applicable workspaces. The question concerns HCP Terraform auditability acting to retain run and change history for collaboration and review, not a limit of HCP Terraform variable sets.

E:

The proposed warning belongs to HCP Terraform drift detection, which serves the different goal to monitor for resources that have diverged from workspace configuration, rather than to HCP Terraform auditability: Health assessments can identify drift between tracked resources and desired configuration. The question concerns HCP Terraform auditability acting to retain run and change history for collaboration and review, not a limit of HCP Terraform drift detection.

Question 403

A Terraform runbook describes the mechanism "Output block". Which responsibility should a reviewer associate with it?

  1. prompt for or provide a root-module value when no default exists
  2. name a computed expression used repeatedly inside one module
  3. expose a selected Terraform expression to the caller or CLI
  4. override environment or tfvars values with an explicit CLI variable flag
  5. load multiple variable assignments from a chosen tfvars file

Explanation

Correct Answer

C:

The practical result of Output block, used to expose a selected Terraform expression to the caller or CLI, is: An output block publishes a value from its module, such as an endpoint or resource identifier. A qualification for this effect is: Outputs do not automatically create an infrastructure object.

Incorrect Answers

A:

That outcome applies to Required input variable, intended to prompt for or provide a root-module value when no default exists, rather than the question's feature Output block: A variable block without a default requires a value supplied through a supported input channel. Unlike Required input variable, Output block is intended to expose a selected Terraform expression to the caller or CLI, not to prompt for or provide a root-module value when no default exists.

B:

That outcome applies to Local value expression, intended to name a computed expression used repeatedly inside one module, rather than the question's feature Output block: locals blocks evaluate named expressions available as local.name within that module. Unlike Local value expression, Output block is intended to expose a selected Terraform expression to the caller or CLI, not to name a computed expression used repeatedly inside one module.

D:

That outcome applies to Variable source precedence, intended to override environment or tfvars values with an explicit CLI variable flag, rather than the question's feature Output block: Direct -var and -var-file command-line assignments have precedence over automatically loaded values. Unlike Variable source precedence, Output block is intended to expose a selected Terraform expression to the caller or CLI, not to override environment or tfvars values with an explicit CLI variable flag.

E:

That outcome applies to Variable file input, intended to load multiple variable assignments from a chosen tfvars file, rather than the question's feature Output block: The -var-file flag passes root-module input values from a named variable definitions file. Unlike Variable file input, Output block is intended to expose a selected Terraform expression to the caller or CLI, not to load multiple variable assignments from a chosen tfvars file.

Question 404

A Terraform operator is specifically tasked to require approval before risky infrastructure changes. Which mechanism most directly meets this particular need?

  1. Repeatable environment provisioning
  2. Peer review for infrastructure
  3. Automated provisioning pipeline
  4. Version-controlled configuration history
  5. Consistent development and production patterns
  6. Change impact preview

Explanation

Correct Answer

B:

The task is to require approval before risky infrastructure changes; Peer review for infrastructure directly supports that requirement: Text configuration can be reviewed through a normal code review before an approved apply. Its relevant boundary is: Source approval does not replace inspecting the execution plan.

Incorrect Answers

A:

Repeatable environment provisioning is designed to recreate equivalent infrastructure patterns from one codebase, whereas this task is to require approval before risky infrastructure changes: Parameterizing reusable Terraform modules can provision consistent environment patterns repeatedly. Against Peer review for infrastructure, its limitation is: Differences in inputs and provider versions can still alter actual results.

C:

Automated provisioning pipeline is designed to replace repetitive click-by-click resource deployment with a pipeline, whereas this task is to require approval before risky infrastructure changes: A CI pipeline can run validation and planning before an authorized apply, reducing procedural inconsistency. Against Peer review for infrastructure, its limitation is: Automation must still control credentials and state concurrency.

D:

Version-controlled configuration history is designed to trace why infrastructure definitions changed, whereas this task is to require approval before risky infrastructure changes: Git commits and pull requests make configuration edits auditable before the next Terraform run. Against Peer review for infrastructure, its limitation is: A Git diff tracks source files rather than proving the exact live infrastructure state.

E:

Consistent development and production patterns is designed to reduce configuration drift across environments using shared modules, whereas this task is to require approval before risky infrastructure changes: Reusing modules with explicit inputs aligns infrastructure design while allowing intentional environment differences. Against Peer review for infrastructure, its limitation is: Sharing a module does not force all environments to use identical values.

F:

Change impact preview is designed to identify likely creations, updates, and deletions before execution, whereas this task is to require approval before risky infrastructure changes: Terraform planning exposes proposed operations for examination before they take effect. Against Peer review for infrastructure, its limitation is: A plan may include unknown attributes that are resolved only during apply.

Question 405

A deployment design calls for a supported way to inspect the latest state or a saved execution plan in readable form. Which mechanism most directly meets this particular need?

  1. terraform show
  2. terraform state show ADDRESS
  3. terraform show -json
  4. terraform state list

Explanation

Correct Answer

A:

The task is to inspect the latest state or a saved execution plan in readable form; terraform show directly supports that requirement: terraform show can display an existing state snapshot or a named plan file. Its relevant boundary is: It is not the same as running a fresh plan against current infrastructure.

Incorrect Answers

B:

terraform state show ADDRESS is designed to inspect stored attributes for one tracked resource instance, whereas this task is to inspect the latest state or a saved execution plan in readable form: state show presents the state representation of an addressed resource. Against terraform show, its limitation is: It does not perform an infrastructure change or show another resource automatically.

C:

terraform show -json is designed to export state or saved plan information in machine-readable form, whereas this task is to inspect the latest state or a saved execution plan in readable form: show -json emits detailed JSON for supported state and plan representations. Against terraform show, its limitation is: Sensitive values can appear in cleartext and output needs access controls.

D:

terraform state list is designed to enumerate Terraform resource addresses currently tracked in a state snapshot, whereas this task is to inspect the latest state or a saved execution plan in readable form: state list displays managed addresses and can be narrowed with address filters. Against terraform show, its limitation is: It does not enumerate every object in the cloud account.

Question 406

A Terraform rollout has two separate requirements: first, preserve locked provider selections in routine CI initialization; second, accept an intentional backend configuration change without migrating state. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Init provider plugin upgrade control; then use Backend migration during init.
  2. First use Module download on init; then use Backend reconfiguration during init.
  3. First use Backend reconfiguration during init; then use Init provider plugin upgrade control.
  4. First use Backend migration during init; then use Module download on init.
  5. First use Init provider plugin upgrade control; then use Backend reconfiguration during init.

Explanation

Correct Answer

E:

The first requirement, to preserve locked provider selections in routine CI initialization, is handled by Init provider plugin upgrade control: A normal terraform init honors the existing dependency lock selections unless update is requested. The second requirement, to accept an intentional backend configuration change without migrating state, is handled by Backend reconfiguration during init: terraform init -reconfigure disregards the existing backend initialization settings and uses new ones. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to preserve locked provider selections in routine CI initialization and accept an intentional backend configuration change without migrating state, the first candidate Init provider plugin upgrade control addresses preserve locked provider selections in routine CI initialization; the second candidate Backend migration during init addresses move existing state to a newly selected backend when changing its storage. This mapping fails because the second mechanism primarily supports the task to move existing state to a newly selected backend when changing its storage; the actual requirements are preserve locked provider selections in routine CI initialization first and accept an intentional backend configuration change without migrating state second.

B:

For the requested tasks to preserve locked provider selections in routine CI initialization and accept an intentional backend configuration change without migrating state, the first candidate Module download on init addresses install externally sourced child modules referenced by the root module; the second candidate Backend reconfiguration during init addresses accept an intentional backend configuration change without migrating state. This mapping fails because the first mechanism primarily supports the task to install externally sourced child modules referenced by the root module; the actual requirements are preserve locked provider selections in routine CI initialization first and accept an intentional backend configuration change without migrating state second.

C:

For the requested tasks to preserve locked provider selections in routine CI initialization and accept an intentional backend configuration change without migrating state, the first candidate Backend reconfiguration during init addresses accept an intentional backend configuration change without migrating state; the second candidate Init provider plugin upgrade control addresses preserve locked provider selections in routine CI initialization. This mapping fails because the first mechanism primarily supports the task to accept an intentional backend configuration change without migrating state and the second mechanism primarily supports the task to preserve locked provider selections in routine CI initialization; the actual requirements are preserve locked provider selections in routine CI initialization first and accept an intentional backend configuration change without migrating state second.

D:

For the requested tasks to preserve locked provider selections in routine CI initialization and accept an intentional backend configuration change without migrating state, the first candidate Backend migration during init addresses move existing state to a newly selected backend when changing its storage; the second candidate Module download on init addresses install externally sourced child modules referenced by the root module. This mapping fails because the first mechanism primarily supports the task to move existing state to a newly selected backend when changing its storage and the second mechanism primarily supports the task to install externally sourced child modules referenced by the root module; the actual requirements are preserve locked provider selections in routine CI initialization first and accept an intentional backend configuration change without migrating state second.

Question 407

A Terraform rollout has two separate requirements: first, select shared state storage with appropriate concurrency semantics; second, avoid racing state mutations when several operators run Terraform. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Remote backend locking capabilities; then use Lock acquisition before writes.
  2. First use Lock acquisition before writes; then use Remote backend locking capabilities.
  3. First use Remote backend locking capabilities; then use terraform force-unlock.
  4. First use terraform force-unlock; then use terraform -lock-timeout behavior.
  5. First use terraform -lock-timeout behavior; then use Lock acquisition before writes.

Explanation

Correct Answer

A:

The first requirement, to select shared state storage with appropriate concurrency semantics, is handled by Remote backend locking capabilities: Supported remote backends can coordinate locking around updates to common state. The second requirement, to avoid racing state mutations when several operators run Terraform, is handled by Lock acquisition before writes: Terraform tries to obtain a state lock when the chosen backend supports it. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

B:

For the requested tasks to select shared state storage with appropriate concurrency semantics and avoid racing state mutations when several operators run Terraform, the first candidate Lock acquisition before writes addresses avoid racing state mutations when several operators run Terraform; the second candidate Remote backend locking capabilities addresses select shared state storage with appropriate concurrency semantics. This mapping fails because the first mechanism primarily supports the task to avoid racing state mutations when several operators run Terraform and the second mechanism primarily supports the task to select shared state storage with appropriate concurrency semantics; the actual requirements are select shared state storage with appropriate concurrency semantics first and avoid racing state mutations when several operators run Terraform second.

C:

For the requested tasks to select shared state storage with appropriate concurrency semantics and avoid racing state mutations when several operators run Terraform, the first candidate Remote backend locking capabilities addresses select shared state storage with appropriate concurrency semantics; the second candidate terraform force-unlock addresses remove a stale lock only after confirming that no valid run owns it. This mapping fails because the second mechanism primarily supports the task to remove a stale lock only after confirming that no valid run owns it; the actual requirements are select shared state storage with appropriate concurrency semantics first and avoid racing state mutations when several operators run Terraform second.

D:

For the requested tasks to select shared state storage with appropriate concurrency semantics and avoid racing state mutations when several operators run Terraform, the first candidate terraform force-unlock addresses remove a stale lock only after confirming that no valid run owns it; the second candidate terraform -lock-timeout behavior addresses let a run wait briefly rather than fail immediately when state is busy. This mapping fails because the first mechanism primarily supports the task to remove a stale lock only after confirming that no valid run owns it and the second mechanism primarily supports the task to let a run wait briefly rather than fail immediately when state is busy; the actual requirements are select shared state storage with appropriate concurrency semantics first and avoid racing state mutations when several operators run Terraform second.

E:

For the requested tasks to select shared state storage with appropriate concurrency semantics and avoid racing state mutations when several operators run Terraform, the first candidate terraform -lock-timeout behavior addresses let a run wait briefly rather than fail immediately when state is busy; the second candidate Lock acquisition before writes addresses avoid racing state mutations when several operators run Terraform. This mapping fails because the first mechanism primarily supports the task to let a run wait briefly rather than fail immediately when state is busy; the actual requirements are select shared state storage with appropriate concurrency semantics first and avoid racing state mutations when several operators run Terraform second.

Question 408

The team is documenting risks of Output block while planning to expose a selected Terraform expression to the caller or CLI. Which caveat specifically applies to that mechanism?

  1. They are not root-module input variables and cannot be set with -var.
  2. The file supplies values but does not declare variable types.
  3. Outputs do not automatically create an infrastructure object.
  4. Input precedence does not grant the variable a new scope inside child modules.

Explanation

Correct Answer

C:

For Output block in the task to expose a selected Terraform expression to the caller or CLI, the important caution is: Outputs do not automatically create an infrastructure object. The reason this matters is its actual behavior: An output block publishes a value from its module, such as an endpoint or resource identifier.

Incorrect Answers

A:

The proposed warning belongs to Local value expression, which serves the different goal to name a computed expression used repeatedly inside one module, rather than to Output block: locals blocks evaluate named expressions available as local.name within that module. The question concerns Output block acting to expose a selected Terraform expression to the caller or CLI, not a limit of Local value expression.

B:

The proposed warning belongs to Variable file input, which serves the different goal to load multiple variable assignments from a chosen tfvars file, rather than to Output block: The -var-file flag passes root-module input values from a named variable definitions file. The question concerns Output block acting to expose a selected Terraform expression to the caller or CLI, not a limit of Variable file input.

D:

The proposed warning belongs to Variable source precedence, which serves the different goal to override environment or tfvars values with an explicit CLI variable flag, rather than to Output block: Direct -var and -var-file command-line assignments have precedence over automatically loaded values. The question concerns Output block acting to expose a selected Terraform expression to the caller or CLI, not a limit of Variable source precedence.

Question 409

A Terraform rollout has two separate requirements: first, read values from every instance created by a counted or keyed module call; second, expose specific child values to its parent with an output block. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Module outputs with repeated instances; then use Child module output scope.
  2. First use Root variable namespace; then use Module local values.
  3. First use Module outputs with repeated instances; then use Root variable namespace.
  4. First use Module local values; then use Child module output scope.
  5. First use Child module output scope; then use Module outputs with repeated instances.

Explanation

Correct Answer

A:

The first requirement, to read values from every instance created by a counted or keyed module call, is handled by Module outputs with repeated instances: Counted module outputs use numeric indices; for_each module outputs use instance keys. The second requirement, to expose specific child values to its parent with an output block, is handled by Child module output scope: The parent can use module.child.output_name only when the child explicitly declares that output. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

B:

For the requested tasks to read values from every instance created by a counted or keyed module call and expose specific child values to its parent with an output block, the first candidate Root variable namespace addresses distinguish CLI-supplied root inputs from child inputs; the second candidate Module local values addresses compute module-specific intermediate values without exporting them. This mapping fails because the first mechanism primarily supports the task to distinguish CLI-supplied root inputs from child inputs and the second mechanism primarily supports the task to compute module-specific intermediate values without exporting them; the actual requirements are read values from every instance created by a counted or keyed module call first and expose specific child values to its parent with an output block second.

C:

For the requested tasks to read values from every instance created by a counted or keyed module call and expose specific child values to its parent with an output block, the first candidate Module outputs with repeated instances addresses read values from every instance created by a counted or keyed module call; the second candidate Root variable namespace addresses distinguish CLI-supplied root inputs from child inputs. This mapping fails because the second mechanism primarily supports the task to distinguish CLI-supplied root inputs from child inputs; the actual requirements are read values from every instance created by a counted or keyed module call first and expose specific child values to its parent with an output block second.

D:

For the requested tasks to read values from every instance created by a counted or keyed module call and expose specific child values to its parent with an output block, the first candidate Module local values addresses compute module-specific intermediate values without exporting them; the second candidate Child module output scope addresses expose specific child values to its parent with an output block. This mapping fails because the first mechanism primarily supports the task to compute module-specific intermediate values without exporting them; the actual requirements are read values from every instance created by a counted or keyed module call first and expose specific child values to its parent with an output block second.

E:

For the requested tasks to read values from every instance created by a counted or keyed module call and expose specific child values to its parent with an output block, the first candidate Child module output scope addresses expose specific child values to its parent with an output block; the second candidate Module outputs with repeated instances addresses read values from every instance created by a counted or keyed module call. This mapping fails because the first mechanism primarily supports the task to expose specific child values to its parent with an output block and the second mechanism primarily supports the task to read values from every instance created by a counted or keyed module call; the actual requirements are read values from every instance created by a counted or keyed module call first and expose specific child values to its parent with an output block second.

Question 410

The implementation must both retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. HCP Terraform variable sets
  2. HCP Terraform teams and permissions
  3. HCP Terraform auditability
  4. HCP Terraform policy sets
  5. HCP Terraform private module registry

Explanation

Correct Answers

C:

Among the paired tasks to retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, HCP Terraform auditability serves the requirement to retain run and change history for collaboration and review: Workspace run histories help teams trace proposed and executed infrastructure operations. The other task must be covered by a separate mechanism.

D:

Among the paired tasks to retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, HCP Terraform policy sets serves the requirement to enforce organizational rules during infrastructure runs: HCP Terraform can evaluate governance policies such as Sentinel or OPA as part of run controls. The other task must be covered by a separate mechanism.

Incorrect Answers

A:

The requirements are retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, while HCP Terraform variable sets supports the different task to share reusable variables across selected workspaces: Variable sets can provide common Terraform or environment variables to applicable workspaces. That capability is outside the two selected responsibilities.

B:

The requirements are retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, while HCP Terraform teams and permissions supports the different task to grant workspace access based on collaboration responsibilities: Teams can be assigned appropriate workspace permissions for viewing, planning, and applying. That capability is outside the two selected responsibilities.

E:

The requirements are retain run and change history for collaboration and review and enforce organizational rules during infrastructure runs, while HCP Terraform private module registry supports the different task to share approved reusable modules within an organization: A private registry distributes versioned modules to organization workspaces and teams. That capability is outside the two selected responsibilities.

HashiCorp Certified: Terraform Associate (004) (Terraform Associate 004) Practice Tests