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

Question 370

A design uses Lock identifier verification to identify the precise stale lock before taking exceptional recovery action. Which qualification applies to the named mechanism?

  1. Guessing an ID or acting during an active deployment can corrupt coordination.
  2. It does not itself activate locking on a backend that lacks that feature.
  3. -lock=false makes concurrent writers potentially unsafe.
  4. Remote storage and locking are related but distinct capabilities.

Explanation

Correct Answer

A:

For Lock identifier verification in the task to identify the precise stale lock before taking exceptional recovery action, the important caution is: Guessing an ID or acting during an active deployment can corrupt coordination. The reason this matters is its actual behavior: A lock ID should be matched to the blocked state operation before unlocking.

Incorrect Answers

B:

The proposed warning belongs to terraform -lock-timeout behavior, which serves the different goal to let a run wait briefly rather than fail immediately when state is busy, rather than to Lock identifier verification: The lock-timeout flag controls how long supported operations retry obtaining a lock. The question concerns Lock identifier verification acting to identify the precise stale lock before taking exceptional recovery action, not a limit of terraform -lock-timeout behavior.

C:

The proposed warning belongs to Avoid disabling state locks, which serves the different goal to protect shared state rather than using -lock=false as a routine workaround, rather than to Lock identifier verification: Using a lock-capable backend with normal locking reduces state races. The question concerns Lock identifier verification acting to identify the precise stale lock before taking exceptional recovery action, not a limit of Avoid disabling state locks.

D:

The proposed warning belongs to Remote backend locking capabilities, which serves the different goal to select shared state storage with appropriate concurrency semantics, rather than to Lock identifier verification: Supported remote backends can coordinate locking around updates to common state. The question concerns Lock identifier verification acting to identify the precise stale lock before taking exceptional recovery action, not a limit of Remote backend locking capabilities.

Question 371

A Terraform runbook describes the mechanism "Repeatable environment provisioning". Which responsibility should a reviewer associate with it?

  1. make infrastructure dependencies understandable from code
  2. reduce configuration drift across environments using shared modules
  3. recreate equivalent infrastructure patterns from one codebase
  4. identify likely creations, updates, and deletions before execution

Explanation

Correct Answer

C:

The practical result of Repeatable environment provisioning, used to recreate equivalent infrastructure patterns from one codebase, is: Parameterizing reusable Terraform modules can provision consistent environment patterns repeatedly. A qualification for this effect is: Differences in inputs and provider versions can still alter actual results.

Incorrect Answers

A:

That outcome applies to Self-documenting resource relationships, intended to make infrastructure dependencies understandable from code, rather than the question's feature Repeatable environment provisioning: Resource references and explicit dependencies can express how objects relate without relying on tribal knowledge. Unlike Self-documenting resource relationships, Repeatable environment provisioning is intended to recreate equivalent infrastructure patterns from one codebase, not to make infrastructure dependencies understandable from code.

B:

That outcome applies to Consistent development and production patterns, intended to reduce configuration drift across environments using shared modules, rather than the question's feature Repeatable environment provisioning: Reusing modules with explicit inputs aligns infrastructure design while allowing intentional environment differences. Unlike Consistent development and production patterns, Repeatable environment provisioning is intended to recreate equivalent infrastructure patterns from one codebase, not to reduce configuration drift across environments using shared modules.

D:

That outcome applies to Change impact preview, intended to identify likely creations, updates, and deletions before execution, rather than the question's feature Repeatable environment provisioning: Terraform planning exposes proposed operations for examination before they take effect. Unlike Change impact preview, Repeatable environment provisioning is intended to recreate equivalent infrastructure patterns from one codebase, not to identify likely creations, updates, and deletions before execution.

Question 372

The team is documenting risks of Module input defaults while planning to make some child module arguments optional for callers. Which caveat specifically applies to that mechanism?

  1. A repeated module call is not the same value shape as a single module output object.
  2. They are not automatically exposed through a module output reference.
  3. An aliased provider is not automatically inherited as a child alias.
  4. An input declared in the child is not implicitly available as var.name in the parent.
  5. A default does not override an explicitly passed module argument.

Explanation

Correct Answer

E:

For Module input defaults in the task to make some child module arguments optional for callers, the important caution is: A default does not override an explicitly passed module argument. The reason this matters is its actual behavior: A child variable with a default can be omitted by the caller, allowing the child to use its fallback.

Incorrect Answers

A:

The proposed warning belongs to Module outputs with repeated instances, which serves the different goal to read values from every instance created by a counted or keyed module call, rather than to Module input defaults: Counted module outputs use numeric indices; for_each module outputs use instance keys. The question concerns Module input defaults acting to make some child module arguments optional for callers, not a limit of Module outputs with repeated instances.

B:

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 input defaults: Local values belong to the defining module and are referenced through local.name in that scope. The question concerns Module input defaults acting to make some child module arguments optional for callers, not a limit of Module local values.

C:

The proposed warning belongs to Provider configuration scope, which serves the different goal to keep provider instances configured in the root and pass them to child modules, rather than to Module input defaults: A root module can explicitly map provider configurations into child module calls. The question concerns Module input defaults acting to make some child module arguments optional for callers, not a limit of Provider configuration scope.

D:

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 input defaults: The child declares a variable and the parent's module block assigns a value to that argument. The question concerns Module input defaults acting to make some child module arguments optional for callers, not a limit of Child module input variable.

Question 373

The rollout owner asks whether HCP Terraform dynamic provider credentials is sufficient to avoid long-lived static cloud credentials in workspace variables. Which limitation specifically concerns that mechanism?

  1. The target provider and cloud identity federation must be configured correctly.
  2. Per-workspace values and precedence must be reviewed when there are overlaps.
  3. Team permission management requires a supported paid HCP Terraform edition; these roles do not replace cloud-provider permissions.
  4. Publishing a module is different from executing a workspace run.
  5. Policies assess plans or configuration; they are not Terraform resource providers.

Explanation

Correct Answer

A:

For HCP Terraform dynamic provider credentials in the task to avoid long-lived static cloud credentials in workspace variables, the important caution is: The target provider and cloud identity federation must be configured correctly. The reason this matters is its actual behavior: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration.

Incorrect Answers

B:

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 dynamic provider credentials: Variable sets can provide common Terraform or environment variables to applicable workspaces. The question concerns HCP Terraform dynamic provider credentials acting to avoid long-lived static cloud credentials in workspace variables, not a limit of HCP Terraform variable sets.

C:

The proposed warning belongs to HCP Terraform teams and permissions, which serves the different goal to grant workspace access based on collaboration responsibilities, rather than to HCP Terraform dynamic provider credentials: Teams can be assigned appropriate workspace permissions for viewing, planning, and applying. The question concerns HCP Terraform dynamic provider credentials acting to avoid long-lived static cloud credentials in workspace variables, not a limit of HCP Terraform teams and permissions.

D:

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 dynamic provider credentials: A private registry distributes versioned modules to organization workspaces and teams. The question concerns HCP Terraform dynamic provider credentials acting to avoid long-lived static cloud credentials in workspace variables, not a limit of HCP Terraform private module registry.

E:

The proposed warning belongs to HCP Terraform policy sets, which serves the different goal to enforce organizational rules during infrastructure runs, rather than to HCP Terraform dynamic provider credentials: HCP Terraform can evaluate governance policies such as Sentinel or OPA as part of run controls. The question concerns HCP Terraform dynamic provider credentials acting to avoid long-lived static cloud credentials in workspace variables, not a limit of HCP Terraform policy sets.

Question 374

A Terraform runbook describes the mechanism "terraform state show ADDRESS". Which responsibility should a reviewer associate with it?

  1. inspect stored attributes for one tracked resource instance
  2. retrieve the current backend state snapshot as serialized JSON
  3. locate a relevant module or resource without reading every tracked address
  4. display declared root output values from the current state

Explanation

Correct Answer

A:

The practical result of terraform state show ADDRESS, used to inspect stored attributes for one tracked resource instance, is: state show presents the state representation of an addressed resource. A qualification for this effect is: It does not perform an infrastructure change or show another resource automatically.

Incorrect Answers

B:

That outcome applies to terraform state pull, intended to retrieve the current backend state snapshot as serialized JSON, rather than the question's feature terraform state show ADDRESS: state pull reads state from the configured backend for inspection or backup handling. Unlike terraform state pull, terraform state show ADDRESS is intended to inspect stored attributes for one tracked resource instance, not to retrieve the current backend state snapshot as serialized JSON.

C:

That outcome applies to Address filter for state list, intended to locate a relevant module or resource without reading every tracked address, rather than the question's feature terraform state show ADDRESS: state list accepts optional address patterns to narrow visible resources. Unlike Address filter for state list, terraform state show ADDRESS is intended to inspect stored attributes for one tracked resource instance, not to locate a relevant module or resource without reading every tracked address.

D:

That outcome applies to terraform output, intended to display declared root output values from the current state, rather than the question's feature terraform state show ADDRESS: output reads named output values and can provide -json for structured automation. Unlike terraform output, terraform state show ADDRESS is intended to inspect stored attributes for one tracked resource instance, not to display declared root output values from the current state.

Question 375

Before continuing an infrastructure rollout, the operator must name a computed expression used repeatedly inside one module. Which mechanism most directly meets this particular need?

  1. Variable type constraint
  2. Variable default value
  3. Local value expression
  4. Output block

Explanation

Correct Answer

C:

The task is to name a computed expression used repeatedly inside one module; Local value expression directly supports that requirement: locals blocks evaluate named expressions available as local.name within that module. Its relevant boundary is: They are not root-module input variables and cannot be set with -var.

Incorrect Answers

A:

Variable type constraint is designed to restrict an input to an expected Terraform type, whereas this task is to name a computed expression used repeatedly inside one module: A type declaration such as number or object(...) lets Terraform validate and convert compatible inputs. Against Local value expression, its limitation is: Type declarations are different from custom semantic validation rules.

B:

Variable default value is designed to give a module input a fallback when callers omit it, whereas this task is to name a computed expression used repeatedly inside one module: A variable default supplies a value without requiring each caller to pass that argument. Against Local value expression, its limitation is: Explicit callers can override the default with their own value.

D:

Output block addresses the different requirement to expose a selected Terraform expression to the caller or CLI: An output block publishes a value from its module, such as an endpoint or resource identifier; this does not by itself satisfy the requested task to name a computed expression used repeatedly inside one module. For the stated need, Local value expression is the more direct mechanism.

Question 376

A Terraform rollout has two separate requirements: first, work on configuration validation while deliberately skipping backend initialization; second, prepare backend and plugin dependencies before planning. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Init without backend setup; then use Backend reconfiguration during init.
  2. First use Initialize a new working directory; then use Init without backend setup.
  3. First use Backend reconfiguration during init; then use Backend migration during init.
  4. First use Init without backend setup; then use Initialize a new working directory.
  5. First use Backend migration during init; then use Initialize a new working directory.

Explanation

Correct Answer

D:

The first requirement, to work on configuration validation while deliberately skipping backend initialization, is handled by Init without backend setup: terraform init -backend=false skips the backend initialization step where appropriate. The second requirement, to prepare backend and plugin dependencies before planning, is handled by Initialize a new working directory: terraform init configures backend access and fetches required modules and providers. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to work on configuration validation while deliberately skipping backend initialization and prepare backend and plugin dependencies before planning, the first candidate Init without backend setup addresses work on configuration validation while deliberately skipping backend initialization; the second candidate Backend reconfiguration during init addresses accept an intentional backend configuration change without migrating state. This mapping fails because the second mechanism primarily supports the task to accept an intentional backend configuration change without migrating state; the actual requirements are work on configuration validation while deliberately skipping backend initialization first and prepare backend and plugin dependencies before planning second.

B:

For the requested tasks to work on configuration validation while deliberately skipping backend initialization and prepare backend and plugin dependencies before planning, the first candidate Initialize a new working directory addresses prepare backend and plugin dependencies before planning; the second candidate Init without backend setup addresses work on configuration validation while deliberately skipping backend initialization. This mapping fails because the first mechanism primarily supports the task to prepare backend and plugin dependencies before planning and the second mechanism primarily supports the task to work on configuration validation while deliberately skipping backend initialization; the actual requirements are work on configuration validation while deliberately skipping backend initialization first and prepare backend and plugin dependencies before planning second.

C:

For the requested tasks to work on configuration validation while deliberately skipping backend initialization and prepare backend and plugin dependencies before planning, the first candidate Backend reconfiguration during init addresses accept an intentional backend configuration change without migrating state; 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 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 move existing state to a newly selected backend when changing its storage; the actual requirements are work on configuration validation while deliberately skipping backend initialization first and prepare backend and plugin dependencies before planning second.

E:

For the requested tasks to work on configuration validation while deliberately skipping backend initialization and prepare backend and plugin dependencies before planning, the first candidate Backend migration during init addresses move existing state to a newly selected backend when changing its storage; the second candidate Initialize a new working directory addresses prepare backend and plugin dependencies before planning. This mapping fails because the first mechanism primarily supports the task to move existing state to a newly selected backend when changing its storage; the actual requirements are work on configuration validation while deliberately skipping backend initialization first and prepare backend and plugin dependencies before planning second.

Question 377

A design uses Provider block configuration to supply settings such as region or endpoint for a provider instance. Which qualification applies to the named mechanism?

  1. It generally does not create or destroy the looked-up object.
  2. Terraform itself does not create a cloud instance without an appropriate provider.
  3. It does not determine which provider package source gets installed.
  4. Successful terraform validate does not guarantee those credentials can reach an API.

Explanation

Correct Answer

C:

For Provider block configuration in the task to supply settings such as region or endpoint for a provider instance, the important caution is: It does not determine which provider package source gets installed. The reason this matters is its actual behavior: A provider block creates a configured provider instance that resources can use.

Incorrect Answers

A:

The proposed warning belongs to Provider data sources, which serves the different goal to read remote information without declaring ownership of its lifecycle, rather than to Provider block configuration: A provider data source queries external information that configuration can reference. The question concerns Provider block configuration acting to supply settings such as region or endpoint for a provider instance, not a limit of Provider data sources.

B:

The proposed warning belongs to Provider plugin responsibility, which serves the different goal to translate a Terraform resource operation into remote service API calls, rather than to Provider block configuration: The provider implements resource types and performs create, read, update, and delete operations when supported. The question concerns Provider block configuration acting to supply settings such as region or endpoint for a provider instance, not a limit of Provider plugin responsibility.

D:

The proposed warning belongs to Provider authentication, which serves the different goal to authorize API operations requested by a Terraform provider, rather than to Provider block configuration: Providers use supported credentials and authentication mechanisms to talk to their services. The question concerns Provider block configuration acting to supply settings such as region or endpoint for a provider instance, not a limit of Provider authentication.

Question 378

The implementation must both identify the precise stale lock before taking exceptional recovery action and prevent two concurrent runs from writing the same state snapshot. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. terraform -lock-timeout behavior
  2. terraform force-unlock
  3. Terraform state locking
  4. Lock identifier verification
  5. Lock acquisition before writes

Explanation

Correct Answers

C:

Among the paired tasks to identify the precise stale lock before taking exceptional recovery action and prevent two concurrent runs from writing the same state snapshot, Terraform state locking serves the requirement to prevent two concurrent runs from writing the same state snapshot: A backend with locking support serializes operations that could corrupt shared state. The other task must be covered by a separate mechanism.

D:

Among the paired tasks to identify the precise stale lock before taking exceptional recovery action and prevent two concurrent runs from writing the same state snapshot, Lock identifier verification serves the requirement to identify the precise stale lock before taking exceptional recovery action: A lock ID should be matched to the blocked state operation before unlocking. The other task must be covered by a separate mechanism.

Incorrect Answers

A:

The requirements are identify the precise stale lock before taking exceptional recovery action and prevent two concurrent runs from writing the same state snapshot, while terraform -lock-timeout behavior supports the different task to let a run wait briefly rather than fail immediately when state is busy: The lock-timeout flag controls how long supported operations retry obtaining a lock. That capability is outside the two selected responsibilities.

B:

The requirements are identify the precise stale lock before taking exceptional recovery action and prevent two concurrent runs from writing the same state snapshot, while terraform force-unlock supports the different task to remove a stale lock only after confirming that no valid run owns it: force-unlock accepts a lock ID and bypasses normal waiting for an abandoned lock. That capability is outside the two selected responsibilities.

E:

The requirements are identify the precise stale lock before taking exceptional recovery action and prevent two concurrent runs from writing the same state snapshot, while Lock acquisition before writes supports the different task to avoid racing state mutations when several operators run Terraform: Terraform tries to obtain a state lock when the chosen backend supports it. That capability is outside the two selected responsibilities.

Question 379

A Terraform rollout has two separate requirements: first, make some child module arguments optional for callers; second, pass a caller-defined value into a reusable child module. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Child module input variable; then use Module input defaults.
  2. First use Child module output scope; then use Root variable namespace.
  3. First use Module input defaults; then use Child module input variable.
  4. First use Root variable namespace; then use Child module input variable.
  5. First use Module input defaults; then use Child module output scope.

Explanation

Correct Answer

C:

The first requirement, to make some child module arguments optional for callers, is handled by Module input defaults: A child variable with a default can be omitted by the caller, allowing the child to use its fallback. The second requirement, to pass a caller-defined value into a reusable child module, is handled by Child module input variable: The child declares a variable and the parent's module block assigns a value to that argument. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to make some child module arguments optional for callers and pass a caller-defined value into a reusable child module, the first candidate Child module input variable addresses pass a caller-defined value into a reusable child module; the second candidate Module input defaults addresses make some child module arguments optional for callers. This mapping fails because the first mechanism primarily supports the task to pass a caller-defined value into a reusable child module and the second mechanism primarily supports the task to make some child module arguments optional for callers; the actual requirements are make some child module arguments optional for callers first and pass a caller-defined value into a reusable child module second.

B:

For the requested tasks to make some child module arguments optional for callers and pass a caller-defined value into a reusable child module, the first candidate Child module output scope addresses expose specific child values to its parent with an output block; the second candidate Root variable namespace addresses distinguish CLI-supplied root inputs from child inputs. 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 distinguish CLI-supplied root inputs from child inputs; the actual requirements are make some child module arguments optional for callers first and pass a caller-defined value into a reusable child module second.

D:

For the requested tasks to make some child module arguments optional for callers and pass a caller-defined value into a reusable child module, the first candidate Root variable namespace addresses distinguish CLI-supplied root inputs from child inputs; the second candidate Child module input variable addresses pass a caller-defined value into a reusable child module. This mapping fails because the first mechanism primarily supports the task to distinguish CLI-supplied root inputs from child inputs; the actual requirements are make some child module arguments optional for callers first and pass a caller-defined value into a reusable child module second.

E:

For the requested tasks to make some child module arguments optional for callers and pass a caller-defined value into a reusable child module, the first candidate Module input defaults addresses make some child module arguments optional for callers; the second candidate Child module output scope addresses expose specific child values to its parent with an output block. This mapping fails because the second mechanism primarily supports the task to expose specific child values to its parent with an output block; the actual requirements are make some child module arguments optional for callers first and pass a caller-defined value into a reusable child module second.

Question 380

A Terraform rollout has two separate requirements: first, avoid long-lived static cloud credentials in workspace variables; second, share approved reusable modules within an organization. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use HCP Terraform dynamic provider credentials; then use HCP Terraform policy sets.
  2. First use HCP Terraform private module registry; then use HCP Terraform dynamic provider credentials.
  3. First use HCP Terraform teams and permissions; then use HCP Terraform private module registry.
  4. First use HCP Terraform policy sets; then use HCP Terraform teams and permissions.
  5. First use HCP Terraform dynamic provider credentials; then use HCP Terraform private module registry.

Explanation

Correct Answer

E:

The first requirement, to avoid long-lived static cloud credentials in workspace variables, is handled by HCP Terraform dynamic provider credentials: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. The second requirement, to share approved reusable modules within an organization, is handled by HCP Terraform private module registry: A private registry distributes versioned modules to organization workspaces and teams. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to avoid long-lived static cloud credentials in workspace variables and share approved reusable modules within an organization, the first candidate HCP Terraform dynamic provider credentials addresses avoid long-lived static cloud credentials in workspace variables; the second candidate HCP Terraform policy sets addresses enforce organizational rules during infrastructure runs. This mapping fails because the second mechanism primarily supports the task to enforce organizational rules during infrastructure runs; the actual requirements are avoid long-lived static cloud credentials in workspace variables first and share approved reusable modules within an organization second.

B:

For the requested tasks to avoid long-lived static cloud credentials in workspace variables and share approved reusable modules within an organization, the first candidate HCP Terraform private module registry addresses share approved reusable modules within an organization; the second candidate HCP Terraform dynamic provider credentials addresses avoid long-lived static cloud credentials in workspace variables. This mapping fails because the first mechanism primarily supports the task to share approved reusable modules within an organization and the second mechanism primarily supports the task to avoid long-lived static cloud credentials in workspace variables; the actual requirements are avoid long-lived static cloud credentials in workspace variables first and share approved reusable modules within an organization second.

C:

For the requested tasks to avoid long-lived static cloud credentials in workspace variables and share approved reusable modules within an organization, the first candidate HCP Terraform teams and permissions addresses grant workspace access based on collaboration responsibilities; the second candidate HCP Terraform private module registry addresses share approved reusable modules within an organization. This mapping fails because the first mechanism primarily supports the task to grant workspace access based on collaboration responsibilities; the actual requirements are avoid long-lived static cloud credentials in workspace variables first and share approved reusable modules within an organization second.

D:

For the requested tasks to avoid long-lived static cloud credentials in workspace variables and share approved reusable modules within an organization, the first candidate HCP Terraform policy sets addresses enforce organizational rules during infrastructure runs; the second candidate HCP Terraform teams and permissions addresses grant workspace access based on collaboration responsibilities. This mapping fails because the first mechanism primarily supports the task to enforce organizational rules during infrastructure runs and the second mechanism primarily supports the task to grant workspace access based on collaboration responsibilities; the actual requirements are avoid long-lived static cloud credentials in workspace variables first and share approved reusable modules within an organization second.

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