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

Question 220

The implementation must both adopt a remote object from the correct account or region and run a plan after importing an object to check unexpected updates. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. Import validation follow-up
  2. terraform import CLI
  3. Configuration-driven import block
  4. Import resource address matching
  5. Import under aliased provider

Explanation

Correct Answers

A:

Among the paired tasks to adopt a remote object from the correct account or region and run a plan after importing an object to check unexpected updates, Import validation follow-up serves the requirement to run a plan after importing an object to check unexpected updates: A post-import plan reveals whether declared settings match the newly adopted remote object. The other task must be covered by a separate mechanism.

E:

Among the paired tasks to adopt a remote object from the correct account or region and run a plan after importing an object to check unexpected updates, Import under aliased provider serves the requirement to adopt a remote object from the correct account or region: The target resource's selected provider configuration determines how Terraform locates and reads the imported object. The other task must be covered by a separate mechanism.

Incorrect Answers

B:

The requirements are adopt a remote object from the correct account or region and run a plan after importing an object to check unexpected updates, while terraform import CLI supports the different task to bring a pre-existing remote object under a resource address in Terraform state: terraform import ADDRESS ID binds the specified remote object to a declared resource instance. That capability is outside the two selected responsibilities.

C:

The requirements are adopt a remote object from the correct account or region and run a plan after importing an object to check unexpected updates, while Configuration-driven import block supports the different task to declare an import target for normal planning and apply: An import block can specify a resource address and provider-specific identity for import. That capability is outside the two selected responsibilities.

D:

The requirements are adopt a remote object from the correct account or region and run a plan after importing an object to check unexpected updates, while Import resource address matching supports the different task to map a discovered object to the intended Terraform resource instance address: Import uses a Terraform resource address that corresponds to the configuration intended to manage the object. That capability is outside the two selected responsibilities.

Question 221

During a Terraform 1.12 implementation, the immediate requirement is to refer to an instance selected by its map or set key. Which mechanism most directly meets this particular need?

  1. Reference-based evaluation order
  2. Self reference in provisioners
  3. Module output reference
  4. Direct attribute reference
  5. Implicit resource dependency
  6. Resource address for for_each instance

Explanation

Correct Answer

F:

The task is to refer to an instance selected by its map or set key; Resource address for for_each instance directly supports that requirement: A for_each resource uses keyed addressing such as example["prod"] and exposes a key-specific object. Its relevant boundary is: A numeric count index is not interchangeable with a for_each string key.

Incorrect Answers

A:

Reference-based evaluation order is designed to avoid assuming files or block order determines operations, whereas this task is to refer to an instance selected by its map or set key: Terraform's graph follows expression dependencies, not the physical line order of configuration blocks. Against Resource address for for_each instance, its limitation is: References can still form invalid cycles if dependencies point back to each other.

B:

Self reference in provisioners is designed to refer to the current managed object in its own provisioner context, whereas this task is to refer to an instance selected by its map or set key: The self object is available in supported provisioner and connection contexts for the containing resource. Against Resource address for for_each instance, its limitation is: It is not a general replacement for cross-resource references.

C:

Module output reference is designed to use a value explicitly exported by a child module, whereas this task is to refer to an instance selected by its map or set key: The parent reads a child output through module.name.output_name rather than reaching into child internals. Against Resource address for for_each instance, its limitation is: Unexported child resource attributes are not directly available to the caller.

D:

Direct attribute reference is designed to pass the generated ID of one resource into a dependent resource, whereas this task is to refer to an instance selected by its map or set key: An expression such as aws_vpc.main.id links a consuming argument to an upstream resource attribute. Against Resource address for for_each instance, its limitation is: Using a plain string ID loses that implicit graph dependency.

E:

Implicit resource dependency is designed to ensure a dependent resource waits for a referenced upstream attribute, whereas this task is to refer to an instance selected by its map or set key: Terraform infers dependencies when expressions reference other resources. Against Resource address for for_each instance, its limitation is: An explicit depends_on is unnecessary for relationships already expressed through references.

Question 222

The team is documenting risks of Initialize a new working directory while planning to prepare backend and plugin dependencies before planning. Which caveat specifically applies to that mechanism?

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

Explanation

Correct Answer

D:

For Initialize a new working directory in the task to prepare backend and plugin dependencies before planning, the important caution is: Initialization is not the command for creating managed resources. The reason this matters is its actual behavior: terraform init configures backend access and fetches required modules and providers.

Incorrect Answers

A:

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 Initialize a new working directory: It is normally safe to run terraform init repeatedly to satisfy updated dependencies. The question concerns Initialize a new working directory acting to prepare backend and plugin dependencies before planning, not a limit of Initialization as safe repeated step.

B:

The proposed warning belongs to Init provider plugin upgrade control, which serves the different goal to preserve locked provider selections in routine CI initialization, rather than to Initialize a new working directory: A normal terraform init honors the existing dependency lock selections unless update is requested. The question concerns Initialize a new working directory acting to prepare backend and plugin dependencies before planning, not a limit of Init provider plugin upgrade control.

C:

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 Initialize a new working directory: terraform init -backend=false skips the backend initialization step where appropriate. The question concerns Initialize a new working directory acting to prepare backend and plugin dependencies before planning, not a limit of Init without backend setup.

Question 223

A team is adjusting its declarative infrastructure process to download required plugins into the initialized working environment. Which mechanism most directly meets this particular need?

  1. terraform providers lock
  2. Provider version compatibility operator
  3. required_providers source
  4. Provider installation during init

Explanation

Correct Answer

D:

The task is to download required plugins into the initialized working environment; Provider installation during init directly supports that requirement: terraform init resolves provider dependencies and installs or reuses selected plugin packages. Its relevant boundary is: It does not apply infrastructure changes during initialization.

Incorrect Answers

A:

terraform providers lock is designed to populate or update provider checksum selections in the lock file, whereas this task is to download required plugins into the initialized working environment: The providers lock command can record provider package checksums for selected target platforms. Against Provider installation during init, its limitation is: It is not the command that downloads and configures all root-module infrastructure.

B:

Provider version compatibility operator is designed to allow only nonbreaking versions in a specified range, whereas this task is to download required plugins into the initialized working environment: A constraint like ~> 5.2 permits compatible versions within that bound while excluding the next incompatible major range. Against Provider installation during init, its limitation is: It is a permitted range, not proof of the installed provider's actual version.

C:

required_providers source addresses the different requirement to identify the namespace and provider plugin that Terraform should install: The required_providers map supplies a provider source address such as hashicorp/aws for dependency resolution; this does not by itself satisfy the requested task to download required plugins into the initialized working environment. For the stated need, Provider installation during init is the more direct mechanism.

Question 224

A design uses Terraform state locking to prevent two concurrent runs from writing the same state snapshot. Which qualification applies to the named mechanism?

  1. Not every backend supports locking in the same way.
  2. A configuration-only validation step typically does not need to change state.
  3. It does not itself activate locking on a backend that lacks that feature.
  4. Incorrectly breaking an active lock risks competing state modifications.

Explanation

Correct Answer

A:

For Terraform state locking in the task to prevent two concurrent runs from writing the same state snapshot, the important caution is: Not every backend supports locking in the same way. The reason this matters is its actual behavior: A backend with locking support serializes operations that could corrupt shared state.

Incorrect Answers

B:

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 Terraform state locking: Terraform tries to obtain a state lock when the chosen backend supports it. The question concerns Terraform state locking acting to prevent two concurrent runs from writing the same state snapshot, not a limit of Lock acquisition before writes.

C:

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 Terraform state locking: The lock-timeout flag controls how long supported operations retry obtaining a lock. The question concerns Terraform state locking acting to prevent two concurrent runs from writing the same state snapshot, not a limit of terraform -lock-timeout behavior.

D:

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 Terraform state locking: force-unlock accepts a lock ID and bypasses normal waiting for an abandoned lock. The question concerns Terraform state locking acting to prevent two concurrent runs from writing the same state snapshot, not a limit of terraform force-unlock.

Question 225

The team is documenting risks of Child module input variable while planning to pass a caller-defined value into a reusable child module. Which caveat specifically applies to that mechanism?

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

Explanation

Correct Answer

C:

For Child module input variable in the task to pass a caller-defined value into a reusable child module, the important caution is: An input declared in the child is not implicitly available as var.name in the parent. The reason this matters is its actual behavior: The child declares a variable and the parent's module block assigns a value to that argument.

Incorrect Answers

A:

The proposed warning belongs to Child module output scope, which serves the different goal to expose specific child values to its parent with an output block, rather than to Child module input variable: The parent can use module.child.output_name only when the child explicitly declares that output. The question concerns Child module input variable acting to pass a caller-defined value into a reusable child module, not a limit of Child module output scope.

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 Child module input variable: Local values belong to the defining module and are referenced through local.name in that scope. The question concerns Child module input variable acting to pass a caller-defined value into a reusable child module, not a limit of Module local values.

D:

The proposed warning belongs to Root variable namespace, which serves the different goal to distinguish CLI-supplied root inputs from child inputs, rather than to Child module input variable: CLI -var arguments set variables declared in the root module; child values pass through module call arguments. The question concerns Child module input variable acting to pass a caller-defined value into a reusable child module, not a limit of Root variable namespace.

Question 226

The rollout owner asks whether HCP Terraform private module registry is sufficient to share approved reusable modules within an organization. Which limitation specifically concerns that mechanism?

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

Explanation

Correct Answer

A:

For HCP Terraform private module registry in the task to share approved reusable modules within an organization, the important caution is: Publishing a module is different from executing a workspace run. The reason this matters is its actual behavior: A private registry distributes versioned modules to organization workspaces and teams.

Incorrect Answers

B:

The proposed warning belongs to HCP Terraform drift detection, which serves the different goal to monitor for resources that have diverged from workspace configuration, rather than to HCP Terraform private module registry: Health assessments can identify drift between tracked resources and desired configuration. The question concerns HCP Terraform private module registry acting to share approved reusable modules within an organization, not a limit of HCP Terraform drift detection.

C:

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

D:

The proposed warning belongs to HCP Terraform dynamic provider credentials, which serves the different goal to avoid long-lived static cloud credentials in workspace variables, rather than to HCP Terraform private module registry: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. The question concerns HCP Terraform private module registry acting to share approved reusable modules within an organization, not a limit of HCP Terraform dynamic provider credentials.

Question 227

A team reviews the use of Resource address for for_each instance in Terraform 1.12. Which purpose matches its actual behavior?

  1. avoid assuming files or block order determines operations
  2. pass the generated ID of one resource into a dependent resource
  3. refer to an instance selected by its map or set key
  4. refer to the current managed object in its own provisioner context
  5. use a value explicitly exported by a child module

Explanation

Correct Answer

C:

The practical result of Resource address for for_each instance, used to refer to an instance selected by its map or set key, is: A for_each resource uses keyed addressing such as example["prod"] and exposes a key-specific object. A qualification for this effect is: A numeric count index is not interchangeable with a for_each string key.

Incorrect Answers

A:

That outcome applies to Reference-based evaluation order, intended to avoid assuming files or block order determines operations, rather than the question's feature Resource address for for_each instance: Terraform's graph follows expression dependencies, not the physical line order of configuration blocks. Unlike Reference-based evaluation order, Resource address for for_each instance is intended to refer to an instance selected by its map or set key, not to avoid assuming files or block order determines operations.

B:

That outcome applies to Direct attribute reference, intended to pass the generated ID of one resource into a dependent resource, rather than the question's feature Resource address for for_each instance: An expression such as aws_vpc.main.id links a consuming argument to an upstream resource attribute. Unlike Direct attribute reference, Resource address for for_each instance is intended to refer to an instance selected by its map or set key, not to pass the generated ID of one resource into a dependent resource.

D:

That outcome applies to Self reference in provisioners, intended to refer to the current managed object in its own provisioner context, rather than the question's feature Resource address for for_each instance: The self object is available in supported provisioner and connection contexts for the containing resource. Unlike Self reference in provisioners, Resource address for for_each instance is intended to refer to an instance selected by its map or set key, not to refer to the current managed object in its own provisioner context.

E:

That outcome applies to Module output reference, intended to use a value explicitly exported by a child module, rather than the question's feature Resource address for for_each instance: The parent reads a child output through module.name.output_name rather than reaching into child internals. Unlike Module output reference, Resource address for for_each instance is intended to refer to an instance selected by its map or set key, not to use a value explicitly exported by a child module.

Question 228

For a new infrastructure repository, the team wants to preview the proposed actions before changing real resources. Which mechanism most directly meets this particular need?

  1. Infrastructure execution plan
  2. Declarative infrastructure model
  3. Terraform resource declaration
  4. Infrastructure as code definition

Explanation

Correct Answer

A:

The task is to preview the proposed actions before changing real resources; Infrastructure execution plan directly supports that requirement: A Terraform plan calculates proposed actions from configuration, state, providers, and current observations. Its relevant boundary is: Reviewing a plan is different from committing its effects to the remote system.

Incorrect Answers

B:

Declarative infrastructure model is designed to specify an end state rather than every API request, whereas this task is to preview the proposed actions before changing real resources: A declarative model states the desired objects and lets Terraform determine an execution path from configuration and state. Against Infrastructure execution plan, its limitation is: It does not mean Terraform can automatically infer missing provider configuration.

C:

Terraform resource declaration is designed to describe one managed infrastructure object in a configuration, whereas this task is to preview the proposed actions before changing real resources: A resource block represents an object that Terraform will create, update, or destroy through a provider. Against Infrastructure execution plan, its limitation is: A resource declaration is not the same as a read-only data lookup.

D:

Infrastructure as code definition is designed to represent desired infrastructure in reviewable configuration files, whereas this task is to preview the proposed actions before changing real resources: Infrastructure as code describes infrastructure through machine-readable files instead of relying only on manual console operations. Against Infrastructure execution plan, its limitation is: The configuration still needs a tool and credentials to change actual systems.

Question 229

A platform engineering group needs to use import planning support to help write resource HCL for an existing object. Which mechanism most directly meets this particular need?

  1. Import resource address matching
  2. Import without recreation
  3. terraform import CLI
  4. Generate import configuration where supported
  5. Configuration-driven import block

Explanation

Correct Answer

D:

The task is to use import planning support to help write resource HCL for an existing object; Generate import configuration where supported directly supports that requirement: Terraform supports generating configuration with appropriate import workflows for certain imported resources. Its relevant boundary is: Generated HCL requires review and may include attributes needing cleanup.

Incorrect Answers

A:

Import resource address matching is designed to map a discovered object to the intended Terraform resource instance address, whereas this task is to use import planning support to help write resource HCL for an existing object: Import uses a Terraform resource address that corresponds to the configuration intended to manage the object. Against Generate import configuration where supported, its limitation is: A remote object ID is not interchangeable with the Terraform address.

B:

Import without recreation is designed to adopt an existing object rather than creating a new duplicate, whereas this task is to use import planning support to help write resource HCL for an existing object: Import connects an existing provider object to the Terraform state mapping. Against Generate import configuration where supported, its limitation is: A post-import plan must still be checked for configuration differences.

C:

terraform import CLI is designed to bring a pre-existing remote object under a resource address in Terraform state, whereas this task is to use import planning support to help write resource HCL for an existing object: terraform import ADDRESS ID binds the specified remote object to a declared resource instance. Against Generate import configuration where supported, its limitation is: The import command alone does not generate a complete root configuration.

E:

Configuration-driven import block is designed to declare an import target for normal planning and apply, whereas this task is to use import planning support to help write resource HCL for an existing object: An import block can specify a resource address and provider-specific identity for import. Against Generate import configuration where supported, its limitation is: The matching managed resource configuration must exist or be generated appropriately.

Question 230

A technical review has three distinct objectives: prepare backend and plugin dependencies before planning; move existing state to a newly selected backend when changing its storage; and rerun initialization after adding a provider or changing module sources. Which THREE mechanisms should the team identify for these respective needs? Choose THREE.

  1. Module download on init
  2. Initialization as safe repeated step
  3. Initialize a new working directory
  4. Backend migration during init
  5. Backend reconfiguration during init

Explanation

Correct Answers

B:

In the workflow combining prepare backend and plugin dependencies before planning, move existing state to a newly selected backend when changing its storage, and rerun initialization after adding a provider or changing module sources, Initialization as safe repeated step correctly addresses the individual goal to rerun initialization after adding a provider or changing module sources: It is normally safe to run terraform init repeatedly to satisfy updated dependencies. It is one of three separately required capabilities.

C:

In the workflow combining prepare backend and plugin dependencies before planning, move existing state to a newly selected backend when changing its storage, and rerun initialization after adding a provider or changing module sources, Initialize a new working directory correctly addresses the individual goal to prepare backend and plugin dependencies before planning: terraform init configures backend access and fetches required modules and providers. It is one of three separately required capabilities.

D:

In the workflow combining prepare backend and plugin dependencies before planning, move existing state to a newly selected backend when changing its storage, and rerun initialization after adding a provider or changing module sources, Backend migration during init correctly addresses the individual goal to move existing state to a newly selected backend when changing its storage: terraform init -migrate-state offers state migration when a backend configuration changes. It is one of three separately required capabilities.

Incorrect Answers

A:

Compared with the three tasks to prepare backend and plugin dependencies before planning, move existing state to a newly selected backend when changing its storage, and rerun initialization after adding a provider or changing module sources, Module download on init primarily supports an unrelated request to install externally sourced child modules referenced by the root module: terraform init resolves module sources and downloads them to the local module cache. Therefore this option is not among the three specified mechanisms.

E:

Compared with the three tasks to prepare backend and plugin dependencies before planning, move existing state to a newly selected backend when changing its storage, and rerun initialization after adding a provider or changing module sources, Backend reconfiguration during init primarily supports an unrelated request to accept an intentional backend configuration change without migrating state: terraform init -reconfigure disregards the existing backend initialization settings and uses new ones. Therefore this option is not among the three specified mechanisms.

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