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

Question 470

During an infrastructure design review about how to send the correct region-specific provider into a reusable child module, a maintainer asks what “Module provider mappings” does. Which description is accurate?

  1. The providers map on the module call maps child provider names to selected provider configurations from the root module.
  2. All Terraform configuration files in a module directory are combined as one module; filenames do not define separate execution units.
  3. The count meta-argument creates numerically indexed module instances such as module.worker[0].
  4. Two module blocks that use the same source create separate module instances and separate resource addresses.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to send the correct region-specific provider into a reusable child module, so it produces the behavior described. In contrast, multiple calls to one module serves a different goal: deploy two independently managed stacks from the same module definition, not send the correct region-specific provider into a reusable child module.

Incorrect Answers

B:

The description applies to a module root directory when an engineer needs to understand which source files Terraform loads as one module; the named module provider mappings instead handles the requirement to send the correct region-specific provider into a reusable child module, so this behavior does not describe Module provider mappings in the situation named.

C:

The description applies to a module with count when an engineer needs to instantiate a fixed number of child module copies; the named module provider mappings instead handles the requirement to send the correct region-specific provider into a reusable child module, so this behavior does not describe Module provider mappings in the situation named.

D:

The description applies to multiple calls to one module when an engineer needs to deploy two independently managed stacks from the same module definition; the named module provider mappings instead handles the requirement to send the correct region-specific provider into a reusable child module, so this behavior does not describe Module provider mappings in the situation named.

Question 471

A team consuming shared Terraform modules has a concrete implementation goal: install a newly allowed child module release after editing its version requirement. What is the most appropriate Terraform mechanism?

  1. A Git tag pin for a module
  2. Init after module version change
  3. A pessimistic module version constraint
  4. Provider and module version separation
  5. Init -upgrade for registry modules

Explanation

Correct Answer

B:

Changing a module source or version constraint requires reinitializing to resolve the updated selection; this directly meets the requirement to install a newly allowed child module release after editing its version requirement. By comparison, provider and module version separation is intended to avoid confusing provider plugin selection with reusable module source selection, which is a different task from install a newly allowed child module release after editing its version requirement.

Incorrect Answers

A:

A Git module's ?ref= tag or commit selects a repository revision instead of a registry module version constraint; this mechanism is useful when the job is to select a specific VCS module release without using a registry version argument, whereas the current scenario requires the engineer to install a newly allowed child module release after editing its version requirement. These operations have different effects in the stated Terraform workflow.

C:

A module version ~> 2.1.0 permits 2.1.x releases but excludes 2.2.0 and later; this mechanism is useful when the job is to allow compatible patch updates within a module's minor release series, whereas the current scenario requires the engineer to install a newly allowed child module release after editing its version requirement. These operations have different effects in the stated Terraform workflow.

D:

Provider versions are constrained in required_providers and locked in .terraform.lock.hcl; registry modules use their module block version arguments; this mechanism is useful when the job is to avoid confusing provider plugin selection with reusable module source selection, whereas the current scenario requires the engineer to install a newly allowed child module release after editing its version requirement. These operations have different effects in the stated Terraform workflow.

E:

The upgrade mode reselects module versions subject to constraints instead of automatically keeping the previously installed copy; this mechanism is useful when the job is to consider newer published module releases already allowed by a version constraint, whereas the current scenario requires the engineer to install a newly allowed child module release after editing its version requirement. These operations have different effects in the stated Terraform workflow.

Question 472

A runbook lists “The ternary conditional operator” for the task to set a resource argument according to a boolean expression. Which technical effect should its description include?

  1. keys returns a lexicographically sorted list of map keys, useful for deterministic iteration.
  2. coalesce returns the first usable argument after skipping null or empty strings; it is not a boolean operator.
  3. one returns the lone member, or null if empty, and reports an error when more than one element exists.
  4. The condition ? value_a : value_b expression chooses a suitable branch without creating duplicate resource blocks.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to set a resource argument according to a boolean expression, so it produces the behavior described. In contrast, the keys function serves a different goal: list the names of keys defined in a map, not set a resource argument according to a boolean expression.

Incorrect Answers

A:

The description applies to the keys function when an engineer needs to list the names of keys defined in a map; the named the ternary conditional operator instead handles the requirement to set a resource argument according to a boolean expression, so this behavior does not describe The ternary conditional operator in the situation named.

B:

The description applies to the coalesce function when an engineer needs to pick the first non-null and nonempty string among candidate values; the named the ternary conditional operator instead handles the requirement to set a resource argument according to a boolean expression, so this behavior does not describe The ternary conditional operator in the situation named.

C:

The description applies to the one function when an engineer needs to extract a single element from a collection that contains zero or one elements; the named the ternary conditional operator instead handles the requirement to set a resource argument according to a boolean expression, so this behavior does not describe The ternary conditional operator in the situation named.

Question 473

An application stack composed of modules has a concrete implementation goal: avoid confusing provider plugin selection with reusable module source selection. What is the most appropriate Terraform mechanism?

  1. Init after module version change
  2. A registry module version constraint
  3. Provider and module version separation
  4. A Git tag pin for a module
  5. A pessimistic module version constraint

Explanation

Correct Answer

C:

Provider versions are constrained in required_providers and locked in .terraform.lock.hcl; registry modules use their module block version arguments; this directly meets the requirement to avoid confusing provider plugin selection with reusable module source selection. By comparison, a pessimistic module version constraint is intended to allow compatible patch updates within a module's minor release series, which is a different task from avoid confusing provider plugin selection with reusable module source selection.

Incorrect Answers

A:

Changing a module source or version constraint requires reinitializing to resolve the updated selection; this mechanism is useful when the job is to install a newly allowed child module release after editing its version requirement, whereas the current scenario requires the engineer to avoid confusing provider plugin selection with reusable module source selection. These operations have different effects in the stated Terraform workflow.

B:

The module version argument accepts version constraints for registry sources and Terraform resolves compatible published releases during init; this mechanism is useful when the job is to select a supported module release range from the registry, whereas the current scenario requires the engineer to avoid confusing provider plugin selection with reusable module source selection. These operations have different effects in the stated Terraform workflow.

D:

A Git module's ?ref= tag or commit selects a repository revision instead of a registry module version constraint; this mechanism is useful when the job is to select a specific VCS module release without using a registry version argument, whereas the current scenario requires the engineer to avoid confusing provider plugin selection with reusable module source selection. These operations have different effects in the stated Terraform workflow.

E:

A module version ~> 2.1.0 permits 2.1.x releases but excludes 2.2.0 and later; this mechanism is useful when the job is to allow compatible patch updates within a module's minor release series, whereas the current scenario requires the engineer to avoid confusing provider plugin selection with reusable module source selection. These operations have different effects in the stated Terraform workflow.

Question 474

A change request asks an engineer to store a collection with no duplicate members and no guaranteed order. Which choice best implements the requested behavior?

  1. A set of strings type
  2. An unknown plan-time value
  3. for_each with a map
  4. An optional object attribute

Explanation

Correct Answer

A:

The set(string) type deduplicates values and does not preserve a meaningful input element order; this directly meets the requirement to store a collection with no duplicate members and no guaranteed order. By comparison, an optional object attribute is intended to accept an omitted field in a structured object input, which is a different task from store a collection with no duplicate members and no guaranteed order.

Incorrect Answers

B:

An unknown value represents future information and can propagate through expressions until a provider supplies the result; this mechanism is useful when the job is to identify a computed attribute that Terraform cannot determine until apply, whereas the current scenario requires the engineer to store a collection with no duplicate members and no guaranteed order. These operations have different effects in the stated Terraform workflow.

C:

A resource's for_each meta-argument accepts maps or sets of strings; map keys appear in resource addresses; this mechanism is useful when the job is to create instances using stable logical keys rather than shifting numeric indexes, whereas the current scenario requires the engineer to store a collection with no duplicate members and no guaranteed order. These operations have different effects in the stated Terraform workflow.

D:

The optional type modifier inside an object constraint allows the caller to omit a field and optionally sets a default; this mechanism is useful when the job is to accept an omitted field in a structured object input, whereas the current scenario requires the engineer to store a collection with no duplicate members and no guaranteed order. These operations have different effects in the stated Terraform workflow.

Question 475

A runbook lists “A set of strings type” for the task to store a collection with no duplicate members and no guaranteed order. Which technical effect should its description include?

  1. Terraform's condition ? true_value : false_value syntax chooses one branch while reconciling compatible result types.
  2. In supported contexts, setting an optional resource argument to null behaves like leaving that argument unset.
  3. The any constraint is a placeholder for any compatible concrete type; explicit types generally provide better module contracts.
  4. The set(string) type deduplicates values and does not preserve a meaningful input element order.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to store a collection with no duplicate members and no guaranteed order, so it produces the behavior described. In contrast, the any type constraint serves a different goal: accept values without imposing a specific static input shape, not store a collection with no duplicate members and no guaranteed order.

Incorrect Answers

A:

The description applies to a conditional expression when an engineer needs to select between two expression results based on a boolean predicate; the named a set of strings type instead handles the requirement to store a collection with no duplicate members and no guaranteed order, so this behavior does not describe A set of strings type in the situation named.

B:

The description applies to the null value when an engineer needs to represent the absence of an optional argument value; the named a set of strings type instead handles the requirement to store a collection with no duplicate members and no guaranteed order, so this behavior does not describe A set of strings type in the situation named.

C:

The description applies to the any type constraint when an engineer needs to accept values without imposing a specific static input shape; the named a set of strings type instead handles the requirement to store a collection with no duplicate members and no guaranteed order, so this behavior does not describe A set of strings type in the situation named.

Question 476

A multi-provider deployment design needs to detect a mismatched plugin distribution package. Which feature or operation is the most direct match?

  1. Provider integrity hashes
  2. Provider authentication environment variables
  3. The provider block
  4. A provider plugin

Explanation

Correct Answer

A:

Terraform checks downloaded provider package checksums against lock information where hashes are available; this directly meets the requirement to detect a mismatched plugin distribution package. By comparison, the provider block is intended to configure API connection settings for an already required provider, which is a different task from detect a mismatched plugin distribution package.

Incorrect Answers

B:

Many provider plugins can read credentials from provider-specific environment variables or identity mechanisms, reducing secret exposure in configuration; this mechanism is useful when the job is to avoid hard-coding a provider's API credential into .tf files, whereas the current scenario requires the engineer to detect a mismatched plugin distribution package. These operations have different effects in the stated Terraform workflow.

C:

A provider block can configure an endpoint, region or authentication parameters but should not carry the provider's version constraint; this mechanism is useful when the job is to configure API connection settings for an already required provider, whereas the current scenario requires the engineer to detect a mismatched plugin distribution package. These operations have different effects in the stated Terraform workflow.

D:

Providers implement resource and data-source schemas plus read, create, update and delete operations for their services; this mechanism is useful when the job is to translate Terraform resource operations into calls to the relevant remote API, whereas the current scenario requires the engineer to detect a mismatched plugin distribution package. These operations have different effects in the stated Terraform workflow.

Question 477

A configuration review for an application stack has a concrete implementation goal: verify an invariant about a resource after reading or managing it. What is the most appropriate Terraform mechanism?

  1. The error_message field
  2. Input validation versus check blocks
  3. Resource postcondition
  4. Input variable validation

Explanation

Correct Answer

C:

A postcondition evaluates a condition concerning resource results and blocks downstream use when its assertion fails; this directly meets the requirement to verify an invariant about a resource after reading or managing it. By comparison, input variable validation is intended to reject malformed module inputs before provisioning resources, which is a different task from verify an invariant about a resource after reading or managing it.

Incorrect Answers

A:

Validation, precondition and postcondition definitions use error_message to tell the operator why a rule failed; this mechanism is useful when the job is to present a meaningful explanation when a custom condition evaluates false, whereas the current scenario requires the engineer to verify an invariant about a resource after reading or managing it. These operations have different effects in the stated Terraform workflow.

B:

Variable validation rejects unacceptable values, whereas failed check assertions are intended for diagnostic warnings; this mechanism is useful when the job is to choose a blocking input constraint rather than a monitoring-style assertion, whereas the current scenario requires the engineer to verify an invariant about a resource after reading or managing it. These operations have different effects in the stated Terraform workflow.

D:

The validation block uses a condition and a custom error_message to enforce rules on caller-supplied values; this mechanism is useful when the job is to reject malformed module inputs before provisioning resources, whereas the current scenario requires the engineer to verify an invariant about a resource after reading or managing it. These operations have different effects in the stated Terraform workflow.

Question 478

Reviewers reject “Lock ownership verification” as a way to serialize operations that write the same Terraform state. Which actual behavior explains why the proposal is unsuitable?

  1. A lock may belong to another active run, so check its identity and run status rather than immediately forcing removal.
  2. A state backend with locking helps serialize competing changes, complemented by pipeline approval and run coordination.
  3. HCP Terraform coordinates workspace runs and state handling, reducing conflicts among collaborating operators.
  4. Supported backends acquire a state lock so simultaneous writers cannot corrupt or overwrite each other's state changes.

Explanation

Correct Answer

A:

Lock ownership verification is used when an operator needs to confirm that a held lock is stale before attempting manual removal. Consequently, this choice cannot meet the separate requirement to serialize operations that write the same Terraform state. The intended action would instead require A backend state lock.

Incorrect Answers

B:

This behavior belongs to State consistency during CI, which helps engineers keep two pipelines from changing the same infrastructure state simultaneously rather than satisfying the separate requirement to serialize operations that write the same Terraform state. The attempted technique was Lock ownership verification; it would instead be used to confirm that a held lock is stale before attempting manual removal, not to produce the effect associated with State consistency during CI.

C:

This behavior belongs to HCP Terraform run serialization, which helps engineers avoid multiple infrastructure applies targeting the same shared HCP workspace state rather than satisfying the separate requirement to serialize operations that write the same Terraform state. The attempted technique was Lock ownership verification; it would instead be used to confirm that a held lock is stale before attempting manual removal, not to produce the effect associated with HCP Terraform run serialization.

D:

That outcome belongs to A backend state lock, the mechanism that can serialize operations that write the same Terraform state. The question concerns the engineer’s actual proposal, Lock ownership verification; it is directed at confirm that a held lock is stale before attempting manual removal, not that result.

Question 479

A Terraform module author requires a way to create a deterministic SHA-256 digest for content comparison. Which Terraform approach most directly fulfills that request?

  1. The ternary conditional operator
  2. The substr function
  3. The sha256 function
  4. The keys function

Explanation

Correct Answer

C:

sha256 computes a one-way hash of a string, not an encrypted recoverable secret or random credential; this directly meets the requirement to create a deterministic SHA-256 digest for content comparison. By comparison, the substr function is intended to extract a specific range of characters from a string, which is a different task from create a deterministic SHA-256 digest for content comparison.

Incorrect Answers

A:

The condition ? value_a : value_b expression chooses a suitable branch without creating duplicate resource blocks; this mechanism is useful when the job is to set a resource argument according to a boolean expression, whereas the current scenario requires the engineer to create a deterministic SHA-256 digest for content comparison. These operations have different effects in the stated Terraform workflow.

B:

substr returns characters starting at an offset with the specified length rather than splitting on a delimiter; this mechanism is useful when the job is to extract a specific range of characters from a string, whereas the current scenario requires the engineer to create a deterministic SHA-256 digest for content comparison. These operations have different effects in the stated Terraform workflow.

D:

keys returns a lexicographically sorted list of map keys, useful for deterministic iteration; this mechanism is useful when the job is to list the names of keys defined in a map, whereas the current scenario requires the engineer to create a deterministic SHA-256 digest for content comparison. These operations have different effects in the stated Terraform workflow.

Question 480

Reviewers reject “Backend configuration only in a root module” as a way to store Terraform state in a file in the working directory by default. Which actual behavior explains why the proposal is unsuitable?

  1. Backend configuration is evaluated for the root module; defining backend settings inside reusable child modules does not give them separate state.
  2. Local state can hold raw provider attributes and secrets, so filesystem access controls and encryption matter.
  3. Terraform commonly writes backup snapshots for local state updates, but backups require the same confidentiality controls as state.
  4. Without another backend, Terraform uses the local backend and writes its default workspace state to terraform.tfstate.

Explanation

Correct Answer

A:

Backend configuration only in a root module is used when an operator needs to choose where a root deployment's state will be stored. Consequently, this choice cannot meet the separate requirement to store Terraform state in a file in the working directory by default. The intended action would instead require The default local backend.

Incorrect Answers

B:

This behavior belongs to State file confidentiality, which helps engineers protect a workstation's local state file even when output values are hidden rather than satisfying the separate requirement to store Terraform state in a file in the working directory by default. The attempted technique was Backend configuration only in a root module; it would instead be used to choose where a root deployment's state will be stored, not to produce the effect associated with State file confidentiality.

C:

This behavior belongs to A local state backup file, which helps engineers recover from a state change without relying solely on an unversioned primary file rather than satisfying the separate requirement to store Terraform state in a file in the working directory by default. The attempted technique was Backend configuration only in a root module; it would instead be used to choose where a root deployment's state will be stored, not to produce the effect associated with A local state backup file.

D:

That outcome belongs to The default local backend, the mechanism that can store Terraform state in a file in the working directory by default. The question concerns the engineer’s actual proposal, Backend configuration only in a root module; it is directed at choose where a root deployment's state will be stored, not that result.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests