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

Question 540

A reviewer has to approve a two-part design: assign the caller's value to the child's required variable; additionally, assign different values to identically named inputs in two distinct module instances. Which option pairs the correct mechanisms?

  1. Pass a child input in the module block + Keep same-named child inputs separate across module calls
  2. Expose selected values via output blocks + Keep same-named child inputs separate across module calls
  3. Use child locals for internal derivations + Pass a root output through a child input explicitly
  4. Pass a child input in the module block + Use typed module inputs

Explanation

Correct Answer

A:

For the first criterion, 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 assign the caller's value to the child's required variable and assign different values to identically named inputs in two distinct module instances; this directly addresses the need to assign the caller's value to the child's required variable. For the separate second criterion, each call has its own variable namespace and argument values; passing region = "east" in one module call does not alter var.region inside another instance; this behavior should be assessed against the concrete need to assign the caller's value to the child's required variable and assign different values to identically named inputs in two distinct module instances; this fulfills the need to assign different values to identically named inputs in two distinct module instances. Together they cover the independent tasks of assign the caller's value to the child's required variable and assign different values to identically named inputs in two distinct module instances without exchanging the responsibilities of these features.

Incorrect Answers

B:

The second measure does meet the assign different values to identically named inputs in two distinct module instances requirement, but the first is designed for another concern: 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 assign the caller's value to the child's required variable and assign different values to identically named inputs in two distinct module instances. That first component is designed to allow a caller to reference child results, which does not accomplish the requested task to assign the caller's value to the child's required variable, even though the other measure satisfies assign different values to identically named inputs in two distinct module instances.

C:

The first measure is intended to compute implementation details without exposing extra inputs: Local values are not parameters the caller can set directly; they provide readable internal names for expressions derived from variables and resources; this behavior should be assessed against the concrete need to assign the caller's value to the child's required variable and assign different values to identically named inputs in two distinct module instances. The second measure is intended to connect two modules while preserving their separate scopes: 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 assign the caller's value to the child's required variable and assign different values to identically named inputs in two distinct module instances. Neither is the directly designated method for the separate goals of assign the caller's value to the child's required variable and assign different values to identically named inputs in two distinct module instances in this review.

D:

The first measure meets the requirement to assign the caller's value to the child's required variable, 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 assign the caller's value to the child's required variable and assign different values to identically named inputs in two distinct module instances. That second component is designed to catch incompatible caller values before deployment, so the still-missing criterion is to assign different values to identically named inputs in two distinct module instances, while the first criterion remains assign the caller's value to the child's required variable.

Question 541

A Terraform review separates 2 requirements: (1) meet the child module's variable contract; (2) keep reusable components small and interoperable. Identify the two features that each directly handle one of those requirements. Choose TWO.

  1. Supply required module input arguments
  2. Pass the providers mapping to a child
  3. Build a root orchestration module
  4. Use for_each on a compatible module call
  5. Use multiple child modules to separate responsibilities

Explanation

Correct Answers

A:

Terraform maps arguments by name to variables declared inside the child; missing required values prevent a valid plan; this behavior should be assessed against the concrete need to meet the child module's variable contract and keep reusable components small and interoperable. This matches the distinct objective to meet the child module's variable contract; the remaining chosen features address keep reusable components small and interoperable.

E:

Well-defined module outputs connect independent components without cloning all resource blocks; the overall run still uses one state for that root configuration; this behavior should be assessed against the concrete need to meet the child module's variable contract and keep reusable components small and interoperable. This matches the distinct objective to keep reusable components small and interoperable; the remaining chosen features address meet the child module's variable contract.

Incorrect Answers

B:

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 meet the child module's variable contract and keep reusable components small and interoperable. Its main application is to select which root provider configurations the module uses; the checklist instead asks for meet the child module's variable contract; and keep reusable components small and interoperable. None of those distinct criteria specifically calls for this alternative.

C:

The root module can connect network, compute, and monitoring children through inputs and outputs; each child's encapsulation reduces repeated configuration; this behavior should be assessed against the concrete need to meet the child module's variable contract and keep reusable components small and interoperable. Its main application is to compose specialized children without embedding infrastructure logic everywhere; the checklist instead asks for meet the child module's variable contract; and keep reusable components small and interoperable. None of those distinct criteria specifically calls for this alternative.

D:

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 meet the child module's variable contract and keep reusable components small and interoperable. Its main application is to instantiate a module per stable map or set key; the checklist instead asks for meet the child module's variable contract; and keep reusable components small and interoperable. None of those distinct criteria specifically calls for this alternative.

Question 542

A reusable module is receiving controlled releases. The team must both allow compatible registry releases within a bounded series and permit a defined compatible interval of releases. Which paired choice implements those distinct goals?

  1. Set version = "= 1.4.2" on a registry module + Use >= 1.2.0, < 2.0.0 for registry modules
  2. Set version = "~> 2.3" on a registry module + Use >= 1.2.0, < 2.0.0 for registry modules
  3. Recognize module versions are not locked by .terraform.lock.hcl + Run terraform init -upgrade after changing a version range
  4. Set version = "~> 2.3" on a registry module + Review the plan after a module upgrade

Explanation

Correct Answer

B:

For the first criterion, the pessimistic version constraint selects an eligible published release; it cannot pin raw Git URLs because that source uses its own reference mechanism; this behavior should be assessed against the concrete need to allow compatible registry releases within a bounded series and permit a defined compatible interval of releases; this directly addresses the need to allow compatible registry releases within a bounded series. For the separate second criterion, multiple constraints are intersected when selecting registry module versions; they express an acceptable range, not a request to always use the latest major release; this behavior should be assessed against the concrete need to allow compatible registry releases within a bounded series and permit a defined compatible interval of releases; this fulfills the need to permit a defined compatible interval of releases. Together they cover the independent tasks of allow compatible registry releases within a bounded series and permit a defined compatible interval of releases without exchanging the responsibilities of these features.

Incorrect Answers

A:

The second measure does meet the permit a defined compatible interval of releases requirement, but the first is designed for another concern: An equality constraint selects a specific registry release; it avoids accidental upgrades until the configuration is changed; this behavior should be assessed against the concrete need to allow compatible registry releases within a bounded series and permit a defined compatible interval of releases. That first component is designed to use one exact published module version for reproducible runs, which does not accomplish the requested task to allow compatible registry releases within a bounded series, even though the other measure satisfies permit a defined compatible interval of releases.

C:

The first measure is intended to avoid assuming the provider lock file pins downloaded module packages: 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 allow compatible registry releases within a bounded series and permit a defined compatible interval of releases. The second measure is intended to refresh external module and provider selections to newly permitted releases: 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 allow compatible registry releases within a bounded series and permit a defined compatible interval of releases. Neither is the directly designated method for the separate goals of allow compatible registry releases within a bounded series and permit a defined compatible interval of releases in this review.

D:

The first measure meets the requirement to allow compatible registry releases within a bounded series, 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 allow compatible registry releases within a bounded series and permit a defined compatible interval of releases. That second component is designed to spot effects caused by changed child resource definitions, so the still-missing criterion is to permit a defined compatible interval of releases, while the first criterion remains allow compatible registry releases within a bounded series.

Question 543

A reviewer has to approve a two-part design: select a nested module directory inside a downloaded repository; additionally, develop a shared component without publishing a remote module release. Which option pairs the correct mechanisms?

  1. Use //subdirectory in an external module source + Use a local module source for rapid in-repository changes
  2. Use git::https://... as the source + Run terraform init after adding an external module
  3. Use //subdirectory in an external module source + Use ?ref=v1.4.0 with a Git source
  4. Understand source address is required for a module call + Use a local module source for rapid in-repository changes

Explanation

Correct Answer

A:

For the first criterion, 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 and develop a shared component without publishing a remote module release; this directly addresses the need to select a nested module directory inside a downloaded repository. For the separate second criterion, 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 and develop a shared component without publishing a remote module release; this fulfills the need to develop a shared component without publishing a remote module release. Together they cover the independent tasks of select a nested module directory inside a downloaded repository and develop a shared component without publishing a remote module release without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to fetch module code directly from a Git repository: 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 select a nested module directory inside a downloaded repository and develop a shared component without publishing a remote module release. The second measure is intended to download newly declared module source code: Initialization retrieves remote modules and prepares the local working directory. terraform fmt cannot fetch source packages; this behavior should be assessed against the concrete need to select a nested module directory inside a downloaded repository and develop a shared component without publishing a remote module release. Neither is the directly designated method for the separate goals of select a nested module directory inside a downloaded repository and develop a shared component without publishing a remote module release in this review.

C:

The first measure meets the requirement to select a nested module directory inside a downloaded repository, but its partner serves a different role: A Git ref selects code from the repository; for reproducibility a commit or immutable release tag is safer than a moving branch; this behavior should be assessed against the concrete need to select a nested module directory inside a downloaded repository and develop a shared component without publishing a remote module release. That second component is designed to pin a Git-sourced module to a named tag, commit, or branch reference, so the still-missing criterion is to develop a shared component without publishing a remote module release, while the first criterion remains select a nested module directory inside a downloaded repository.

D:

The second measure does meet the develop a shared component without publishing a remote module release requirement, but the first is designed for another concern: The source argument resolves module code; a module block with no valid source cannot simply invent the child's resources; this behavior should be assessed against the concrete need to select a nested module directory inside a downloaded repository and develop a shared component without publishing a remote module release. That first component is designed to identify where Terraform should load the child configuration, which does not accomplish the requested task to select a nested module directory inside a downloaded repository, even though the other measure satisfies develop a shared component without publishing a remote module release.

Question 544

In a planned migration, the requested result is to assign different values to identically named inputs in two distinct module instances. What should the engineer select?

  1. Declare inputs in a child variable block
  2. Use a default on a child input for optional behavior
  3. Keep same-named child inputs separate across module calls
  4. Treat module output sensitivity as contagious

Explanation

Correct Answer

C:

Each call has its own variable namespace and argument values; passing region = "east" in one module call does not alter var.region inside another instance; this behavior should be assessed against the concrete need to assign different values to identically named inputs in two distinct module instances. This directly supports the task to assign different values to identically named inputs in two distinct module instances during a deployment checklist.

Incorrect Answers

A:

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 assign different values to identically named inputs in two distinct module instances. The stated requirement is to assign different values to identically named inputs in two distinct module instances, not to accept values from the calling module through a documented interface; 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 assign different values to identically named inputs in two distinct module instances. 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 assign different values to identically named inputs in two distinct module instances.

D:

Sensitive values can flow across module boundaries; a root output exposing a sensitive value generally needs an explicit sensitive marking; state protection remains necessary; this behavior should be assessed against the concrete need to assign different values to identically named inputs in two distinct module instances. It may support a related workflow, but the question specifically requires the mechanism for assign different values to identically named inputs in two distinct module instances rather than avoid accidentally publishing a secret through the caller's outputs.

Question 545

An engineer needs to instantiate a module per stable map or set key as part of a planned migration. Which option is the best fit?

  1. Use for_each on a compatible module call
  2. Use depends_on on a module when necessary
  3. Share provider configurations from the root
  4. Use count on a compatible module call

Explanation

Correct Answer

A:

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 instantiate a module per stable map or set key. This directly supports the task to instantiate a module per stable map or set key during a maintenance request.

Incorrect Answers

B:

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 instantiate a module per stable map or set key. The stated requirement is to instantiate a module per stable map or set key, not to enforce a hidden prerequisite for an entire child module; this alternative addresses a different control or phase.

C:

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 instantiate a module per stable map or set key. That can be useful when the aim is to avoid configuring cloud credentials separately in every reusable child, but it does not directly deliver the requested ability to instantiate a module per stable map or set key.

D:

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 instantiate a module per stable map or set key. The distinction matters here: using that mechanism to create a numbered collection of module instances would still leave the objective to instantiate a module per stable map or set key unmet.

Question 546

A Terraform configuration must avoid a surprise module upgrade. The requirement is to recognize that filesystem modules follow the current checkout. Which Terraform mechanism directly meets this requirement?

  1. Specify a registry module version in the call
  2. Recognize module versions are not locked by .terraform.lock.hcl
  3. Do not assign a version argument to a local path module
  4. Set version = "= 1.4.2" on a registry module

Explanation

Correct Answer

C:

Local source content is taken directly from disk; versioning needs repository practices rather than Terraform's registry-module version selector; this behavior should be assessed against the concrete need to recognize that filesystem modules follow the current checkout. This directly supports the task to recognize that filesystem modules follow the current checkout during an automated release.

Incorrect Answers

A:

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 recognize that filesystem modules follow the current checkout. The distinction matters here: using that mechanism to distinguish registry version selection from source identification would still leave the objective to recognize that filesystem modules follow the current checkout unmet.

B:

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 recognize that filesystem modules follow the current checkout. It may support a related workflow, but the question specifically requires the mechanism for recognize that filesystem modules follow the current checkout rather than avoid assuming the provider lock file pins downloaded module packages.

D:

An equality constraint selects a specific registry release; it avoids accidental upgrades until the configuration is changed; this behavior should be assessed against the concrete need to recognize that filesystem modules follow the current checkout. That can be useful when the aim is to use one exact published module version for reproducible runs, but it does not directly deliver the requested ability to recognize that filesystem modules follow the current checkout.

Question 547

In a planned migration, the requested result is to retrieve a published module from its registry address. What should the engineer select?

  1. Use git::https://... as the source
  2. Use source = "../shared"
  3. Avoid confusing a module with a provider
  4. Use //subdirectory in an external module source
  5. Use a public registry source namespace/name/provider
  6. Use ?ref=v1.4.0 with a Git source

Explanation

Correct Answer

E:

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 retrieve a published module from its registry address. This directly supports the task to retrieve a published module from its registry address during a deployment checklist.

Incorrect Answers

A:

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 retrieve a published module from its registry address. The distinction matters here: using that mechanism to fetch module code directly from a Git repository would still leave the objective to retrieve a published module from its registry address unmet.

B:

Parent-relative local paths allow neighboring configurations to share code; the directory must be present on the machine or in the checked-out repository; this behavior should be assessed against the concrete need to retrieve a published module from its registry address. It may support a related workflow, but the question specifically requires the mechanism for retrieve a published module from its registry address rather than reuse a module from a sibling directory.

C:

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 retrieve a published module from its registry address. The stated requirement is to retrieve a published module from its registry address, not to recognize reusable Terraform configuration versus an API integration plugin; this alternative addresses a different control or phase.

D:

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 retrieve a published module from its registry address. That can be useful when the aim is to select a nested module directory inside a downloaded repository, but it does not directly deliver the requested ability to retrieve a published module from its registry address.

F:

A Git ref selects code from the repository; for reproducibility a commit or immutable release tag is safer than a moving branch; this behavior should be assessed against the concrete need to retrieve a published module from its registry address. It may support a related workflow, but the question specifically requires the mechanism for retrieve a published module from its registry address rather than pin a Git-sourced module to a named tag, commit, or branch reference.

Question 548

An engineer needs to assign the caller's value to the child's required variable as part of a planned migration. Which option is the best fit?

  1. Avoid referencing child local values from the parent
  2. Use nullable = false for a non-null module input
  3. Use child locals for internal derivations
  4. Pass a child input in the module block

Explanation

Correct Answer

D:

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 assign the caller's value to the child's required variable. This directly supports the task to assign the caller's value to the child's required variable during a maintenance request.

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 assign the caller's value to the child's required variable. That can be useful when the aim is to preserve encapsulation of implementation-only calculations, but it does not directly deliver the requested ability to assign the caller's value to the child's required variable.

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 assign the caller's value to the child's required variable. The distinction matters here: using that mechanism to reject a caller's explicit null rather than accidentally passing it onward would still leave the objective to assign the caller's value to the child's required variable unmet.

C:

Local values are not parameters the caller can set directly; they provide readable internal names for expressions derived from variables and resources; this behavior should be assessed against the concrete need to assign the caller's value to the child's required variable. It may support a related workflow, but the question specifically requires the mechanism for assign the caller's value to the child's required variable rather than compute implementation details without exposing extra inputs.

Question 549

A module call requires provider settings and outputs. Two independent changes are requested: first, enforce a hidden prerequisite for an entire child module; second, test in-repository child changes before publishing a version. Which pair of measures fulfills both?

  1. Use depends_on on a module when necessary + Share provider configurations from the root
  2. Use depends_on on a module when necessary + Use a local module while iterating on a design
  3. Use count on a compatible module call + Pass the providers mapping to a child
  4. Use multiple child modules to separate responsibilities + Use a local module while iterating on a design

Explanation

Correct Answer

B:

For the first criterion, 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 enforce a hidden prerequisite for an entire child module and test in-repository child changes before publishing a version; this directly addresses the need to enforce a hidden prerequisite for an entire child module. For the separate second 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 enforce a hidden prerequisite for an entire child module and test in-repository child changes before publishing a version; this fulfills the need to test in-repository child changes before publishing a version. Together they cover the independent tasks of enforce a hidden prerequisite for an entire child module and test in-repository child changes before publishing a version without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure meets the requirement to enforce a hidden prerequisite for an entire child module, 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 enforce a hidden prerequisite for an entire child module and test in-repository child changes before publishing a version. That second component is designed to avoid configuring cloud credentials separately in every reusable child, so the still-missing criterion is to test in-repository child changes before publishing a version, while the first criterion remains enforce a hidden prerequisite for an entire child module.

C:

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 enforce a hidden prerequisite for an entire child module and test in-repository child changes before publishing a version. The second 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 enforce a hidden prerequisite for an entire child module and test in-repository child changes before publishing a version. Neither is the directly designated method for the separate goals of enforce a hidden prerequisite for an entire child module and test in-repository child changes before publishing a version in this review.

D:

The second measure does meet the test in-repository child changes before publishing a version requirement, but the first is designed for another concern: Well-defined module outputs connect independent components without cloning all resource blocks; the overall run still uses one state for that root configuration; this behavior should be assessed against the concrete need to enforce a hidden prerequisite for an entire child module and test in-repository child changes before publishing a version. That first component is designed to keep reusable components small and interoperable, which does not accomplish the requested task to enforce a hidden prerequisite for an entire child module, even though the other measure satisfies test in-repository child changes before publishing a version.

Question 550

A build pipeline compares module versioning across source types. A reviewer must determine how to spot effects caused by changed child resource definitions. Which action is the appropriate choice?

  1. Review the plan after a module upgrade
  2. Recognize module versions are not locked by .terraform.lock.hcl
  3. Do not assign a version argument to a local path module
  4. Use a release tag as a Git source ref

Explanation

Correct Answer

A:

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 spot effects caused by changed child resource definitions. This directly supports the task to spot effects caused by changed child resource definitions during a staged rollout.

Incorrect Answers

B:

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 spot effects caused by changed child resource definitions. The stated requirement is to spot effects caused by changed child resource definitions, not to avoid assuming the provider lock file pins downloaded module packages; this alternative addresses a different control or phase.

C:

Local source content is taken directly from disk; versioning needs repository practices rather than Terraform's registry-module version selector; this behavior should be assessed against the concrete need to spot effects caused by changed child resource definitions. That can be useful when the aim is to recognize that filesystem modules follow the current checkout, but it does not directly deliver the requested ability to spot effects caused by changed child resource definitions.

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 spot effects caused by changed child resource definitions. The distinction matters here: using that mechanism to refer to a known Git module milestone would still leave the objective to spot effects caused by changed child resource definitions unmet.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests