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

Question 380

A Terraform rollout has two separate requirements: first, avoid long-lived static cloud credentials in workspace variables; second, share approved reusable modules within an organization. Which assignment of mechanisms correctly handles both responsibilities?

  1. First use HCP Terraform dynamic provider credentials; then use HCP Terraform policy sets.
  2. First use HCP Terraform private module registry; then use HCP Terraform dynamic provider credentials.
  3. First use HCP Terraform teams and permissions; then use HCP Terraform private module registry.
  4. First use HCP Terraform policy sets; then use HCP Terraform teams and permissions.
  5. First use HCP Terraform dynamic provider credentials; then use HCP Terraform private module registry.

Explanation

Correct Answer

E:

The first requirement, to avoid long-lived static cloud credentials in workspace variables, is handled by HCP Terraform dynamic provider credentials: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. The second requirement, to share approved reusable modules within an organization, is handled by HCP Terraform private module registry: A private registry distributes versioned modules to organization workspaces and teams. Each of these mechanisms has a distinct responsibility.

Incorrect Answers

A:

For the requested tasks to avoid long-lived static cloud credentials in workspace variables and share approved reusable modules within an organization, the first candidate HCP Terraform dynamic provider credentials addresses avoid long-lived static cloud credentials in workspace variables; the second candidate HCP Terraform policy sets addresses enforce organizational rules during infrastructure runs. This mapping fails because the second mechanism primarily supports the task to enforce organizational rules during infrastructure runs; the actual requirements are avoid long-lived static cloud credentials in workspace variables first and share approved reusable modules within an organization second.

B:

For the requested tasks to avoid long-lived static cloud credentials in workspace variables and share approved reusable modules within an organization, the first candidate HCP Terraform private module registry addresses share approved reusable modules within an organization; the second candidate HCP Terraform dynamic provider credentials addresses avoid long-lived static cloud credentials in workspace variables. This mapping fails because the first mechanism primarily supports the task to share approved reusable modules within an organization and the second mechanism primarily supports the task to avoid long-lived static cloud credentials in workspace variables; the actual requirements are avoid long-lived static cloud credentials in workspace variables first and share approved reusable modules within an organization second.

C:

For the requested tasks to avoid long-lived static cloud credentials in workspace variables and share approved reusable modules within an organization, the first candidate HCP Terraform teams and permissions addresses grant workspace access based on collaboration responsibilities; the second candidate HCP Terraform private module registry addresses share approved reusable modules within an organization. This mapping fails because the first mechanism primarily supports the task to grant workspace access based on collaboration responsibilities; the actual requirements are avoid long-lived static cloud credentials in workspace variables first and share approved reusable modules within an organization second.

D:

For the requested tasks to avoid long-lived static cloud credentials in workspace variables and share approved reusable modules within an organization, the first candidate HCP Terraform policy sets addresses enforce organizational rules during infrastructure runs; the second candidate HCP Terraform teams and permissions addresses grant workspace access based on collaboration responsibilities. This mapping fails because the first mechanism primarily supports the task to enforce organizational rules during infrastructure runs and the second mechanism primarily supports the task to grant workspace access based on collaboration responsibilities; the actual requirements are avoid long-lived static cloud credentials in workspace variables first and share approved reusable modules within an organization second.

Question 381

A configuration walkthrough identifies "Local value expression". Which task is it principally intended to support?

  1. expose a selected Terraform expression to the caller or CLI
  2. name a computed expression used repeatedly inside one module
  3. restrict an input to an expected Terraform type
  4. prompt for or provide a root-module value when no default exists
  5. give a module input a fallback when callers omit it

Explanation

Correct Answer

B:

The practical result of Local value expression, used to name a computed expression used repeatedly inside one module, is: locals blocks evaluate named expressions available as local.name within that module. A qualification for this effect is: They are not root-module input variables and cannot be set with -var.

Incorrect Answers

A:

That outcome applies to Output block, intended to expose a selected Terraform expression to the caller or CLI, rather than the question's feature Local value expression: An output block publishes a value from its module, such as an endpoint or resource identifier. Unlike Output block, Local value expression is intended to name a computed expression used repeatedly inside one module, not to expose a selected Terraform expression to the caller or CLI.

C:

That outcome applies to Variable type constraint, intended to restrict an input to an expected Terraform type, rather than the question's feature Local value expression: A type declaration such as number or object(...) lets Terraform validate and convert compatible inputs. Unlike Variable type constraint, Local value expression is intended to name a computed expression used repeatedly inside one module, not to restrict an input to an expected Terraform type.

D:

That outcome applies to Required input variable, intended to prompt for or provide a root-module value when no default exists, rather than the question's feature Local value expression: A variable block without a default requires a value supplied through a supported input channel. Unlike Required input variable, Local value expression is intended to name a computed expression used repeatedly inside one module, not to prompt for or provide a root-module value when no default exists.

E:

That outcome applies to Variable default value, intended to give a module input a fallback when callers omit it, rather than the question's feature Local value expression: A variable default supplies a value without requiring each caller to pass that argument. Unlike Variable default value, Local value expression is intended to name a computed expression used repeatedly inside one module, not to give a module input a fallback when callers omit it.

Question 382

The rollout owner asks whether Repeatable environment provisioning is sufficient to recreate equivalent infrastructure patterns from one codebase. Which limitation specifically concerns that mechanism?

  1. Differences in inputs and provider versions can still alter actual results.
  2. A plan may include unknown attributes that are resolved only during apply.
  3. Sharing a module does not force all environments to use identical values.
  4. Provider behavior and implicit side effects still need relevant documentation.

Explanation

Correct Answer

A:

For Repeatable environment provisioning in the task to recreate equivalent infrastructure patterns from one codebase, the important caution is: Differences in inputs and provider versions can still alter actual results. The reason this matters is its actual behavior: Parameterizing reusable Terraform modules can provision consistent environment patterns repeatedly.

Incorrect Answers

B:

The proposed warning belongs to Change impact preview, which serves the different goal to identify likely creations, updates, and deletions before execution, rather than to Repeatable environment provisioning: Terraform planning exposes proposed operations for examination before they take effect. The question concerns Repeatable environment provisioning acting to recreate equivalent infrastructure patterns from one codebase, not a limit of Change impact preview.

C:

The proposed warning belongs to Consistent development and production patterns, which serves the different goal to reduce configuration drift across environments using shared modules, rather than to Repeatable environment provisioning: Reusing modules with explicit inputs aligns infrastructure design while allowing intentional environment differences. The question concerns Repeatable environment provisioning acting to recreate equivalent infrastructure patterns from one codebase, not a limit of Consistent development and production patterns.

D:

The proposed warning belongs to Self-documenting resource relationships, which serves the different goal to make infrastructure dependencies understandable from code, rather than to Repeatable environment provisioning: Resource references and explicit dependencies can express how objects relate without relying on tribal knowledge. The question concerns Repeatable environment provisioning acting to recreate equivalent infrastructure patterns from one codebase, not a limit of Self-documenting resource relationships.

Question 383

The rollout owner asks whether terraform state show ADDRESS is sufficient to inspect stored attributes for one tracked resource instance. Which limitation specifically concerns that mechanism?

  1. It does not enumerate every object in the cloud account.
  2. An address filter does not delete unwanted resource records.
  3. It does not display arbitrary resource attributes unless exported via outputs.
  4. Editing and pushing the JSON should not be treated as a routine management workflow.
  5. It does not perform an infrastructure change or show another resource automatically.

Explanation

Correct Answer

E:

For terraform state show ADDRESS in the task to inspect stored attributes for one tracked resource instance, the important caution is: It does not perform an infrastructure change or show another resource automatically. The reason this matters is its actual behavior: state show presents the state representation of an addressed resource.

Incorrect Answers

A:

The proposed warning belongs to terraform state list, which serves the different goal to enumerate Terraform resource addresses currently tracked in a state snapshot, rather than to terraform state show ADDRESS: state list displays managed addresses and can be narrowed with address filters. The question concerns terraform state show ADDRESS acting to inspect stored attributes for one tracked resource instance, not a limit of terraform state list.

B:

The proposed warning belongs to Address filter for state list, which serves the different goal to locate a relevant module or resource without reading every tracked address, rather than to terraform state show ADDRESS: state list accepts optional address patterns to narrow visible resources. The question concerns terraform state show ADDRESS acting to inspect stored attributes for one tracked resource instance, not a limit of Address filter for state list.

C:

The proposed warning belongs to terraform output, which serves the different goal to display declared root output values from the current state, rather than to terraform state show ADDRESS: output reads named output values and can provide -json for structured automation. The question concerns terraform state show ADDRESS acting to inspect stored attributes for one tracked resource instance, not a limit of terraform output.

D:

The proposed warning belongs to terraform state pull, which serves the different goal to retrieve the current backend state snapshot as serialized JSON, rather than to terraform state show ADDRESS: state pull reads state from the configured backend for inspection or backup handling. The question concerns terraform state show ADDRESS acting to inspect stored attributes for one tracked resource instance, not a limit of terraform state pull.

Question 384

A team is adjusting its declarative infrastructure process to preserve locked provider selections in routine CI initialization. Which mechanism most directly meets this particular need?

  1. Initialization as safe repeated step
  2. Module download on init
  3. Init provider plugin upgrade control
  4. Init without backend setup
  5. Initialize a new working directory

Explanation

Correct Answer

C:

The task is to preserve locked provider selections in routine CI initialization; Init provider plugin upgrade control directly supports that requirement: A normal terraform init honors the existing dependency lock selections unless update is requested. Its relevant boundary is: A changed constraint can require an explicit upgrade or other resolution.

Incorrect Answers

A:

Initialization as safe repeated step is designed to rerun initialization after adding a provider or changing module sources, whereas this task is to preserve locked provider selections in routine CI initialization: It is normally safe to run terraform init repeatedly to satisfy updated dependencies. Against Init provider plugin upgrade control, its limitation is: Reinitialization is not a substitute for planning after configuration changes.

B:

Module download on init is designed to install externally sourced child modules referenced by the root module, whereas this task is to preserve locked provider selections in routine CI initialization: terraform init resolves module sources and downloads them to the local module cache. Against Init provider plugin upgrade control, its limitation is: Downloading a module does not create its infrastructure.

D:

Init without backend setup is designed to work on configuration validation while deliberately skipping backend initialization, whereas this task is to preserve locked provider selections in routine CI initialization: terraform init -backend=false skips the backend initialization step where appropriate. Against Init provider plugin upgrade control, its limitation is: Commands needing live state might not work without a configured backend.

E:

Initialize a new working directory is designed to prepare backend and plugin dependencies before planning, whereas this task is to preserve locked provider selections in routine CI initialization: terraform init configures backend access and fetches required modules and providers. Against Init provider plugin upgrade control, its limitation is: Initialization is not the command for creating managed resources.

Question 385

A deployment design calls for a supported way to select shared state storage with appropriate concurrency semantics. Which mechanism most directly meets this particular need?

  1. terraform force-unlock
  2. terraform -lock-timeout behavior
  3. Remote backend locking capabilities
  4. Terraform state locking
  5. Lock acquisition before writes

Explanation

Correct Answer

C:

The task is to select shared state storage with appropriate concurrency semantics; Remote backend locking capabilities directly supports that requirement: Supported remote backends can coordinate locking around updates to common state. Its relevant boundary is: Remote storage and locking are related but distinct capabilities.

Incorrect Answers

A:

terraform force-unlock is designed to remove a stale lock only after confirming that no valid run owns it, whereas this task is to select shared state storage with appropriate concurrency semantics: force-unlock accepts a lock ID and bypasses normal waiting for an abandoned lock. Against Remote backend locking capabilities, its limitation is: Incorrectly breaking an active lock risks competing state modifications.

B:

terraform -lock-timeout behavior is designed to let a run wait briefly rather than fail immediately when state is busy, whereas this task is to select shared state storage with appropriate concurrency semantics: The lock-timeout flag controls how long supported operations retry obtaining a lock. Against Remote backend locking capabilities, its limitation is: It does not itself activate locking on a backend that lacks that feature.

D:

Terraform state locking is designed to prevent two concurrent runs from writing the same state snapshot, whereas this task is to select shared state storage with appropriate concurrency semantics: A backend with locking support serializes operations that could corrupt shared state. Against Remote backend locking capabilities, its limitation is: Not every backend supports locking in the same way.

E:

Lock acquisition before writes is designed to avoid racing state mutations when several operators run Terraform, whereas this task is to select shared state storage with appropriate concurrency semantics: Terraform tries to obtain a state lock when the chosen backend supports it. Against Remote backend locking capabilities, its limitation is: A configuration-only validation step typically does not need to change state.

Question 386

A change proposal relies on Local value expression for the task to name a computed expression used repeatedly inside one module. Which limitation specifically applies to it?

  1. Declaring a variable does not itself fetch a remote API value.
  2. Type declarations are different from custom semantic validation rules.
  3. Outputs do not automatically create an infrastructure object.
  4. They are not root-module input variables and cannot be set with -var.
  5. The file supplies values but does not declare variable types.

Explanation

Correct Answer

D:

For Local value expression in the task to name a computed expression used repeatedly inside one module, the important caution is: They are not root-module input variables and cannot be set with -var. The reason this matters is its actual behavior: locals blocks evaluate named expressions available as local.name within that module.

Incorrect Answers

A:

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 Local value expression: A variable block without a default requires a value supplied through a supported input channel. The question concerns Local value expression acting to name a computed expression used repeatedly inside one module, not a limit of Required input variable.

B:

The proposed warning belongs to Variable type constraint, which serves the different goal to restrict an input to an expected Terraform type, rather than to Local value expression: A type declaration such as number or object(...) lets Terraform validate and convert compatible inputs. The question concerns Local value expression acting to name a computed expression used repeatedly inside one module, not a limit of Variable type constraint.

C:

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 Local value expression: An output block publishes a value from its module, such as an endpoint or resource identifier. The question concerns Local value expression acting to name a computed expression used repeatedly inside one module, not a limit of Output block.

E:

The listed caution belongs specifically to Variable file input, used to load multiple variable assignments from a chosen tfvars file: The -var-file flag passes root-module input values from a named variable definitions file; the feature under review is instead Local value expression, so this answer attaches another feature's qualification to the wrong mechanism.

Question 387

A platform engineering group needs to read values from every instance created by a counted or keyed module call. Which mechanism most directly meets this particular need?

  1. Child module output scope
  2. Module outputs with repeated instances
  3. Child module input variable
  4. Root variable namespace

Explanation

Correct Answer

B:

The task is to read values from every instance created by a counted or keyed module call; Module outputs with repeated instances directly supports that requirement: Counted module outputs use numeric indices; for_each module outputs use instance keys. Its relevant boundary is: A repeated module call is not the same value shape as a single module output object.

Incorrect Answers

A:

Child module output scope is designed to expose specific child values to its parent with an output block, whereas this task is to read values from every instance created by a counted or keyed module call: The parent can use module.child.output_name only when the child explicitly declares that output. Against Module outputs with repeated instances, its limitation is: Internal child locals and resource attributes remain encapsulated by default.

C:

Child module input variable is designed to pass a caller-defined value into a reusable child module, whereas this task is to read values from every instance created by a counted or keyed module call: The child declares a variable and the parent's module block assigns a value to that argument. Against Module outputs with repeated instances, its limitation is: An input declared in the child is not implicitly available as var.name in the parent.

D:

Root variable namespace is designed to distinguish CLI-supplied root inputs from child inputs, whereas this task is to read values from every instance created by a counted or keyed module call: CLI -var arguments set variables declared in the root module; child values pass through module call arguments. Against Module outputs with repeated instances, its limitation is: A variable with the same name in two modules is a separate declaration.

Question 388

An engineer must update an existing Terraform workflow to retain run and change history for collaboration and review. Which mechanism most directly meets this particular need?

  1. HCP Terraform auditability
  2. HCP Terraform variable sets
  3. HCP Terraform dynamic provider credentials
  4. HCP Terraform private module registry

Explanation

Correct Answer

A:

The task is to retain run and change history for collaboration and review; HCP Terraform auditability directly supports that requirement: Workspace run histories help teams trace proposed and executed infrastructure operations. Its relevant boundary is: A recorded run history is not the same as versioned source code approval.

Incorrect Answers

B:

HCP Terraform variable sets is designed to share reusable variables across selected workspaces, whereas this task is to retain run and change history for collaboration and review: Variable sets can provide common Terraform or environment variables to applicable workspaces. Against HCP Terraform auditability, its limitation is: Per-workspace values and precedence must be reviewed when there are overlaps.

C:

HCP Terraform dynamic provider credentials is designed to avoid long-lived static cloud credentials in workspace variables, whereas this task is to retain run and change history for collaboration and review: Supported dynamic credentials issue time-limited tokens to runs based on trust configuration. Against HCP Terraform auditability, its limitation is: The target provider and cloud identity federation must be configured correctly.

D:

HCP Terraform private module registry addresses the different requirement to share approved reusable modules within an organization: A private registry distributes versioned modules to organization workspaces and teams; this does not by itself satisfy the requested task to retain run and change history for collaboration and review. For the stated need, HCP Terraform auditability is the more direct mechanism.

Question 389

The implementation must both supply settings such as region or endpoint for a provider instance and read remote information without declaring ownership of its lifecycle. Which TWO mechanisms directly address these two separate requirements? Choose TWO.

  1. Provider block configuration
  2. Provider authentication
  3. Provider plugin responsibility
  4. Provider selection for resource prefix
  5. Provider data sources

Explanation

Correct Answers

A:

Among the paired tasks to supply settings such as region or endpoint for a provider instance and read remote information without declaring ownership of its lifecycle, Provider block configuration serves the requirement to supply settings such as region or endpoint for a provider instance: A provider block creates a configured provider instance that resources can use. The other task must be covered by a separate mechanism.

E:

Among the paired tasks to supply settings such as region or endpoint for a provider instance and read remote information without declaring ownership of its lifecycle, Provider data sources serves the requirement to read remote information without declaring ownership of its lifecycle: A provider data source queries external information that configuration can reference. The other task must be covered by a separate mechanism.

Incorrect Answers

B:

The requirements are supply settings such as region or endpoint for a provider instance and read remote information without declaring ownership of its lifecycle, while Provider authentication supports the different task to authorize API operations requested by a Terraform provider: Providers use supported credentials and authentication mechanisms to talk to their services. That capability is outside the two selected responsibilities.

C:

The requirements are supply settings such as region or endpoint for a provider instance and read remote information without declaring ownership of its lifecycle, while Provider plugin responsibility supports the different task to translate a Terraform resource operation into remote service API calls: The provider implements resource types and performs create, read, update, and delete operations when supported. That capability is outside the two selected responsibilities.

D:

The requested tasks are to supply settings such as region or endpoint for a provider instance; read remote information without declaring ownership of its lifecycle, but Provider selection for resource prefix primarily addresses the different goal to associate a resource with the default provider for its type prefix: Without a provider meta-argument Terraform normally selects the matching local provider configuration; therefore it is not one of the mechanisms selected for the stated requirements.

Question 390

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

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

Explanation

Correct Answer

E:

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

Incorrect Answers

A:

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

B:

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

C:

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

D:

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

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