HashiCorp Terraform Associate (HashiCorp Certified: Terraform Associate) Practice Test 53

Question 520

The immediate Terraform task is to allow a caller to reference child results. Which method handles that task most directly?

  1. Avoid referencing child local values from the parent
  2. Use nullable = false for a non-null module input
  3. Expose selected values via output blocks
  4. Pass a root output through a child input explicitly

Explanation

Correct Answer

C:

A child output becomes accessible as module.instance.output_name; callers cannot directly reach arbitrary unexported resources inside the child module; this behavior should be assessed against the concrete need to allow a caller to reference child results. This directly supports the task to allow a caller to reference child results during a configuration change.

Incorrect Answers

A:

Only outputs are exposed for general child-module consumption; callers should not depend on private local names that may change during refactoring; this behavior should be assessed against the concrete need to allow a caller to reference child results. The distinction matters here: using that mechanism to preserve encapsulation of implementation-only calculations would still leave the objective to allow a caller to reference child results unmet.

B:

The variable setting controls whether null is permitted; it does not imply that the child can choose a cloud credential automatically; this behavior should be assessed against the concrete need to allow a caller to reference child results. It may support a related workflow, but the question specifically requires the mechanism for allow a caller to reference child results rather than reject a caller's explicit null rather than accidentally passing it onward.

D:

A caller can use module.upstream.value as an argument to module.downstream; this also creates a dependency through the reference; this behavior should be assessed against the concrete need to allow a caller to reference child results. That can be useful when the aim is to connect two modules while preserving their separate scopes, but it does not directly deliver the requested ability to allow a caller to reference child results.

Question 521

A Terraform rollout has separate acceptance criteria: consume a child module result in the caller and instantiate a module per stable map or set key. Which combined approach directly satisfies the two criteria?

  1. Share provider configurations from the root + Use for_each on a compatible module call
  2. Pass the providers mapping to a child + Define a module block with source
  3. Read module.web.endpoint after declaring an output + Use for_each on a compatible module call
  4. Read module.web.endpoint after declaring an output + Use a local module while iterating on a design

Explanation

Correct Answer

C:

For the first criterion, only named output values are exposed by the module reference; the caller cannot assume internal resource addresses are directly visible; this behavior should be assessed against the concrete need to consume a child module result in the caller and instantiate a module per stable map or set key; this directly addresses the need to consume a child module result in the caller. For the separate second criterion, for-each instance addresses include keys and are often easier to maintain through membership changes than positional count indices; this behavior should be assessed against the concrete need to consume a child module result in the caller and instantiate a module per stable map or set key; this fulfills the need to instantiate a module per stable map or set key. Together they cover the independent tasks of consume a child module result in the caller and instantiate a module per stable map or set key without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the instantiate a module per stable map or set key requirement, but the first is designed for another concern: A child module should declare provider requirements while receiving provider configurations through inheritance or explicit mapping; this supports flexible reuse; this behavior should be assessed against the concrete need to consume a child module result in the caller and instantiate a module per stable map or set key. That first component is designed to avoid configuring cloud credentials separately in every reusable child, which does not accomplish the requested task to consume a child module result in the caller, even though the other measure satisfies instantiate a module per stable map or set key.

B:

The first measure is intended to select which root provider configurations the module uses: A module provider map binds the child's expected names to configured parent provider instances; it does not install providers independently; this behavior should be assessed against the concrete need to consume a child module result in the caller and instantiate a module per stable map or set key. The second measure is intended to instantiate a reusable child configuration from a known location: A module call loads the child configuration and supplies its arguments; the caller's root remains responsible for backend setup; this behavior should be assessed against the concrete need to consume a child module result in the caller and instantiate a module per stable map or set key. Neither is the directly designated method for the separate goals of consume a child module result in the caller and instantiate a module per stable map or set key in this review.

D:

The first measure meets the requirement to consume a child module result in the caller, but its partner serves a different role: A local path loads code directly from the checkout; this differs from upgrading an immutable release in an external module registry; this behavior should be assessed against the concrete need to consume a child module result in the caller and instantiate a module per stable map or set key. That second component is designed to test in-repository child changes before publishing a version, so the still-missing criterion is to instantiate a module per stable map or set key, while the first criterion remains consume a child module result in the caller.

Question 522

A Terraform configuration must avoid a surprise module upgrade. The team must both avoid assuming the provider lock file pins downloaded module packages and distinguish registry version selection from source identification. Which paired choice implements those distinct goals?

  1. Recognize module versions are not locked by .terraform.lock.hcl + Specify a registry module version in the call
  2. Document compatibility requirements for module consumers + Treat major version changes as interface changes
  3. Use a release tag as a Git source ref + Specify a registry module version in the call
  4. Recognize module versions are not locked by .terraform.lock.hcl + Review the plan after a module upgrade

Explanation

Correct Answer

A:

For the first criterion, the dependency lock file records provider versions and checksums; module selection is governed by source references and registry module constraints; this behavior should be assessed against the concrete need to avoid assuming the provider lock file pins downloaded module packages and distinguish registry version selection from source identification; this directly addresses the need to avoid assuming the provider lock file pins downloaded module packages. For the separate second criterion, the source says which module to fetch, while version constrains published versions; both are important for predictable registry consumption; this behavior should be assessed against the concrete need to avoid assuming the provider lock file pins downloaded module packages and distinguish registry version selection from source identification; this fulfills the need to distinguish registry version selection from source identification. Together they cover the independent tasks of avoid assuming the provider lock file pins downloaded module packages and distinguish registry version selection from source identification without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to make dependency expectations explicit before broad reuse: A reusable module can state minimum provider versions and tested Terraform versions; this keeps consumers from resolving unsupported combinations; this behavior should be assessed against the concrete need to avoid assuming the provider lock file pins downloaded module packages and distinguish registry version selection from source identification. The second measure is intended to review module inputs, outputs, and resource movements before upgrading: A new release can change the child module's contract or resource addresses; a valid installation does not guarantee a safe infrastructure plan; this behavior should be assessed against the concrete need to avoid assuming the provider lock file pins downloaded module packages and distinguish registry version selection from source identification. Neither is the directly designated method for the separate goals of avoid assuming the provider lock file pins downloaded module packages and distinguish registry version selection from source identification in this review.

C:

The second measure does meet the distinguish registry version selection from source identification requirement, but the first is designed for another concern: A Git tag can name a release, but mutable tags remain a repository-governance risk; this version control is separate from registry module version constraints; this behavior should be assessed against the concrete need to avoid assuming the provider lock file pins downloaded module packages and distinguish registry version selection from source identification. That first component is designed to refer to a known Git module milestone, which does not accomplish the requested task to avoid assuming the provider lock file pins downloaded module packages, even though the other measure satisfies distinguish registry version selection from source identification.

D:

The first measure meets the requirement to avoid assuming the provider lock file pins downloaded module packages, but its partner serves a different role: A new module may replace resources or alter defaults; initialization only fetches code; the plan reveals its likely infrastructure impact; this behavior should be assessed against the concrete need to avoid assuming the provider lock file pins downloaded module packages and distinguish registry version selection from source identification. That second component is designed to spot effects caused by changed child resource definitions, so the still-missing criterion is to distinguish registry version selection from source identification, while the first criterion remains avoid assuming the provider lock file pins downloaded module packages.

Question 523

A reviewer has to approve a two-part design: load a child module from a path relative to the calling configuration; additionally, retrieve a published module from its registry address. Which option pairs the correct mechanisms?

  1. Use the module registry's documented inputs and outputs + Use a public registry source namespace/name/provider
  2. Use source = "./modules/network" + Use git::https://... as the source
  3. Use source = "./modules/network" + Use a public registry source namespace/name/provider
  4. Use a local module source for rapid in-repository changes + Use //subdirectory in an external module source

Explanation

Correct Answer

C:

For the first criterion, local sources refer to code on disk, and ./ makes the relative location explicit; they do not select a published registry version; this behavior should be assessed against the concrete need to load a child module from a path relative to the calling configuration and retrieve a published module from its registry address; this directly addresses the need to load a child module from a path relative to the calling configuration. For the separate second criterion, the shorthand identifies a Terraform Registry module and its provider category; version constraints can apply to registry-sourced modules; this behavior should be assessed against the concrete need to load a child module from a path relative to the calling configuration and retrieve a published module from its registry address; this fulfills the need to retrieve a published module from its registry address. Together they cover the independent tasks of load a child module from a path relative to the calling configuration and retrieve a published module from its registry address without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the retrieve a published module from its registry address requirement, but the first is designed for another concern: Published modules define an intended interface; callers supply declared variables and consume declared outputs; internal resources are implementation details; this behavior should be assessed against the concrete need to load a child module from a path relative to the calling configuration and retrieve a published module from its registry address. That first component is designed to integrate the module without assuming internal resource names are its API, which does not accomplish the requested task to load a child module from a path relative to the calling configuration, even though the other measure satisfies retrieve a published module from its registry address.

B:

The first measure meets the requirement to load a child module from a path relative to the calling configuration, but its partner serves a different role: Terraform supports a Git URL source and can use a reference query parameter; the registry version argument is not used to version raw Git sources; this behavior should be assessed against the concrete need to load a child module from a path relative to the calling configuration and retrieve a published module from its registry address. That second component is designed to fetch module code directly from a Git repository, so the still-missing criterion is to retrieve a published module from its registry address, while the first criterion remains load a child module from a path relative to the calling configuration.

D:

The first measure is intended to develop a shared component without publishing a remote module release: A local module is loaded from the current filesystem tree; changes are visible with the current checkout instead of awaiting a registry release; this behavior should be assessed against the concrete need to load a child module from a path relative to the calling configuration and retrieve a published module from its registry address. The second measure is intended to select a nested module directory inside a downloaded repository: The double-slash delimiter distinguishes the subdirectory from the package URL; terraform retrieves the containing package before entering the path; this behavior should be assessed against the concrete need to load a child module from a path relative to the calling configuration and retrieve a published module from its registry address. Neither is the directly designated method for the separate goals of load a child module from a path relative to the calling configuration and retrieve a published module from its registry address in this review.

Question 524

A Terraform rollout has separate acceptance criteria: accept values from the calling module through a documented interface and reject a caller's explicit null rather than accidentally passing it onward. Which combined approach directly satisfies the two criteria?

  1. Declare inputs in a child variable block + Use typed module inputs
  2. Use a default on a child input for optional behavior + Use nullable = false for a non-null module input
  3. Pass a child input in the module block + Avoid referencing child local values from the parent
  4. Declare inputs in a child variable block + Use nullable = false for a non-null module input

Explanation

Correct Answer

D:

For the first criterion, each module declares its own variable names and constraints; a child does not automatically inherit all root input variables; this behavior should be assessed against the concrete need to accept values from the calling module through a documented interface and reject a caller's explicit null rather than accidentally passing it onward; this directly addresses the need to accept values from the calling module through a documented interface. For the separate second criterion, the variable setting controls whether null is permitted; it does not imply that the child can choose a cloud credential automatically; this behavior should be assessed against the concrete need to accept values from the calling module through a documented interface and reject a caller's explicit null rather than accidentally passing it onward; this fulfills the need to reject a caller's explicit null rather than accidentally passing it onward. Together they cover the independent tasks of accept values from the calling module through a documented interface and reject a caller's explicit null rather than accidentally passing it onward without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to accept values from the calling module through a documented interface, but its partner serves a different role: Type constraints describe accepted strings, collections, or nested objects; they make the child-module contract more predictable than undocumented any values; this behavior should be assessed against the concrete need to accept values from the calling module through a documented interface and reject a caller's explicit null rather than accidentally passing it onward. That second component is designed to catch incompatible caller values before deployment, so the still-missing criterion is to reject a caller's explicit null rather than accidentally passing it onward, while the first criterion remains accept values from the calling module through a documented interface.

B:

The second measure does meet the reject a caller's explicit null rather than accidentally passing it onward requirement, but the first is designed for another concern: A variable default supplies the value within the child when no argument is passed; other child inputs without defaults remain required; this behavior should be assessed against the concrete need to accept values from the calling module through a documented interface and reject a caller's explicit null rather than accidentally passing it onward. That first component is designed to allow callers to omit that specific module argument, which does not accomplish the requested task to accept values from the calling module through a documented interface, even though the other measure satisfies reject a caller's explicit null rather than accidentally passing it onward.

C:

The first measure is intended to assign the caller's value to the child's required variable: Arguments in a module call map into variables declared by that child; an undeclared argument is not a magic global variable; this behavior should be assessed against the concrete need to accept values from the calling module through a documented interface and reject a caller's explicit null rather than accidentally passing it onward. The second measure is intended to preserve encapsulation of implementation-only calculations: Only outputs are exposed for general child-module consumption; callers should not depend on private local names that may change during refactoring; this behavior should be assessed against the concrete need to accept values from the calling module through a documented interface and reject a caller's explicit null rather than accidentally passing it onward. Neither is the directly designated method for the separate goals of accept values from the calling module through a documented interface and reject a caller's explicit null rather than accidentally passing it onward in this review.

Question 525

An engineer needs to avoid assuming a backend in a child controls the caller's state as part of an automated release. Which option is the best fit?

  1. Pass the providers mapping to a child
  2. Read module.web.endpoint after declaring an output
  3. Keep backend configuration in the root module
  4. Use depends_on on a module when necessary

Explanation

Correct Answer

C:

The backend applies to the top-level working configuration; child modules cannot independently select state storage during a normal shared module call; this behavior should be assessed against the concrete need to avoid assuming a backend in a child controls the caller's state. This directly supports the task to avoid assuming a backend in a child controls the caller's state during an infrastructure audit.

Incorrect Answers

A:

A module provider map binds the child's expected names to configured parent provider instances; it does not install providers independently; this behavior should be assessed against the concrete need to avoid assuming a backend in a child controls the caller's state. The distinction matters here: using that mechanism to select which root provider configurations the module uses would still leave the objective to avoid assuming a backend in a child controls the caller's state unmet.

B:

Only named output values are exposed by the module reference; the caller cannot assume internal resource addresses are directly visible; this behavior should be assessed against the concrete need to avoid assuming a backend in a child controls the caller's state. It may support a related workflow, but the question specifically requires the mechanism for avoid assuming a backend in a child controls the caller's state rather than consume a child module result in the caller.

D:

An explicit module dependency orders its operations after the listed object; prefer output references when they can express the dependency more narrowly; this behavior should be assessed against the concrete need to avoid assuming a backend in a child controls the caller's state. That can be useful when the aim is to enforce a hidden prerequisite for an entire child module, but it does not directly deliver the requested ability to avoid assuming a backend in a child controls the caller's state.

Question 526

A build pipeline compares module versioning across source types. The requirement is to refer to a known Git module milestone. Which Terraform mechanism directly meets this requirement?

  1. Document compatibility requirements for module consumers
  2. Review the plan after a module upgrade
  3. Recognize module versions are not locked by .terraform.lock.hcl
  4. Use a release tag as a Git source ref

Explanation

Correct Answer

D:

A Git tag can name a release, but mutable tags remain a repository-governance risk; this version control is separate from registry module version constraints; this behavior should be assessed against the concrete need to refer to a known Git module milestone. This directly supports the task to refer to a known Git module milestone during a planned migration.

Incorrect Answers

A:

A reusable module can state minimum provider versions and tested Terraform versions; this keeps consumers from resolving unsupported combinations; this behavior should be assessed against the concrete need to refer to a known Git module milestone. That can be useful when the aim is to make dependency expectations explicit before broad reuse, but it does not directly deliver the requested ability to refer to a known Git module milestone.

B:

A new module may replace resources or alter defaults; initialization only fetches code; the plan reveals its likely infrastructure impact; this behavior should be assessed against the concrete need to refer to a known Git module milestone. The distinction matters here: using that mechanism to spot effects caused by changed child resource definitions would still leave the objective to refer to a known Git module milestone unmet.

C:

The dependency lock file records provider versions and checksums; module selection is governed by source references and registry module constraints; this behavior should be assessed against the concrete need to refer to a known Git module milestone. It may support a related workflow, but the question specifically requires the mechanism for refer to a known Git module milestone rather than avoid assuming the provider lock file pins downloaded module packages.

Question 527

In an automated release, the requested result is to select a nested module directory inside a downloaded repository. What should the engineer select?

  1. Avoid confusing a module with a provider
  2. Use //subdirectory in an external module source
  3. Use a local module source for rapid in-repository changes
  4. Use the module registry's documented inputs and outputs

Explanation

Correct Answer

B:

The double-slash delimiter distinguishes the subdirectory from the package URL; terraform retrieves the containing package before entering the path; this behavior should be assessed against the concrete need to select a nested module directory inside a downloaded repository. This directly supports the task to select a nested module directory inside a downloaded repository during a module implementation.

Incorrect Answers

A:

A module contains HCL blocks; a provider implements external API operations; an external module may use providers but is not itself a provider binary; this behavior should be assessed against the concrete need to select a nested module directory inside a downloaded repository. That can be useful when the aim is to recognize reusable Terraform configuration versus an API integration plugin, but it does not directly deliver the requested ability to select a nested module directory inside a downloaded repository.

C:

A local module is loaded from the current filesystem tree; changes are visible with the current checkout instead of awaiting a registry release; this behavior should be assessed against the concrete need to select a nested module directory inside a downloaded repository. It may support a related workflow, but the question specifically requires the mechanism for select a nested module directory inside a downloaded repository rather than develop a shared component without publishing a remote module release.

D:

Published modules define an intended interface; callers supply declared variables and consume declared outputs; internal resources are implementation details; this behavior should be assessed against the concrete need to select a nested module directory inside a downloaded repository. The stated requirement is to select a nested module directory inside a downloaded repository, not to integrate the module without assuming internal resource names are its API; this alternative addresses a different control or phase.

Question 528

An engineer needs to catch incompatible caller values before deployment as part of an automated release. Which option is the best fit?

  1. Avoid referencing child local values from the parent
  2. Use a default on a child input for optional behavior
  3. Use typed module inputs
  4. Declare inputs in a child variable block

Explanation

Correct Answer

C:

Type constraints describe accepted strings, collections, or nested objects; they make the child-module contract more predictable than undocumented any values; this behavior should be assessed against the concrete need to catch incompatible caller values before deployment. This directly supports the task to catch incompatible caller values before deployment during an infrastructure audit.

Incorrect Answers

A:

Only outputs are exposed for general child-module consumption; callers should not depend on private local names that may change during refactoring; this behavior should be assessed against the concrete need to catch incompatible caller values before deployment. The stated requirement is to catch incompatible caller values before deployment, not to preserve encapsulation of implementation-only calculations; this alternative addresses a different control or phase.

B:

A variable default supplies the value within the child when no argument is passed; other child inputs without defaults remain required; this behavior should be assessed against the concrete need to catch incompatible caller values before deployment. That can be useful when the aim is to allow callers to omit that specific module argument, but it does not directly deliver the requested ability to catch incompatible caller values before deployment.

D:

Each module declares its own variable names and constraints; a child does not automatically inherit all root input variables; this behavior should be assessed against the concrete need to catch incompatible caller values before deployment. It may support a related workflow, but the question specifically requires the mechanism for catch incompatible caller values before deployment rather than accept values from the calling module through a documented interface.

Question 529

An engineer wants to instantiate multiple copies of a component. Two independent changes are requested: first, test in-repository child changes before publishing a version; second, avoid assuming a backend in a child controls the caller's state. Which pair of measures fulfills both?

  1. Use a local module while iterating on a design + Share provider configurations from the root
  2. Use count on a compatible module call + Read module.web.endpoint after declaring an output
  3. Use a local module while iterating on a design + Keep backend configuration in the root module
  4. Use depends_on on a module when necessary + Keep backend configuration in the root module

Explanation

Correct Answer

C:

For the first criterion, a local path loads code directly from the checkout; this differs from upgrading an immutable release in an external module registry; this behavior should be assessed against the concrete need to test in-repository child changes before publishing a version and avoid assuming a backend in a child controls the caller's state; this directly addresses the need to test in-repository child changes before publishing a version. For the separate second criterion, the backend applies to the top-level working configuration; child modules cannot independently select state storage during a normal shared module call; this behavior should be assessed against the concrete need to test in-repository child changes before publishing a version and avoid assuming a backend in a child controls the caller's state; this fulfills the need to avoid assuming a backend in a child controls the caller's state. Together they cover the independent tasks of test in-repository child changes before publishing a version and avoid assuming a backend in a child controls the caller's state without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to test in-repository child changes before publishing a version, but its partner serves a different role: A child module should declare provider requirements while receiving provider configurations through inheritance or explicit mapping; this supports flexible reuse; this behavior should be assessed against the concrete need to test in-repository child changes before publishing a version and avoid assuming a backend in a child controls the caller's state. That second component is designed to avoid configuring cloud credentials separately in every reusable child, so the still-missing criterion is to avoid assuming a backend in a child controls the caller's state, while the first criterion remains test in-repository child changes before publishing a version.

B:

The first measure is intended to create a numbered collection of module instances: Count produces addresses such as module.worker[0]; each instance can receive a different input computed from count.index; this behavior should be assessed against the concrete need to test in-repository child changes before publishing a version and avoid assuming a backend in a child controls the caller's state. The second measure is intended to consume a child module result in the caller: Only named output values are exposed by the module reference; the caller cannot assume internal resource addresses are directly visible; this behavior should be assessed against the concrete need to test in-repository child changes before publishing a version and avoid assuming a backend in a child controls the caller's state. Neither is the directly designated method for the separate goals of test in-repository child changes before publishing a version and avoid assuming a backend in a child controls the caller's state in this review.

D:

The second measure does meet the avoid assuming a backend in a child controls the caller's state requirement, but the first is designed for another concern: An explicit module dependency orders its operations after the listed object; prefer output references when they can express the dependency more narrowly; this behavior should be assessed against the concrete need to test in-repository child changes before publishing a version and avoid assuming a backend in a child controls the caller's state. That first component is designed to enforce a hidden prerequisite for an entire child module, which does not accomplish the requested task to test in-repository child changes before publishing a version, even though the other measure satisfies avoid assuming a backend in a child controls the caller's state.

Question 530

A reusable module is receiving controlled releases. A reviewer must determine how to distinguish registry version selection from source identification. Which action is the appropriate choice?

  1. Run terraform init -upgrade after changing a version range
  2. Specify a registry module version in the call
  3. Use ?ref=COMMIT on a Git module
  4. Use a release tag as a Git source ref

Explanation

Correct Answer

B:

The source says which module to fetch, while version constrains published versions; both are important for predictable registry consumption; this behavior should be assessed against the concrete need to distinguish registry version selection from source identification. This directly supports the task to distinguish registry version selection from source identification during a cross-team handoff.

Incorrect Answers

A:

Upgrade mode re-fetches and reevaluates eligible dependencies; existing infrastructure does not change until a subsequent plan/apply; this behavior should be assessed against the concrete need to distinguish registry version selection from source identification. The distinction matters here: using that mechanism to refresh external module and provider selections to newly permitted releases would still leave the objective to distinguish registry version selection from source identification unmet.

C:

A commit hash identifies precise source content; module version arguments are not interpreted for raw Git sources; this behavior should be assessed against the concrete need to distinguish registry version selection from source identification. The stated requirement is to distinguish registry version selection from source identification, not to choose a specific revision from an external Git repository; this alternative addresses a different control or phase.

D:

A Git tag can name a release, but mutable tags remain a repository-governance risk; this version control is separate from registry module version constraints; this behavior should be assessed against the concrete need to distinguish registry version selection from source identification. That can be useful when the aim is to refer to a known Git module milestone, but it does not directly deliver the requested ability to distinguish registry version selection from source identification.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests