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

Question 240

A configuration review identifies the need to expose specific child values to its parent with an output block. Which mechanism most directly meets this particular need?

  1. Child module input variable
  2. Provider configuration scope
  3. Child module output scope
  4. Module outputs with repeated instances
  5. Module input defaults

Explanation

Correct Answer

C:

The task is to expose specific child values to its parent with an output block; Child module output scope directly supports that requirement: The parent can use module.child.output_name only when the child explicitly declares that output. Its relevant boundary is: Internal child locals and resource attributes remain encapsulated by default.

Incorrect Answers

A:

Child module input variable is designed to pass a caller-defined value into a reusable child module, whereas this task is to expose specific child values to its parent with an output block: The child declares a variable and the parent's module block assigns a value to that argument. Against Child module output scope, its limitation is: An input declared in the child is not implicitly available as var.name in the parent.

B:

Provider configuration scope is designed to keep provider instances configured in the root and pass them to child modules, whereas this task is to expose specific child values to its parent with an output block: A root module can explicitly map provider configurations into child module calls. Against Child module output scope, its limitation is: An aliased provider is not automatically inherited as a child alias.

D:

Module outputs with repeated instances is designed to read values from every instance created by a counted or keyed module call, whereas this task is to expose specific child values to its parent with an output block: Counted module outputs use numeric indices; for_each module outputs use instance keys. Against Child module output scope, its limitation is: A repeated module call is not the same value shape as a single module output object.

E:

Module input defaults is designed to make some child module arguments optional for callers, whereas this task is to expose specific child values to its parent with an output block: A child variable with a default can be omitted by the caller, allowing the child to use its fallback. Against Child module output scope, its limitation is: A default does not override an explicitly passed module argument.

Question 241

A platform engineering group needs to enforce organizational rules during infrastructure runs. Which mechanism most directly meets this particular need?

  1. HCP Terraform policy sets
  2. HCP Terraform private module registry
  3. HCP Terraform variable sets
  4. HCP Terraform drift detection
  5. HCP Terraform teams and permissions

Explanation

Correct Answer

A:

The task is to enforce organizational rules during infrastructure runs; HCP Terraform policy sets directly supports that requirement: HCP Terraform can evaluate governance policies such as Sentinel or OPA as part of run controls. Its relevant boundary is: Policies assess plans or configuration; they are not Terraform resource providers.

Incorrect Answers

B:

HCP Terraform private module registry is designed to share approved reusable modules within an organization, whereas this task is to enforce organizational rules during infrastructure runs: A private registry distributes versioned modules to organization workspaces and teams. Against HCP Terraform policy sets, its limitation is: Publishing a module is different from executing a workspace run.

C:

HCP Terraform variable sets is designed to share reusable variables across selected workspaces, whereas this task is to enforce organizational rules during infrastructure runs: Variable sets can provide common Terraform or environment variables to applicable workspaces. Against HCP Terraform policy sets, its limitation is: Per-workspace values and precedence must be reviewed when there are overlaps.

D:

HCP Terraform drift detection is designed to monitor for resources that have diverged from workspace configuration, whereas this task is to enforce organizational rules during infrastructure runs: Health assessments can identify drift between tracked resources and desired configuration. Against HCP Terraform policy sets, its limitation is: HCP Terraform health assessments require Standard or Premium edition and an eligible workspace; detection itself does not automatically correct drift.

E:

HCP Terraform teams and permissions is designed to grant workspace access based on collaboration responsibilities, whereas this task is to enforce organizational rules during infrastructure runs: Teams can be assigned appropriate workspace permissions for viewing, planning, and applying. Against HCP Terraform policy sets, its limitation is: Team permission management requires a supported paid HCP Terraform edition; these roles do not replace cloud-provider permissions.

Question 242

An operator chooses the mechanism "Generate import configuration where supported" for a Terraform project. Which outcome should this choice support?

  1. map a discovered object to the intended Terraform resource instance address
  2. adopt a remote object from the correct account or region
  3. adopt an existing object rather than creating a new duplicate
  4. use import planning support to help write resource HCL for an existing object
  5. declare an import target for normal planning and apply
  6. bring a pre-existing remote object under a resource address in Terraform state

Explanation

Correct Answer

D:

The practical result of Generate import configuration where supported, used to use import planning support to help write resource HCL for an existing object, is: Terraform supports generating configuration with appropriate import workflows for certain imported resources. A qualification for this effect is: Generated HCL requires review and may include attributes needing cleanup.

Incorrect Answers

A:

That outcome applies to Import resource address matching, intended to map a discovered object to the intended Terraform resource instance address, rather than the question's feature Generate import configuration where supported: Import uses a Terraform resource address that corresponds to the configuration intended to manage the object. Unlike Import resource address matching, Generate import configuration where supported is intended to use import planning support to help write resource HCL for an existing object, not to map a discovered object to the intended Terraform resource instance address.

B:

That outcome applies to Import under aliased provider, intended to adopt a remote object from the correct account or region, rather than the question's feature Generate import configuration where supported: The target resource's selected provider configuration determines how Terraform locates and reads the imported object. Unlike Import under aliased provider, Generate import configuration where supported is intended to use import planning support to help write resource HCL for an existing object, not to adopt a remote object from the correct account or region.

C:

That outcome applies to Import without recreation, intended to adopt an existing object rather than creating a new duplicate, rather than the question's feature Generate import configuration where supported: Import connects an existing provider object to the Terraform state mapping. Unlike Import without recreation, Generate import configuration where supported is intended to use import planning support to help write resource HCL for an existing object, not to adopt an existing object rather than creating a new duplicate.

E:

That outcome applies to Configuration-driven import block, intended to declare an import target for normal planning and apply, rather than the question's feature Generate import configuration where supported: An import block can specify a resource address and provider-specific identity for import. Unlike Configuration-driven import block, Generate import configuration where supported is intended to use import planning support to help write resource HCL for an existing object, not to declare an import target for normal planning and apply.

F:

That outcome applies to terraform import CLI, intended to bring a pre-existing remote object under a resource address in Terraform state, rather than the question's feature Generate import configuration where supported: terraform import ADDRESS ID binds the specified remote object to a declared resource instance. Unlike terraform import CLI, Generate import configuration where supported is intended to use import planning support to help write resource HCL for an existing object, not to bring a pre-existing remote object under a resource address in Terraform state.

Question 243

A reviewer is asked to choose a mechanism to use a value explicitly exported by a child module. Which mechanism most directly meets this particular need?

  1. Implicit resource dependency
  2. Direct attribute reference
  3. Module output reference
  4. Resource address for count instance

Explanation

Correct Answer

C:

The task is to use a value explicitly exported by a child module; Module output reference directly supports that requirement: The parent reads a child output through module.name.output_name rather than reaching into child internals. Its relevant boundary is: Unexported child resource attributes are not directly available to the caller.

Incorrect Answers

A:

Implicit resource dependency is designed to ensure a dependent resource waits for a referenced upstream attribute, whereas this task is to use a value explicitly exported by a child module: Terraform infers dependencies when expressions reference other resources. Against Module output reference, its limitation is: An explicit depends_on is unnecessary for relationships already expressed through references.

B:

Direct attribute reference is designed to pass the generated ID of one resource into a dependent resource, whereas this task is to use a value explicitly exported by a child module: An expression such as aws_vpc.main.id links a consuming argument to an upstream resource attribute. Against Module output reference, its limitation is: Using a plain string ID loses that implicit graph dependency.

D:

Resource address for count instance is designed to select the exact indexed instance from count-created resources, whereas this task is to use a value explicitly exported by a child module: Count-created instances use numeric indices in expressions and state addresses, such as example[1]. Against Module output reference, its limitation is: The index is not a stable semantic key if list ordering changes.

Question 244

During an implementation review, a Terraform team encounters "Backend reconfiguration during init". Which purpose is associated with that mechanism?

  1. install externally sourced child modules referenced by the root module
  2. move existing state to a newly selected backend when changing its storage
  3. prepare backend and plugin dependencies before planning
  4. accept an intentional backend configuration change without migrating state

Explanation

Correct Answer

D:

The practical result of Backend reconfiguration during init, used to accept an intentional backend configuration change without migrating state, is: terraform init -reconfigure disregards the existing backend initialization settings and uses new ones. A qualification for this effect is: It does not automatically move the old state into the new backend.

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 Backend reconfiguration during init: terraform init resolves module sources and downloads them to the local module cache. Unlike Module download on init, Backend reconfiguration during init is intended to accept an intentional backend configuration change without migrating state, not to install externally sourced child modules referenced by the root module.

B:

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 Backend reconfiguration during init: terraform init -migrate-state offers state migration when a backend configuration changes. Unlike Backend migration during init, Backend reconfiguration during init is intended to accept an intentional backend configuration change without migrating state, not to move existing state to a newly selected backend when changing its storage.

C:

That outcome applies to Initialize a new working directory, intended to prepare backend and plugin dependencies before planning, rather than the question's feature Backend reconfiguration during init: terraform init configures backend access and fetches required modules and providers. Unlike Initialize a new working directory, Backend reconfiguration during init is intended to accept an intentional backend configuration change without migrating state, not to prepare backend and plugin dependencies before planning.

Question 245

The team is documenting risks of Provider installation during init while planning to download required plugins into the initialized working environment. Which caveat specifically applies to that mechanism?

  1. It is a permitted range, not proof of the installed provider's actual version.
  2. It cannot override a required_providers constraint that excludes a release.
  3. It is not the command that downloads and configures all root-module infrastructure.
  4. It does not apply infrastructure changes during initialization.

Explanation

Correct Answer

D:

For Provider installation during init in the task to download required plugins into the initialized working environment, the important caution is: It does not apply infrastructure changes during initialization. The reason this matters is its actual behavior: terraform init resolves provider dependencies and installs or reuses selected plugin packages.

Incorrect Answers

A:

The proposed warning belongs to Provider version compatibility operator, which serves the different goal to allow only nonbreaking versions in a specified range, rather than to Provider installation during init: A constraint like ~> 5.2 permits compatible versions within that bound while excluding the next incompatible major range. The question concerns Provider installation during init acting to download required plugins into the initialized working environment, not a limit of Provider version compatibility operator.

B:

The proposed warning belongs to terraform init -upgrade, which serves the different goal to ask initialization to reconsider allowed provider selections, rather than to Provider installation during init: Using -upgrade during init allows newer versions satisfying the configured provider constraints to be selected. The question concerns Provider installation during init acting to download required plugins into the initialized working environment, not a limit of terraform init -upgrade.

C:

The proposed warning belongs to terraform providers lock, which serves the different goal to populate or update provider checksum selections in the lock file, rather than to Provider installation during init: The providers lock command can record provider package checksums for selected target platforms. The question concerns Provider installation during init acting to download required plugins into the initialized working environment, not a limit of terraform providers lock.

Question 246

A colleague recommends the Terraform concept "Lock acquisition before writes". Which use case best matches it?

  1. protect shared state rather than using -lock=false as a routine workaround
  2. avoid racing state mutations when several operators run Terraform
  3. identify the precise stale lock before taking exceptional recovery action
  4. select shared state storage with appropriate concurrency semantics

Explanation

Correct Answer

B:

The practical result of Lock acquisition before writes, used to avoid racing state mutations when several operators run Terraform, is: Terraform tries to obtain a state lock when the chosen backend supports it. A qualification for this effect is: A configuration-only validation step typically does not need to change state.

Incorrect Answers

A:

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 acquisition before writes: Using a lock-capable backend with normal locking reduces state races. Unlike Avoid disabling state locks, Lock acquisition before writes is intended to avoid racing state mutations when several operators run Terraform, not to protect shared state rather than using -lock=false as a routine workaround.

C:

That outcome applies to Lock identifier verification, intended to identify the precise stale lock before taking exceptional recovery action, rather than the question's feature Lock acquisition before writes: A lock ID should be matched to the blocked state operation before unlocking. Unlike Lock identifier verification, Lock acquisition before writes is intended to avoid racing state mutations when several operators run Terraform, not to identify the precise stale lock before taking exceptional recovery action.

D:

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 acquisition before writes: Supported remote backends can coordinate locking around updates to common state. Unlike Remote backend locking capabilities, Lock acquisition before writes is intended to avoid racing state mutations when several operators run Terraform, not to select shared state storage with appropriate concurrency semantics.

Question 247

A team reviews the use of Child module output scope in Terraform 1.12. Which purpose matches its actual behavior?

  1. keep provider instances configured in the root and pass them to child modules
  2. expose specific child values to its parent with an output block
  3. read values from every instance created by a counted or keyed module call
  4. make some child module arguments optional for callers

Explanation

Correct Answer

B:

The practical result of Child module output scope, used to expose specific child values to its parent with an output block, is: The parent can use module.child.output_name only when the child explicitly declares that output. A qualification for this effect is: Internal child locals and resource attributes remain encapsulated by default.

Incorrect Answers

A:

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 Child module output scope: A root module can explicitly map provider configurations into child module calls. Unlike Provider configuration scope, Child module output scope is intended to expose specific child values to its parent with an output block, not to keep provider instances configured in the root and pass them to child modules.

C:

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 Child module output scope: Counted module outputs use numeric indices; for_each module outputs use instance keys. Unlike Module outputs with repeated instances, Child module output scope is intended to expose specific child values to its parent with an output block, not to read values from every instance created by a counted or keyed module call.

D:

That outcome applies to Module input defaults, intended to make some child module arguments optional for callers, rather than the question's feature Child module output scope: A child variable with a default can be omitted by the caller, allowing the child to use its fallback. Unlike Module input defaults, Child module output scope is intended to expose specific child values to its parent with an output block, not to make some child module arguments optional for callers.

Question 248

An operator chooses the mechanism "HCP Terraform policy sets" for a Terraform project. Which outcome should this choice support?

  1. grant workspace access based on collaboration responsibilities
  2. enforce organizational rules during infrastructure runs
  3. share approved reusable modules within an organization
  4. share reusable variables across selected workspaces

Explanation

Correct Answer

B:

The practical result of HCP Terraform policy sets, used to enforce organizational rules during infrastructure runs, is: HCP Terraform can evaluate governance policies such as Sentinel or OPA as part of run controls. A qualification for this effect is: Policies assess plans or configuration; they are not Terraform resource providers.

Incorrect Answers

A:

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 policy sets: Teams can be assigned appropriate workspace permissions for viewing, planning, and applying. Unlike HCP Terraform teams and permissions, HCP Terraform policy sets is intended to enforce organizational rules during infrastructure runs, not to grant workspace access based on collaboration responsibilities.

C:

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 policy sets: A private registry distributes versioned modules to organization workspaces and teams. Unlike HCP Terraform private module registry, HCP Terraform policy sets is intended to enforce organizational rules during infrastructure runs, not to share approved reusable modules within an organization.

D:

That outcome applies to HCP Terraform variable sets, intended to share reusable variables across selected workspaces, rather than the question's feature HCP Terraform policy sets: Variable sets can provide common Terraform or environment variables to applicable workspaces. Unlike HCP Terraform variable sets, HCP Terraform policy sets is intended to enforce organizational rules during infrastructure runs, not to share reusable variables across selected workspaces.

Question 249

A configuration walkthrough identifies "Module output reference". Which task is it principally intended to support?

  1. refer to an instance selected by its map or set key
  2. use a value explicitly exported by a child module
  3. pass the generated ID of one resource into a dependent resource
  4. ensure a dependent resource waits for a referenced upstream attribute
  5. select the exact indexed instance from count-created resources

Explanation

Correct Answer

B:

The practical result of Module output reference, used to use a value explicitly exported by a child module, is: The parent reads a child output through module.name.output_name rather than reaching into child internals. A qualification for this effect is: Unexported child resource attributes are not directly available to the caller.

Incorrect Answers

A:

That outcome applies to Resource address for for_each instance, intended to refer to an instance selected by its map or set key, rather than the question's feature Module output reference: A for_each resource uses keyed addressing such as example["prod"] and exposes a key-specific object. Unlike Resource address for for_each instance, Module output reference is intended to use a value explicitly exported by a child module, not to refer to an instance selected by its map or set key.

C:

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 Module output reference: An expression such as aws_vpc.main.id links a consuming argument to an upstream resource attribute. Unlike Direct attribute reference, Module output reference is intended to use a value explicitly exported by a child module, not to pass the generated ID of one resource into a dependent resource.

D:

That outcome applies to Implicit resource dependency, intended to ensure a dependent resource waits for a referenced upstream attribute, rather than the question's feature Module output reference: Terraform infers dependencies when expressions reference other resources. Unlike Implicit resource dependency, Module output reference is intended to use a value explicitly exported by a child module, not to ensure a dependent resource waits for a referenced upstream attribute.

E:

That outcome applies to Resource address for count instance, intended to select the exact indexed instance from count-created resources, rather than the question's feature Module output reference: Count-created instances use numeric indices in expressions and state addresses, such as example[1]. Unlike Resource address for count instance, Module output reference is intended to use a value explicitly exported by a child module, not to select the exact indexed instance from count-created resources.

Question 250

A change proposal relies on Infrastructure execution plan for the task to preview the proposed actions before changing real resources. Which limitation specifically applies to it?

  1. The configuration still needs a tool and credentials to change actual systems.
  2. Reviewing a plan is different from committing its effects to the remote system.
  3. It does not mean Terraform can automatically infer missing provider configuration.
  4. A resource declaration is not the same as a read-only data lookup.

Explanation

Correct Answer

B:

For Infrastructure execution plan in the task to preview the proposed actions before changing real resources, the important caution is: Reviewing a plan is different from committing its effects to the remote system. The reason this matters is its actual behavior: A Terraform plan calculates proposed actions from configuration, state, providers, and current observations.

Incorrect Answers

A:

The proposed warning belongs to Infrastructure as code definition, which serves the different goal to represent desired infrastructure in reviewable configuration files, rather than to Infrastructure execution plan: Infrastructure as code describes infrastructure through machine-readable files instead of relying only on manual console operations. The question concerns Infrastructure execution plan acting to preview the proposed actions before changing real resources, not a limit of Infrastructure as code definition.

C:

The proposed warning belongs to Declarative infrastructure model, which serves the different goal to specify an end state rather than every API request, rather than to Infrastructure execution plan: A declarative model states the desired objects and lets Terraform determine an execution path from configuration and state. The question concerns Infrastructure execution plan acting to preview the proposed actions before changing real resources, not a limit of Declarative infrastructure model.

D:

The proposed warning belongs to Terraform resource declaration, which serves the different goal to describe one managed infrastructure object in a configuration, rather than to Infrastructure execution plan: A resource block represents an object that Terraform will create, update, or destroy through a provider. The question concerns Infrastructure execution plan acting to preview the proposed actions before changing real resources, not a limit of Terraform resource declaration.

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