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

Question 390

A Terraform rollout has two separate requirements: first, name a computed expression used repeatedly inside one module; second, load multiple variable assignments from a chosen tfvars file. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Local value expression; then use Variable source precedence.
  2. First use Variable source precedence; then use Required input variable.
  3. First use Variable file input; then use Local value expression.
  4. First use Required input variable; then use Variable file input.
  5. First use Local value expression; then use Variable file input.

Explanation

Correct Answer

E:

The first requirement, to name a computed expression used repeatedly inside one module, is handled by Local value expression: locals blocks evaluate named expressions available as local.name within that module. The second requirement, to load multiple variable assignments from a chosen tfvars file, is handled by Variable file input: The -var-file flag passes root-module input values from a named variable definitions file. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to name a computed expression used repeatedly inside one module and load multiple variable assignments from a chosen tfvars file, the first candidate Local value expression addresses name a computed expression used repeatedly inside one module; the second candidate Variable source precedence addresses override environment or tfvars values with an explicit CLI variable flag. This mapping fails because the second mechanism primarily supports the task to override environment or tfvars values with an explicit CLI variable flag; the actual requirements are name a computed expression used repeatedly inside one module first and load multiple variable assignments from a chosen tfvars file second.

B:

For the requested tasks to name a computed expression used repeatedly inside one module and load multiple variable assignments from a chosen tfvars file, the first candidate Variable source precedence addresses override environment or tfvars values with an explicit CLI variable flag; the second candidate Required input variable addresses prompt for or provide a root-module value when no default exists. This mapping fails because the first mechanism primarily supports the task to override environment or tfvars values with an explicit CLI variable flag and the second mechanism primarily supports the task to prompt for or provide a root-module value when no default exists; the actual requirements are name a computed expression used repeatedly inside one module first and load multiple variable assignments from a chosen tfvars file second.

C:

For the requested tasks to name a computed expression used repeatedly inside one module and load multiple variable assignments from a chosen tfvars file, the first candidate Variable file input addresses load multiple variable assignments from a chosen tfvars file; the second candidate Local value expression addresses name a computed expression used repeatedly inside one module. This mapping fails because the first mechanism primarily supports the task to load multiple variable assignments from a chosen tfvars file and the second mechanism primarily supports the task to name a computed expression used repeatedly inside one module; the actual requirements are name a computed expression used repeatedly inside one module first and load multiple variable assignments from a chosen tfvars file second.

D:

For the requested tasks to name a computed expression used repeatedly inside one module and load multiple variable assignments from a chosen tfvars file, the first candidate Required input variable addresses prompt for or provide a root-module value when no default exists; the second candidate Variable file input addresses load multiple variable assignments from a chosen tfvars file. This mapping fails because the first mechanism primarily supports the task to prompt for or provide a root-module value when no default exists; the actual requirements are name a computed expression used repeatedly inside one module first and load multiple variable assignments from a chosen tfvars file second.

Question 391

A Terraform runbook describes the mechanism "Init provider plugin upgrade control". Which responsibility should a reviewer associate with it?

  1. install externally sourced child modules referenced by the root module
  2. work on configuration validation while deliberately skipping backend initialization
  3. preserve locked provider selections in routine CI initialization
  4. rerun initialization after adding a provider or changing module sources

Explanation

Correct Answer

C:

The practical result of Init provider plugin upgrade control, used to preserve locked provider selections in routine CI initialization, is: A normal terraform init honors the existing dependency lock selections unless update is requested. A qualification for this effect is: A changed constraint can require an explicit upgrade or other resolution.

Incorrect Answers

A:

That outcome applies to Module download on init, intended to install externally sourced child modules referenced by the root module, rather than the question's feature Init provider plugin upgrade control: terraform init resolves module sources and downloads them to the local module cache. Unlike Module download on init, Init provider plugin upgrade control is intended to preserve locked provider selections in routine CI initialization, not to install externally sourced child modules referenced by the root module.

B:

That outcome applies to Init without backend setup, intended to work on configuration validation while deliberately skipping backend initialization, rather than the question's feature Init provider plugin upgrade control: terraform init -backend=false skips the backend initialization step where appropriate. Unlike Init without backend setup, Init provider plugin upgrade control is intended to preserve locked provider selections in routine CI initialization, not to work on configuration validation while deliberately skipping backend initialization.

D:

That outcome applies to Initialization as safe repeated step, intended to rerun initialization after adding a provider or changing module sources, rather than the question's feature Init provider plugin upgrade control: It is normally safe to run terraform init repeatedly to satisfy updated dependencies. Unlike Initialization as safe repeated step, Init provider plugin upgrade control is intended to preserve locked provider selections in routine CI initialization, not to rerun initialization after adding a provider or changing module sources.

Question 392

During an implementation review, a Terraform team encounters "Remote backend locking capabilities". Which purpose is associated with that mechanism?

  1. select shared state storage with appropriate concurrency semantics
  2. avoid racing state mutations when several operators run Terraform
  3. remove a stale lock only after confirming that no valid run owns it
  4. prevent two concurrent runs from writing the same state snapshot

Explanation

Correct Answer

A:

The practical result of Remote backend locking capabilities, used to select shared state storage with appropriate concurrency semantics, is: Supported remote backends can coordinate locking around updates to common state. A qualification for this effect is: Remote storage and locking are related but distinct capabilities.

Incorrect Answers

B:

That outcome applies to Lock acquisition before writes, intended to avoid racing state mutations when several operators run Terraform, rather than the question's feature Remote backend locking capabilities: Terraform tries to obtain a state lock when the chosen backend supports it. Unlike Lock acquisition before writes, Remote backend locking capabilities is intended to select shared state storage with appropriate concurrency semantics, not to avoid racing state mutations when several operators run Terraform.

C:

That outcome applies to terraform force-unlock, intended to remove a stale lock only after confirming that no valid run owns it, rather than the question's feature Remote backend locking capabilities: force-unlock accepts a lock ID and bypasses normal waiting for an abandoned lock. Unlike terraform force-unlock, Remote backend locking capabilities is intended to select shared state storage with appropriate concurrency semantics, not to remove a stale lock only after confirming that no valid run owns it.

D:

That outcome applies to Terraform state locking, intended to prevent two concurrent runs from writing the same state snapshot, rather than the question's feature Remote backend locking capabilities: A backend with locking support serializes operations that could corrupt shared state. Unlike Terraform state locking, Remote backend locking capabilities is intended to select shared state storage with appropriate concurrency semantics, not to prevent two concurrent runs from writing the same state snapshot.

Question 393

A Terraform rollout has two separate requirements: first, recreate equivalent infrastructure patterns from one codebase; second, replace repetitive click-by-click resource deployment with a pipeline. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Change impact preview; then use Automated provisioning pipeline.
  2. First use Consistent development and production patterns; then use Change impact preview.
  3. First use Repeatable environment provisioning; then use Consistent development and production patterns.
  4. First use Repeatable environment provisioning; then use Automated provisioning pipeline.
  5. First use Automated provisioning pipeline; then use Repeatable environment provisioning.

Explanation

Correct Answer

D:

The first requirement, to recreate equivalent infrastructure patterns from one codebase, is handled by Repeatable environment provisioning: Parameterizing reusable Terraform modules can provision consistent environment patterns repeatedly. The second requirement, to replace repetitive click-by-click resource deployment with a pipeline, is handled by Automated provisioning pipeline: A CI pipeline can run validation and planning before an authorized apply, reducing procedural inconsistency. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to recreate equivalent infrastructure patterns from one codebase and replace repetitive click-by-click resource deployment with a pipeline, the first candidate Change impact preview addresses identify likely creations, updates, and deletions before execution; the second candidate Automated provisioning pipeline addresses replace repetitive click-by-click resource deployment with a pipeline. This mapping fails because the first mechanism primarily supports the task to identify likely creations, updates, and deletions before execution; the actual requirements are recreate equivalent infrastructure patterns from one codebase first and replace repetitive click-by-click resource deployment with a pipeline second.

B:

For the requested tasks to recreate equivalent infrastructure patterns from one codebase and replace repetitive click-by-click resource deployment with a pipeline, the first candidate Consistent development and production patterns addresses reduce configuration drift across environments using shared modules; the second candidate Change impact preview addresses identify likely creations, updates, and deletions before execution. This mapping fails because the first mechanism primarily supports the task to reduce configuration drift across environments using shared modules and the second mechanism primarily supports the task to identify likely creations, updates, and deletions before execution; the actual requirements are recreate equivalent infrastructure patterns from one codebase first and replace repetitive click-by-click resource deployment with a pipeline second.

C:

For the requested tasks to recreate equivalent infrastructure patterns from one codebase and replace repetitive click-by-click resource deployment with a pipeline, the first candidate Repeatable environment provisioning addresses recreate equivalent infrastructure patterns from one codebase; the second candidate Consistent development and production patterns addresses reduce configuration drift across environments using shared modules. This mapping fails because the second mechanism primarily supports the task to reduce configuration drift across environments using shared modules; the actual requirements are recreate equivalent infrastructure patterns from one codebase first and replace repetitive click-by-click resource deployment with a pipeline second.

E:

For the requested tasks to recreate equivalent infrastructure patterns from one codebase and replace repetitive click-by-click resource deployment with a pipeline, the first candidate Automated provisioning pipeline addresses replace repetitive click-by-click resource deployment with a pipeline; the second candidate Repeatable environment provisioning addresses recreate equivalent infrastructure patterns from one codebase. This mapping fails because the first mechanism primarily supports the task to replace repetitive click-by-click resource deployment with a pipeline and the second mechanism primarily supports the task to recreate equivalent infrastructure patterns from one codebase; the actual requirements are recreate equivalent infrastructure patterns from one codebase first and replace repetitive click-by-click resource deployment with a pipeline second.

Question 394

An operator chooses the mechanism "Module outputs with repeated instances" for a Terraform project. Which outcome should this choice support?

  1. distinguish CLI-supplied root inputs from child inputs
  2. read values from every instance created by a counted or keyed module call
  3. pass a caller-defined value into a reusable child module
  4. expose specific child values to its parent with an output block

Explanation

Correct Answer

B:

The practical result of Module outputs with repeated instances, used to read values from every instance created by a counted or keyed module call, is: Counted module outputs use numeric indices; for_each module outputs use instance keys. A qualification for this effect is: A repeated module call is not the same value shape as a single module output object.

Incorrect Answers

A:

That outcome applies to Root variable namespace, intended to distinguish CLI-supplied root inputs from child inputs, rather than the question's feature Module outputs with repeated instances: CLI -var arguments set variables declared in the root module; child values pass through module call arguments. Unlike Root variable namespace, Module outputs with repeated instances is intended to read values from every instance created by a counted or keyed module call, not to distinguish CLI-supplied root inputs from child inputs.

C:

That outcome applies to Child module input variable, intended to pass a caller-defined value into a reusable child module, rather than the question's feature Module outputs with repeated instances: The child declares a variable and the parent's module block assigns a value to that argument. Unlike Child module input variable, Module outputs with repeated instances is intended to read values from every instance created by a counted or keyed module call, not to pass a caller-defined value into a reusable child module.

D:

That outcome applies to Child module output scope, intended to expose specific child values to its parent with an output block, rather than the question's feature Module outputs with repeated instances: The parent can use module.child.output_name only when the child explicitly declares that output. Unlike Child module output scope, Module outputs with repeated instances is intended to read values from every instance created by a counted or keyed module call, not to expose specific child values to its parent with an output block.

Question 395

A colleague recommends the Terraform concept "HCP Terraform auditability". Which use case best matches it?

  1. monitor for resources that have diverged from workspace configuration
  2. retain run and change history for collaboration and review
  3. share reusable variables across selected workspaces
  4. avoid long-lived static cloud credentials in workspace variables

Explanation

Correct Answer

B:

The practical result of HCP Terraform auditability, used to retain run and change history for collaboration and review, is: Workspace run histories help teams trace proposed and executed infrastructure operations. A qualification for this effect is: A recorded run history is not the same as versioned source code approval.

Incorrect Answers

A:

That outcome applies to HCP Terraform drift detection, intended to monitor for resources that have diverged from workspace configuration, rather than the question's feature HCP Terraform auditability: Health assessments can identify drift between tracked resources and desired configuration. Unlike HCP Terraform drift detection, HCP Terraform auditability is intended to retain run and change history for collaboration and review, not to monitor for resources that have diverged from workspace configuration.

C:

That outcome applies to HCP Terraform variable sets, intended to share reusable variables across selected workspaces, rather than the question's feature HCP Terraform auditability: Variable sets can provide common Terraform or environment variables to applicable workspaces. Unlike HCP Terraform variable sets, HCP Terraform auditability is intended to retain run and change history for collaboration and review, not to share reusable variables across selected workspaces.

D:

That outcome applies to HCP Terraform dynamic provider credentials, intended to avoid long-lived static cloud credentials in workspace variables, rather than the question's feature HCP Terraform auditability: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. Unlike HCP Terraform dynamic provider credentials, HCP Terraform auditability is intended to retain run and change history for collaboration and review, not to avoid long-lived static cloud credentials in workspace variables.

Question 396

A Terraform rollout has two separate requirements: first, inspect stored attributes for one tracked resource instance; second, export state or saved plan information in machine-readable form. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use terraform show -json; then use terraform state show ADDRESS.
  2. First use terraform state pull; then use terraform output.
  3. First use terraform state show ADDRESS; then use terraform state pull.
  4. First use terraform state show ADDRESS; then use terraform show -json.
  5. First use terraform output; then use terraform show -json.

Explanation

Correct Answer

D:

The first requirement, to inspect stored attributes for one tracked resource instance, is handled by terraform state show ADDRESS: state show presents the state representation of an addressed resource. The second requirement, to export state or saved plan information in machine-readable form, is handled by terraform show -json: show -json emits detailed JSON for supported state and plan representations. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to inspect stored attributes for one tracked resource instance and export state or saved plan information in machine-readable form, the first candidate terraform show -json addresses export state or saved plan information in machine-readable form; the second candidate terraform state show ADDRESS addresses inspect stored attributes for one tracked resource instance. This mapping fails because the first mechanism primarily supports the task to export state or saved plan information in machine-readable form and the second mechanism primarily supports the task to inspect stored attributes for one tracked resource instance; the actual requirements are inspect stored attributes for one tracked resource instance first and export state or saved plan information in machine-readable form second.

B:

For the requested tasks to inspect stored attributes for one tracked resource instance and export state or saved plan information in machine-readable form, the first candidate terraform state pull addresses retrieve the current backend state snapshot as serialized JSON; the second candidate terraform output addresses display declared root output values from the current state. This mapping fails because the first mechanism primarily supports the task to retrieve the current backend state snapshot as serialized JSON and the second mechanism primarily supports the task to display declared root output values from the current state; the actual requirements are inspect stored attributes for one tracked resource instance first and export state or saved plan information in machine-readable form second.

C:

For the requested tasks to inspect stored attributes for one tracked resource instance and export state or saved plan information in machine-readable form, the first candidate terraform state show ADDRESS addresses inspect stored attributes for one tracked resource instance; the second candidate terraform state pull addresses retrieve the current backend state snapshot as serialized JSON. This mapping fails because the second mechanism primarily supports the task to retrieve the current backend state snapshot as serialized JSON; the actual requirements are inspect stored attributes for one tracked resource instance first and export state or saved plan information in machine-readable form second.

E:

For the requested tasks to inspect stored attributes for one tracked resource instance and export state or saved plan information in machine-readable form, the first candidate terraform output addresses display declared root output values from the current state; the second candidate terraform show -json addresses export state or saved plan information in machine-readable form. This mapping fails because the first mechanism primarily supports the task to display declared root output values from the current state; the actual requirements are inspect stored attributes for one tracked resource instance first and export state or saved plan information in machine-readable form second.

Question 397

In a reusable deployment, the primary objective is to expose a selected Terraform expression to the caller or CLI. Which mechanism most directly meets this particular need?

  1. Output block
  2. Variable source precedence
  3. Variable file input
  4. Required input variable
  5. Local value expression

Explanation

Correct Answer

A:

The task is to expose a selected Terraform expression to the caller or CLI; Output block directly supports that requirement: An output block publishes a value from its module, such as an endpoint or resource identifier. Its relevant boundary is: Outputs do not automatically create an infrastructure object.

Incorrect Answers

B:

Variable source precedence is designed to override environment or tfvars values with an explicit CLI variable flag, whereas this task is to expose a selected Terraform expression to the caller or CLI: Direct -var and -var-file command-line assignments have precedence over automatically loaded values. Against Output block, its limitation is: Input precedence does not grant the variable a new scope inside child modules.

C:

Variable file input is designed to load multiple variable assignments from a chosen tfvars file, whereas this task is to expose a selected Terraform expression to the caller or CLI: The -var-file flag passes root-module input values from a named variable definitions file. Against Output block, its limitation is: The file supplies values but does not declare variable types.

D:

Required input variable is designed to prompt for or provide a root-module value when no default exists, whereas this task is to expose a selected Terraform expression to the caller or CLI: A variable block without a default requires a value supplied through a supported input channel. Against Output block, its limitation is: Declaring a variable does not itself fetch a remote API value.

E:

Local value expression is designed to name a computed expression used repeatedly inside one module, whereas this task is to expose a selected Terraform expression to the caller or CLI: locals blocks evaluate named expressions available as local.name within that module. Against Output block, its limitation is: They are not root-module input variables and cannot be set with -var.

Question 398

Before adopting Init provider plugin upgrade control to preserve locked provider selections in routine CI initialization, which statement sets an accurate boundary?

  1. Commands needing live state might not work without a configured backend.
  2. Downloading a module does not create its infrastructure.
  3. Initialization is not the command for creating managed resources.
  4. Reinitialization is not a substitute for planning after configuration changes.
  5. A changed constraint can require an explicit upgrade or other resolution.

Explanation

Correct Answer

E:

For Init provider plugin upgrade control in the task to preserve locked provider selections in routine CI initialization, the important caution is: A changed constraint can require an explicit upgrade or other resolution. The reason this matters is its actual behavior: A normal terraform init honors the existing dependency lock selections unless update is requested.

Incorrect Answers

A:

The proposed warning belongs to Init without backend setup, which serves the different goal to work on configuration validation while deliberately skipping backend initialization, rather than to Init provider plugin upgrade control: terraform init -backend=false skips the backend initialization step where appropriate. The question concerns Init provider plugin upgrade control acting to preserve locked provider selections in routine CI initialization, not a limit of Init without backend setup.

B:

The proposed warning belongs to Module download on init, which serves the different goal to install externally sourced child modules referenced by the root module, rather than to Init provider plugin upgrade control: terraform init resolves module sources and downloads them to the local module cache. The question concerns Init provider plugin upgrade control acting to preserve locked provider selections in routine CI initialization, not a limit of Module download on init.

C:

The proposed warning belongs to Initialize a new working directory, which serves the different goal to prepare backend and plugin dependencies before planning, rather than to Init provider plugin upgrade control: terraform init configures backend access and fetches required modules and providers. The question concerns Init provider plugin upgrade control acting to preserve locked provider selections in routine CI initialization, not a limit of Initialize a new working directory.

D:

The proposed warning belongs to Initialization as safe repeated step, which serves the different goal to rerun initialization after adding a provider or changing module sources, rather than to Init provider plugin upgrade control: It is normally safe to run terraform init repeatedly to satisfy updated dependencies. The question concerns Init provider plugin upgrade control acting to preserve locked provider selections in routine CI initialization, not a limit of Initialization as safe repeated step.

Question 399

A configuration review identifies the need to authorize API operations requested by a Terraform provider. Which mechanism most directly meets this particular need?

  1. Provider selection for resource prefix
  2. Provider authentication
  3. Plugin dependency installation
  4. Provider resource schema
  5. Provider plugin responsibility

Explanation

Correct Answer

B:

The task is to authorize API operations requested by a Terraform provider; Provider authentication directly supports that requirement: Providers use supported credentials and authentication mechanisms to talk to their services. Its relevant boundary is: Successful terraform validate does not guarantee those credentials can reach an API.

Incorrect Answers

A:

Provider selection for resource prefix is designed to associate a resource with the default provider for its type prefix, whereas this task is to authorize API operations requested by a Terraform provider: Without a provider meta-argument Terraform normally selects the matching local provider configuration. Against Provider authentication, its limitation is: An alias must be chosen explicitly if the resource needs a nondefault configuration.

C:

Plugin dependency installation is designed to resolve all referenced provider plugins before planning, whereas this task is to authorize API operations requested by a Terraform provider: An initialized working directory has the plugins required for its configured resources and data sources. Against Provider authentication, its limitation is: A provider is not a Terraform module downloaded from a module source.

D:

Provider resource schema is designed to define the supported arguments and attributes for one resource type, whereas this task is to authorize API operations requested by a Terraform provider: The provider schema specifies which settings users can configure and which values are computed. Against Provider authentication, its limitation is: A generic Terraform language feature cannot invent unsupported provider arguments.

E:

Provider plugin responsibility is designed to translate a Terraform resource operation into remote service API calls, whereas this task is to authorize API operations requested by a Terraform provider: The provider implements resource types and performs create, read, update, and delete operations when supported. Against Provider authentication, its limitation is: Terraform itself does not create a cloud instance without an appropriate provider.

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.

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