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

Question 360

In a reusable deployment, the primary objective is to recreate equivalent infrastructure patterns from one codebase. Which mechanism most directly meets this particular need?

  1. Self-documenting resource relationships
  2. Version-controlled configuration history
  3. Change impact preview
  4. Consistent development and production patterns
  5. Repeatable environment provisioning

Explanation

Correct Answer

E:

The task is to recreate equivalent infrastructure patterns from one codebase; Repeatable environment provisioning directly supports that requirement: Parameterizing reusable Terraform modules can provision consistent environment patterns repeatedly. Its relevant boundary is: Differences in inputs and provider versions can still alter actual results.

Incorrect Answers

A:

Self-documenting resource relationships is designed to make infrastructure dependencies understandable from code, whereas this task is to recreate equivalent infrastructure patterns from one codebase: Resource references and explicit dependencies can express how objects relate without relying on tribal knowledge. Against Repeatable environment provisioning, its limitation is: Provider behavior and implicit side effects still need relevant documentation.

B:

Version-controlled configuration history is designed to trace why infrastructure definitions changed, whereas this task is to recreate equivalent infrastructure patterns from one codebase: Git commits and pull requests make configuration edits auditable before the next Terraform run. Against Repeatable environment provisioning, its limitation is: A Git diff tracks source files rather than proving the exact live infrastructure state.

C:

Change impact preview is designed to identify likely creations, updates, and deletions before execution, whereas this task is to recreate equivalent infrastructure patterns from one codebase: Terraform planning exposes proposed operations for examination before they take effect. Against Repeatable environment provisioning, its limitation is: A plan may include unknown attributes that are resolved only during apply.

D:

Consistent development and production patterns is designed to reduce configuration drift across environments using shared modules, whereas this task is to recreate equivalent infrastructure patterns from one codebase: Reusing modules with explicit inputs aligns infrastructure design while allowing intentional environment differences. Against Repeatable environment provisioning, its limitation is: Sharing a module does not force all environments to use identical values.

Question 361

A team is adjusting its declarative infrastructure process to inspect stored attributes for one tracked resource instance. Which mechanism most directly meets this particular need?

  1. terraform output
  2. terraform state pull
  3. Address filter for state list
  4. terraform show
  5. terraform state show ADDRESS
  6. terraform state list

Explanation

Correct Answer

E:

The task is to inspect stored attributes for one tracked resource instance; terraform state show ADDRESS directly supports that requirement: state show presents the state representation of an addressed resource. Its relevant boundary is: It does not perform an infrastructure change or show another resource automatically.

Incorrect Answers

A:

terraform output is designed to display declared root output values from the current state, whereas this task is to inspect stored attributes for one tracked resource instance: output reads named output values and can provide -json for structured automation. Against terraform state show ADDRESS, its limitation is: It does not display arbitrary resource attributes unless exported via outputs.

B:

terraform state pull is designed to retrieve the current backend state snapshot as serialized JSON, whereas this task is to inspect stored attributes for one tracked resource instance: state pull reads state from the configured backend for inspection or backup handling. Against terraform state show ADDRESS, its limitation is: Editing and pushing the JSON should not be treated as a routine management workflow.

C:

Address filter for state list is designed to locate a relevant module or resource without reading every tracked address, whereas this task is to inspect stored attributes for one tracked resource instance: state list accepts optional address patterns to narrow visible resources. Against terraform state show ADDRESS, its limitation is: An address filter does not delete unwanted resource records.

D:

terraform show is designed to inspect the latest state or a saved execution plan in readable form, whereas this task is to inspect stored attributes for one tracked resource instance: terraform show can display an existing state snapshot or a named plan file. Against terraform state show ADDRESS, its limitation is: It is not the same as running a fresh plan against current infrastructure.

F:

terraform state list is designed to enumerate Terraform resource addresses currently tracked in a state snapshot, whereas this task is to inspect stored attributes for one tracked resource instance: state list displays managed addresses and can be narrowed with address filters. Against terraform state show ADDRESS, its limitation is: It does not enumerate every object in the cloud account.

Question 362

A configuration walkthrough identifies "Init without backend setup". Which task is it principally intended to support?

  1. rerun initialization after adding a provider or changing module sources
  2. prepare backend and plugin dependencies before planning
  3. move existing state to a newly selected backend when changing its storage
  4. accept an intentional backend configuration change without migrating state
  5. install externally sourced child modules referenced by the root module
  6. work on configuration validation while deliberately skipping backend initialization

Explanation

Correct Answer

F:

The practical result of Init without backend setup, used to work on configuration validation while deliberately skipping backend initialization, is: terraform init -backend=false skips the backend initialization step where appropriate. A qualification for this effect is: Commands needing live state might not work without a configured backend.

Incorrect Answers

A:

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 without backend setup: It is normally safe to run terraform init repeatedly to satisfy updated dependencies. Unlike Initialization as safe repeated step, Init without backend setup is intended to work on configuration validation while deliberately skipping backend initialization, not to rerun initialization after adding a provider or changing module sources.

B:

That outcome applies to Initialize a new working directory, intended to prepare backend and plugin dependencies before planning, rather than the question's feature Init without backend setup: terraform init configures backend access and fetches required modules and providers. Unlike Initialize a new working directory, Init without backend setup is intended to work on configuration validation while deliberately skipping backend initialization, not to prepare backend and plugin dependencies before planning.

C:

That outcome applies to Backend migration during init, intended to move existing state to a newly selected backend when changing its storage, rather than the question's feature Init without backend setup: terraform init -migrate-state offers state migration when a backend configuration changes. Unlike Backend migration during init, Init without backend setup is intended to work on configuration validation while deliberately skipping backend initialization, not to move existing state to a newly selected backend when changing its storage.

D:

That outcome applies to Backend reconfiguration during init, intended to accept an intentional backend configuration change without migrating state, rather than the question's feature Init without backend setup: terraform init -reconfigure disregards the existing backend initialization settings and uses new ones. Unlike Backend reconfiguration during init, Init without backend setup is intended to work on configuration validation while deliberately skipping backend initialization, not to accept an intentional backend configuration change without migrating state.

E:

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 without backend setup: terraform init resolves module sources and downloads them to the local module cache. Unlike Module download on init, Init without backend setup is intended to work on configuration validation while deliberately skipping backend initialization, not to install externally sourced child modules referenced by the root module.

Question 363

A Terraform runbook describes the mechanism "Lock identifier verification". Which responsibility should a reviewer associate with it?

  1. prevent two concurrent runs from writing the same state snapshot
  2. identify the precise stale lock before taking exceptional recovery action
  3. avoid racing state mutations when several operators run Terraform
  4. protect shared state rather than using -lock=false as a routine workaround
  5. select shared state storage with appropriate concurrency semantics
  6. let a run wait briefly rather than fail immediately when state is busy

Explanation

Correct Answer

B:

The practical result of Lock identifier verification, used to identify the precise stale lock before taking exceptional recovery action, is: A lock ID should be matched to the blocked state operation before unlocking. A qualification for this effect is: Guessing an ID or acting during an active deployment can corrupt coordination.

Incorrect Answers

A:

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 Lock identifier verification: A backend with locking support serializes operations that could corrupt shared state. Unlike Terraform state locking, Lock identifier verification is intended to identify the precise stale lock before taking exceptional recovery action, not to prevent two concurrent runs from writing the same state snapshot.

C:

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 Lock identifier verification: Terraform tries to obtain a state lock when the chosen backend supports it. Unlike Lock acquisition before writes, Lock identifier verification is intended to identify the precise stale lock before taking exceptional recovery action, not to avoid racing state mutations when several operators run Terraform.

D:

That outcome applies to Avoid disabling state locks, intended to protect shared state rather than using -lock=false as a routine workaround, rather than the question's feature Lock identifier verification: Using a lock-capable backend with normal locking reduces state races. Unlike Avoid disabling state locks, Lock identifier verification is intended to identify the precise stale lock before taking exceptional recovery action, not to protect shared state rather than using -lock=false as a routine workaround.

E:

That outcome applies to Remote backend locking capabilities, intended to select shared state storage with appropriate concurrency semantics, rather than the question's feature Lock identifier verification: Supported remote backends can coordinate locking around updates to common state. Unlike Remote backend locking capabilities, Lock identifier verification is intended to identify the precise stale lock before taking exceptional recovery action, not to select shared state storage with appropriate concurrency semantics.

F:

That outcome applies to terraform -lock-timeout behavior, intended to let a run wait briefly rather than fail immediately when state is busy, rather than the question's feature Lock identifier verification: The lock-timeout flag controls how long supported operations retry obtaining a lock. Unlike terraform -lock-timeout behavior, Lock identifier verification is intended to identify the precise stale lock before taking exceptional recovery action, not to let a run wait briefly rather than fail immediately when state is busy.

Question 364

A design uses Variable default value to give a module input a fallback when callers omit it. Which qualification applies to the named mechanism?

  1. Explicit callers can override the default with their own value.
  2. Declaring a variable does not itself fetch a remote API value.
  3. The file supplies values but does not declare variable types.
  4. Outputs do not automatically create an infrastructure object.
  5. Input precedence does not grant the variable a new scope inside child modules.

Explanation

Correct Answer

A:

For Variable default value in the task to give a module input a fallback when callers omit it, the important caution is: Explicit callers can override the default with their own value. The reason this matters is its actual behavior: A variable default supplies a value without requiring each caller to pass that argument.

Incorrect Answers

B:

The proposed warning belongs to Required input variable, which serves the different goal to prompt for or provide a root-module value when no default exists, rather than to Variable default value: A variable block without a default requires a value supplied through a supported input channel. The question concerns Variable default value acting to give a module input a fallback when callers omit it, not a limit of Required input variable.

C:

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 Variable default value: The -var-file flag passes root-module input values from a named variable definitions file. The question concerns Variable default value acting to give a module input a fallback when callers omit it, not a limit of Variable file input.

D:

The proposed warning belongs to Output block, which serves the different goal to expose a selected Terraform expression to the caller or CLI, rather than to Variable default value: An output block publishes a value from its module, such as an endpoint or resource identifier. The question concerns Variable default value acting to give a module input a fallback when callers omit it, not a limit of Output block.

E:

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 Variable default value: Direct -var and -var-file command-line assignments have precedence over automatically loaded values. The question concerns Variable default value acting to give a module input a fallback when callers omit it, not a limit of Variable source precedence.

Question 365

A colleague recommends the Terraform concept "Module input defaults". Which use case best matches it?

  1. pass a caller-defined value into a reusable child module
  2. read values from every instance created by a counted or keyed module call
  3. compute module-specific intermediate values without exporting them
  4. make some child module arguments optional for callers
  5. expose specific child values to its parent with an output block
  6. keep provider instances configured in the root and pass them to child modules

Explanation

Correct Answer

D:

The practical result of Module input defaults, used to make some child module arguments optional for callers, is: A child variable with a default can be omitted by the caller, allowing the child to use its fallback. A qualification for this effect is: A default does not override an explicitly passed module argument.

Incorrect Answers

A:

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 input defaults: The child declares a variable and the parent's module block assigns a value to that argument. Unlike Child module input variable, Module input defaults is intended to make some child module arguments optional for callers, not to pass a caller-defined value into a reusable child module.

B:

That outcome applies to Module outputs with repeated instances, intended to read values from every instance created by a counted or keyed module call, rather than the question's feature Module input defaults: Counted module outputs use numeric indices; for_each module outputs use instance keys. Unlike Module outputs with repeated instances, Module input defaults is intended to make some child module arguments optional for callers, not to read values from every instance created by a counted or keyed module call.

C:

That outcome applies to Module local values, intended to compute module-specific intermediate values without exporting them, rather than the question's feature Module input defaults: Local values belong to the defining module and are referenced through local.name in that scope. Unlike Module local values, Module input defaults is intended to make some child module arguments optional for callers, not to compute module-specific intermediate values without exporting them.

E:

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 input defaults: The parent can use module.child.output_name only when the child explicitly declares that output. Unlike Child module output scope, Module input defaults is intended to make some child module arguments optional for callers, not to expose specific child values to its parent with an output block.

F:

That outcome applies to Provider configuration scope, intended to keep provider instances configured in the root and pass them to child modules, rather than the question's feature Module input defaults: A root module can explicitly map provider configurations into child module calls. Unlike Provider configuration scope, Module input defaults is intended to make some child module arguments optional for callers, not to keep provider instances configured in the root and pass them to child modules.

Question 366

During an implementation review, a Terraform team encounters "HCP Terraform dynamic provider credentials". Which purpose is associated with that mechanism?

  1. avoid long-lived static cloud credentials in workspace variables
  2. grant workspace access based on collaboration responsibilities
  3. monitor for resources that have diverged from workspace configuration
  4. share approved reusable modules within an organization
  5. enforce organizational rules during infrastructure runs
  6. share reusable variables across selected workspaces

Explanation

Correct Answer

A:

The practical result of HCP Terraform dynamic provider credentials, used to avoid long-lived static cloud credentials in workspace variables, is: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. A qualification for this effect is: The target provider and cloud identity federation must be configured correctly.

Incorrect Answers

B:

That outcome applies to HCP Terraform teams and permissions, intended to grant workspace access based on collaboration responsibilities, rather than the question's feature HCP Terraform dynamic provider credentials: Teams can be assigned appropriate workspace permissions for viewing, planning, and applying. Unlike HCP Terraform teams and permissions, HCP Terraform dynamic provider credentials is intended to avoid long-lived static cloud credentials in workspace variables, not to grant workspace access based on collaboration responsibilities.

C:

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 dynamic provider credentials: Health assessments can identify drift between tracked resources and desired configuration. Unlike HCP Terraform drift detection, HCP Terraform dynamic provider credentials is intended to avoid long-lived static cloud credentials in workspace variables, not to monitor for resources that have diverged from workspace configuration.

D:

That outcome applies to HCP Terraform private module registry, intended to share approved reusable modules within an organization, rather than the question's feature HCP Terraform dynamic provider credentials: A private registry distributes versioned modules to organization workspaces and teams. Unlike HCP Terraform private module registry, HCP Terraform dynamic provider credentials is intended to avoid long-lived static cloud credentials in workspace variables, not to share approved reusable modules within an organization.

E:

That outcome applies to HCP Terraform policy sets, intended to enforce organizational rules during infrastructure runs, rather than the question's feature HCP Terraform dynamic provider credentials: HCP Terraform can evaluate governance policies such as Sentinel or OPA as part of run controls. Unlike HCP Terraform policy sets, HCP Terraform dynamic provider credentials is intended to avoid long-lived static cloud credentials in workspace variables, not to enforce organizational rules during infrastructure runs.

F:

That outcome applies to HCP Terraform variable sets, intended to share reusable variables across selected workspaces, rather than the question's feature HCP Terraform dynamic provider credentials: Variable sets can provide common Terraform or environment variables to applicable workspaces. Unlike HCP Terraform variable sets, HCP Terraform dynamic provider credentials is intended to avoid long-lived static cloud credentials in workspace variables, not to share reusable variables across selected workspaces.

Question 367

An operator chooses the mechanism "Provider block configuration" for a Terraform project. Which outcome should this choice support?

  1. authorize API operations requested by a Terraform provider
  2. supply settings such as region or endpoint for a provider instance
  3. translate a Terraform resource operation into remote service API calls
  4. read remote information without declaring ownership of its lifecycle

Explanation

Correct Answer

B:

The practical result of Provider block configuration, used to supply settings such as region or endpoint for a provider instance, is: A provider block creates a configured provider instance that resources can use. A qualification for this effect is: It does not determine which provider package source gets installed.

Incorrect Answers

A:

That outcome applies to Provider authentication, intended to authorize API operations requested by a Terraform provider, rather than the question's feature Provider block configuration: Providers use supported credentials and authentication mechanisms to talk to their services. Unlike Provider authentication, Provider block configuration is intended to supply settings such as region or endpoint for a provider instance, not to authorize API operations requested by a Terraform provider.

C:

That outcome applies to Provider plugin responsibility, intended to translate a Terraform resource operation into remote service API calls, rather than the question's feature Provider block configuration: The provider implements resource types and performs create, read, update, and delete operations when supported. Unlike Provider plugin responsibility, Provider block configuration is intended to supply settings such as region or endpoint for a provider instance, not to translate a Terraform resource operation into remote service API calls.

D:

That outcome applies to Provider data sources, intended to read remote information without declaring ownership of its lifecycle, rather than the question's feature Provider block configuration: A provider data source queries external information that configuration can reference. Unlike Provider data sources, Provider block configuration is intended to supply settings such as region or endpoint for a provider instance, not to read remote information without declaring ownership of its lifecycle.

Question 368

The implementation must both give a module input a fallback when callers omit it and expose a selected Terraform expression to the caller or CLI. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. Required input variable
  2. Output block
  3. Variable type constraint
  4. Local value expression
  5. Variable default value

Explanation

Correct Answers

B:

Among the paired tasks to give a module input a fallback when callers omit it and expose a selected Terraform expression to the caller or CLI, Output block serves the 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. The other task must be covered by a separate mechanism.

E:

Among the paired tasks to give a module input a fallback when callers omit it and expose a selected Terraform expression to the caller or CLI, Variable default value serves the requirement to give a module input a fallback when callers omit it: A variable default supplies a value without requiring each caller to pass that argument. The other task must be covered by a separate mechanism.

Incorrect Answers

A:

The requirements are give a module input a fallback when callers omit it and expose a selected Terraform expression to the caller or CLI, while Required input variable supports the different task to prompt for or provide a root-module value when no default exists: A variable block without a default requires a value supplied through a supported input channel. That capability is outside the two selected responsibilities.

C:

The requirements are give a module input a fallback when callers omit it and expose a selected Terraform expression to the caller or CLI, while Variable type constraint supports the different task to restrict an input to an expected Terraform type: A type declaration such as number or object(...) lets Terraform validate and convert compatible inputs. That capability is outside the two selected responsibilities.

D:

The requirements are give a module input a fallback when callers omit it and expose a selected Terraform expression to the caller or CLI, while Local value expression supports the different task to name a computed expression used repeatedly inside one module: locals blocks evaluate named expressions available as local.name within that module. That capability is outside the two selected responsibilities.

Question 369

The team is documenting risks of Init without backend setup while planning to work on configuration validation while deliberately skipping backend initialization. Which caveat specifically applies to that mechanism?

  1. Commands needing live state might not work without a configured backend.
  2. Initialization is not the command for creating managed resources.
  3. Downloading a module does not create its infrastructure.
  4. It does not automatically move the old state into the new backend.
  5. Operators should safeguard and verify state before a migration.

Explanation

Correct Answer

A:

For Init without backend setup in the task to work on configuration validation while deliberately skipping backend initialization, the important caution is: Commands needing live state might not work without a configured backend. The reason this matters is its actual behavior: terraform init -backend=false skips the backend initialization step where appropriate.

Incorrect Answers

B:

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 without backend setup: terraform init configures backend access and fetches required modules and providers. The question concerns Init without backend setup acting to work on configuration validation while deliberately skipping backend initialization, not a limit of Initialize a new working directory.

C:

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 without backend setup: terraform init resolves module sources and downloads them to the local module cache. The question concerns Init without backend setup acting to work on configuration validation while deliberately skipping backend initialization, not a limit of Module download on init.

D:

The proposed warning belongs to Backend reconfiguration during init, which serves the different goal to accept an intentional backend configuration change without migrating state, rather than to Init without backend setup: terraform init -reconfigure disregards the existing backend initialization settings and uses new ones. The question concerns Init without backend setup acting to work on configuration validation while deliberately skipping backend initialization, not a limit of Backend reconfiguration during init.

E:

The proposed warning belongs to Backend migration during init, which serves the different goal to move existing state to a newly selected backend when changing its storage, rather than to Init without backend setup: terraform init -migrate-state offers state migration when a backend configuration changes. The question concerns Init without backend setup acting to work on configuration validation while deliberately skipping backend initialization, not a limit of Backend migration during init.

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.

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