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

Question 210

Before adopting Resource address for count instance to select the exact indexed instance from count-created resources, which statement sets an accurate boundary?

  1. Using a plain string ID loses that implicit graph dependency.
  2. The index is not a stable semantic key if list ordering changes.
  3. A numeric count index is not interchangeable with a for_each string key.
  4. Unexported child resource attributes are not directly available to the caller.

Explanation

Correct Answer

B:

For Resource address for count instance in the task to select the exact indexed instance from count-created resources, the important caution is: The index is not a stable semantic key if list ordering changes. The reason this matters is its actual behavior: Count-created instances use numeric indices in expressions and state addresses, such as example[1].

Incorrect Answers

A:

The proposed warning belongs to Direct attribute reference, which serves the different goal to pass the generated ID of one resource into a dependent resource, rather than to Resource address for count instance: An expression such as aws_vpc.main.id links a consuming argument to an upstream resource attribute. The question concerns Resource address for count instance acting to select the exact indexed instance from count-created resources, not a limit of Direct attribute reference.

C:

The proposed warning belongs to Resource address for for_each instance, which serves the different goal to refer to an instance selected by its map or set key, rather than to Resource address for count instance: A for_each resource uses keyed addressing such as example["prod"] and exposes a key-specific object. The question concerns Resource address for count instance acting to select the exact indexed instance from count-created resources, not a limit of Resource address for for_each instance.

D:

The listed caution belongs specifically to Module output reference, used to use a value explicitly exported by a child module: The parent reads a child output through module.name.output_name rather than reaching into child internals; the feature under review is instead Resource address for count instance, so this answer attaches another feature's qualification to the wrong mechanism.

Question 211

For a new infrastructure repository, the team wants to pass a caller-defined value into a reusable child module. Which mechanism most directly meets this particular need?

  1. Module local values
  2. Child module output scope
  3. Child module input variable
  4. Root variable namespace
  5. Provider configuration scope

Explanation

Correct Answer

C:

The task is to pass a caller-defined value into a reusable child module; Child module input variable directly supports that requirement: The child declares a variable and the parent's module block assigns a value to that argument. Its relevant boundary is: An input declared in the child is not implicitly available as var.name in the parent.

Incorrect Answers

A:

Module local values is designed to compute module-specific intermediate values without exporting them, whereas this task is to pass a caller-defined value into a reusable child module: Local values belong to the defining module and are referenced through local.name in that scope. Against Child module input variable, its limitation is: They are not automatically exposed through a module output reference.

B:

Child module output scope is designed to expose specific child values to its parent with an output block, whereas this task is to pass a caller-defined value into a reusable child module: The parent can use module.child.output_name only when the child explicitly declares that output. Against Child module input variable, its limitation is: Internal child locals and resource attributes remain encapsulated by default.

D:

Root variable namespace is designed to distinguish CLI-supplied root inputs from child inputs, whereas this task is to pass a caller-defined value into a reusable child module: CLI -var arguments set variables declared in the root module; child values pass through module call arguments. Against Child module input variable, its limitation is: A variable with the same name in two modules is a separate declaration.

E:

Provider configuration scope is designed to keep provider instances configured in the root and pass them to child modules, whereas this task is to pass a caller-defined value into a reusable child module: A root module can explicitly map provider configurations into child module calls. Against Child module input variable, its limitation is: An aliased provider is not automatically inherited as a child alias.

Question 212

The deployment owner requests a reliable way to share approved reusable modules within an organization. Which mechanism most directly meets this particular need?

  1. HCP Terraform policy sets
  2. HCP Terraform private module registry
  3. HCP Terraform dynamic provider credentials
  4. HCP Terraform auditability
  5. HCP Terraform drift detection

Explanation

Correct Answer

B:

The task is to share approved reusable modules within an organization; HCP Terraform private module registry directly supports that requirement: A private registry distributes versioned modules to organization workspaces and teams. Its relevant boundary is: Publishing a module is different from executing a workspace run.

Incorrect Answers

A:

HCP Terraform policy sets is designed to enforce organizational rules during infrastructure runs, whereas this task is to share approved reusable modules within an organization: HCP Terraform can evaluate governance policies such as Sentinel or OPA as part of run controls. Against HCP Terraform private module registry, its limitation is: Policies assess plans or configuration; they are not Terraform resource providers.

C:

HCP Terraform dynamic provider credentials is designed to avoid long-lived static cloud credentials in workspace variables, whereas this task is to share approved reusable modules within an organization: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. Against HCP Terraform private module registry, its limitation is: The target provider and cloud identity federation must be configured correctly.

D:

HCP Terraform auditability is designed to retain run and change history for collaboration and review, whereas this task is to share approved reusable modules within an organization: Workspace run histories help teams trace proposed and executed infrastructure operations. Against HCP Terraform private module registry, its limitation is: A recorded run history is not the same as versioned source code approval.

E:

HCP Terraform drift detection is designed to monitor for resources that have diverged from workspace configuration, whereas this task is to share approved reusable modules within an organization: Health assessments can identify drift between tracked resources and desired configuration. Against HCP Terraform private module registry, its limitation is: HCP Terraform health assessments require Standard or Premium edition and an eligible workspace; detection itself does not automatically correct drift.

Question 213

A Terraform rollout has two separate requirements: first, populate or update provider checksum selections in the lock file; second, allow only nonbreaking versions in a specified range. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Provider version compatibility operator; then use terraform providers lock.
  2. First use required_providers source; then use Provider version constraint.
  3. First use Provider version constraint; then use Provider version compatibility operator.
  4. First use terraform providers lock; then use Provider version compatibility operator.
  5. First use terraform providers lock; then use required_providers source.

Explanation

Correct Answer

D:

The first requirement, to populate or update provider checksum selections in the lock file, is handled by terraform providers lock: The providers lock command can record provider package checksums for selected target platforms. The second requirement, to allow only nonbreaking versions in a specified range, is handled by Provider version compatibility operator: A constraint like ~> 5.2 permits compatible versions within that bound while excluding the next incompatible major range. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to populate or update provider checksum selections in the lock file and allow only nonbreaking versions in a specified range, the first candidate Provider version compatibility operator addresses allow only nonbreaking versions in a specified range; the second candidate terraform providers lock addresses populate or update provider checksum selections in the lock file. This mapping fails because the first mechanism primarily supports the task to allow only nonbreaking versions in a specified range and the second mechanism primarily supports the task to populate or update provider checksum selections in the lock file; the actual requirements are populate or update provider checksum selections in the lock file first and allow only nonbreaking versions in a specified range second.

B:

For the requested tasks to populate or update provider checksum selections in the lock file and allow only nonbreaking versions in a specified range, the first candidate required_providers source addresses identify the namespace and provider plugin that Terraform should install; the second candidate Provider version constraint addresses restrict acceptable versions of an infrastructure provider. This mapping fails because the first mechanism primarily supports the task to identify the namespace and provider plugin that Terraform should install and the second mechanism primarily supports the task to restrict acceptable versions of an infrastructure provider; the actual requirements are populate or update provider checksum selections in the lock file first and allow only nonbreaking versions in a specified range second.

C:

For the requested tasks to populate or update provider checksum selections in the lock file and allow only nonbreaking versions in a specified range, the first candidate Provider version constraint addresses restrict acceptable versions of an infrastructure provider; the second candidate Provider version compatibility operator addresses allow only nonbreaking versions in a specified range. This mapping fails because the first mechanism primarily supports the task to restrict acceptable versions of an infrastructure provider; the actual requirements are populate or update provider checksum selections in the lock file first and allow only nonbreaking versions in a specified range second.

E:

For the requested tasks to populate or update provider checksum selections in the lock file and allow only nonbreaking versions in a specified range, the first candidate terraform providers lock addresses populate or update provider checksum selections in the lock file; the second candidate required_providers source addresses identify the namespace and provider plugin that Terraform should install. This mapping fails because the second mechanism primarily supports the task to identify the namespace and provider plugin that Terraform should install; the actual requirements are populate or update provider checksum selections in the lock file first and allow only nonbreaking versions in a specified range second.

Question 214

A Terraform rollout has two separate requirements: first, select the exact indexed instance from count-created resources; second, use a value explicitly exported by a child module. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use Self reference in provisioners; then use Reference-based evaluation order.
  2. First use Resource address for count instance; then use Self reference in provisioners.
  3. First use Resource address for count instance; then use Module output reference.
  4. First use Reference-based evaluation order; then use Module output reference.
  5. First use Module output reference; then use Resource address for count instance.

Explanation

Correct Answer

C:

The first requirement, to select the exact indexed instance from count-created resources, is handled by Resource address for count instance: Count-created instances use numeric indices in expressions and state addresses, such as example[1]. The second requirement, to use a value explicitly exported by a child module, is handled by Module output reference: The parent reads a child output through module.name.output_name rather than reaching into child internals. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to select the exact indexed instance from count-created resources and use a value explicitly exported by a child module, the first candidate Self reference in provisioners addresses refer to the current managed object in its own provisioner context; the second candidate Reference-based evaluation order addresses avoid assuming files or block order determines operations. This mapping fails because the first mechanism primarily supports the task to refer to the current managed object in its own provisioner context and the second mechanism primarily supports the task to avoid assuming files or block order determines operations; the actual requirements are select the exact indexed instance from count-created resources first and use a value explicitly exported by a child module second.

B:

For the requested tasks to select the exact indexed instance from count-created resources and use a value explicitly exported by a child module, the first candidate Resource address for count instance addresses select the exact indexed instance from count-created resources; the second candidate Self reference in provisioners addresses refer to the current managed object in its own provisioner context. This mapping fails because the second mechanism primarily supports the task to refer to the current managed object in its own provisioner context; the actual requirements are select the exact indexed instance from count-created resources first and use a value explicitly exported by a child module second.

D:

For the requested tasks to select the exact indexed instance from count-created resources and use a value explicitly exported by a child module, the first candidate Reference-based evaluation order addresses avoid assuming files or block order determines operations; the second candidate Module output reference addresses use a value explicitly exported by a child module. This mapping fails because the first mechanism primarily supports the task to avoid assuming files or block order determines operations; the actual requirements are select the exact indexed instance from count-created resources first and use a value explicitly exported by a child module second.

E:

For the requested tasks to select the exact indexed instance from count-created resources and use a value explicitly exported by a child module, the first candidate Module output reference addresses use a value explicitly exported by a child module; the second candidate Resource address for count instance addresses select the exact indexed instance from count-created resources. This mapping fails because the first mechanism primarily supports the task to use a value explicitly exported by a child module and the second mechanism primarily supports the task to select the exact indexed instance from count-created resources; the actual requirements are select the exact indexed instance from count-created resources first and use a value explicitly exported by a child module second.

Question 215

A Terraform runbook describes the mechanism "Initialize a new working directory". Which responsibility should a reviewer associate with it?

  1. work on configuration validation while deliberately skipping backend initialization
  2. preserve locked provider selections in routine CI initialization
  3. prepare backend and plugin dependencies before planning
  4. rerun initialization after adding a provider or changing module sources

Explanation

Correct Answer

C:

The practical result of Initialize a new working directory, used to prepare backend and plugin dependencies before planning, is: terraform init configures backend access and fetches required modules and providers. A qualification for this effect is: Initialization is not the command for creating managed resources.

Incorrect Answers

A:

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 Initialize a new working directory: terraform init -backend=false skips the backend initialization step where appropriate. Unlike Init without backend setup, Initialize a new working directory is intended to prepare backend and plugin dependencies before planning, not to work on configuration validation while deliberately skipping backend initialization.

B:

That outcome applies to Init provider plugin upgrade control, intended to preserve locked provider selections in routine CI initialization, rather than the question's feature Initialize a new working directory: A normal terraform init honors the existing dependency lock selections unless update is requested. Unlike Init provider plugin upgrade control, Initialize a new working directory is intended to prepare backend and plugin dependencies before planning, not to preserve locked provider selections in routine CI 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 Initialize a new working directory: It is normally safe to run terraform init repeatedly to satisfy updated dependencies. Unlike Initialization as safe repeated step, Initialize a new working directory is intended to prepare backend and plugin dependencies before planning, not to rerun initialization after adding a provider or changing module sources.

Question 216

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

  1. let a run wait briefly rather than fail immediately when state is busy
  2. remove a stale lock only after confirming that no valid run owns it
  3. prevent two concurrent runs from writing the same state snapshot
  4. avoid racing state mutations when several operators run Terraform

Explanation

Correct Answer

C:

The practical result of Terraform state locking, used to prevent two concurrent runs from writing the same state snapshot, is: A backend with locking support serializes operations that could corrupt shared state. A qualification for this effect is: Not every backend supports locking in the same way.

Incorrect Answers

A:

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 Terraform state locking: The lock-timeout flag controls how long supported operations retry obtaining a lock. Unlike terraform -lock-timeout behavior, Terraform state locking is intended to prevent two concurrent runs from writing the same state snapshot, not to let a run wait briefly rather than fail immediately when state is busy.

B:

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 Terraform state locking: force-unlock accepts a lock ID and bypasses normal waiting for an abandoned lock. Unlike terraform force-unlock, Terraform state locking is intended to prevent two concurrent runs from writing the same state snapshot, not to remove a stale lock only after confirming that no valid run owns it.

D:

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 Terraform state locking: Terraform tries to obtain a state lock when the chosen backend supports it. Unlike Lock acquisition before writes, Terraform state locking is intended to prevent two concurrent runs from writing the same state snapshot, not to avoid racing state mutations when several operators run Terraform.

Question 217

The implementation must both record intended infrastructure settings under version control and translate declarative resources into operations on a platform. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. Infrastructure provider API
  2. Terraform resource declaration
  3. Declarative infrastructure model
  4. Infrastructure as code definition
  5. Desired configuration

Explanation

Correct Answers

A:

Among the paired tasks to record intended infrastructure settings under version control and translate declarative resources into operations on a platform, Infrastructure provider API serves the requirement to translate declarative resources into operations on a platform: Provider plugins supply resource implementations and call remote APIs when Terraform reconciles infrastructure. The other task must be covered by a separate mechanism.

E:

Among the paired tasks to record intended infrastructure settings under version control and translate declarative resources into operations on a platform, Desired configuration serves the requirement to record intended infrastructure settings under version control: Configuration expresses the operator's intended infrastructure and is the starting point for planning. The other task must be covered by a separate mechanism.

Incorrect Answers

B:

The requirements are record intended infrastructure settings under version control and translate declarative resources into operations on a platform, while Terraform resource declaration supports the different task to describe one managed infrastructure object in a configuration: A resource block represents an object that Terraform will create, update, or destroy through a provider. That capability is outside the two selected responsibilities.

C:

The requirements are record intended infrastructure settings under version control and translate declarative resources into operations on a platform, while Declarative infrastructure model supports the different task to specify an end state rather than every API request: A declarative model states the desired objects and lets Terraform determine an execution path from configuration and state. That capability is outside the two selected responsibilities.

D:

The requirements are record intended infrastructure settings under version control and translate declarative resources into operations on a platform, while Infrastructure as code definition supports the different task to represent desired infrastructure in reviewable configuration files: Infrastructure as code describes infrastructure through machine-readable files instead of relying only on manual console operations. That capability is outside the two selected responsibilities.

Question 218

An operator chooses the mechanism "Child module input variable" for a Terraform project. Which outcome should this choice support?

  1. distinguish CLI-supplied root inputs from child inputs
  2. pass a caller-defined value into a reusable child module
  3. compute module-specific intermediate values without exporting them
  4. expose specific child values to its parent with an output block

Explanation

Correct Answer

B:

The practical result of Child module input variable, used to pass a caller-defined value into a reusable child module, is: The child declares a variable and the parent's module block assigns a value to that argument. A qualification for this effect is: An input declared in the child is not implicitly available as var.name in the parent.

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 Child module input variable: CLI -var arguments set variables declared in the root module; child values pass through module call arguments. Unlike Root variable namespace, Child module input variable is intended to pass a caller-defined value into a reusable child module, not to distinguish CLI-supplied root inputs from child inputs.

C:

That outcome applies to Module local values, intended to compute module-specific intermediate values without exporting them, rather than the question's feature Child module input variable: Local values belong to the defining module and are referenced through local.name in that scope. Unlike Module local values, Child module input variable is intended to pass a caller-defined value into a reusable child module, not to compute module-specific intermediate values without exporting them.

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 Child module input variable: The parent can use module.child.output_name only when the child explicitly declares that output. Unlike Child module output scope, Child module input variable is intended to pass a caller-defined value into a reusable child module, not to expose specific child values to its parent with an output block.

Question 219

A colleague recommends the Terraform concept "HCP Terraform private module registry". 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 approved reusable modules within an organization
  4. avoid long-lived static cloud credentials in workspace variables

Explanation

Correct Answer

C:

The practical result of HCP Terraform private module registry, used to share approved reusable modules within an organization, is: A private registry distributes versioned modules to organization workspaces and teams. A qualification for this effect is: Publishing a module is different from executing a workspace run.

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 private module registry: Health assessments can identify drift between tracked resources and desired configuration. Unlike HCP Terraform drift detection, HCP Terraform private module registry is intended to share approved reusable modules within an organization, not to monitor for resources that have diverged from workspace configuration.

B:

That outcome applies to HCP Terraform auditability, intended to retain run and change history for collaboration and review, rather than the question's feature HCP Terraform private module registry: Workspace run histories help teams trace proposed and executed infrastructure operations. Unlike HCP Terraform auditability, HCP Terraform private module registry is intended to share approved reusable modules within an organization, not to retain run and change history for collaboration and review.

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 private module registry: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. Unlike HCP Terraform dynamic provider credentials, HCP Terraform private module registry is intended to share approved reusable modules within an organization, not to avoid long-lived static cloud credentials in workspace variables.

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.

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