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

Question 310

A declarative resource and expression design requires a way to distinguish static configuration checks from conditions requiring actual resource values. Which Terraform approach most directly fulfills that request?

  1. Data source postcondition
  2. Postconditions for exported IDs
  3. terraform validate versus runtime assertions
  4. Input variable validation

Explanation

Correct Answer

C:

Static validate checks structural correctness, while condition expressions may depend on inputs or provider readings evaluated during plan or apply; this directly meets the requirement to distinguish static configuration checks from conditions requiring actual resource values. By comparison, data source postcondition is intended to reject use of queried data when it violates a required invariant, which is a different task from distinguish static configuration checks from conditions requiring actual resource values.

Incorrect Answers

A:

A postcondition on a data block can validate attributes returned from a provider before downstream resources rely on them; this mechanism is useful when the job is to reject use of queried data when it violates a required invariant, whereas the current scenario requires the engineer to distinguish static configuration checks from conditions requiring actual resource values. These operations have different effects in the stated Terraform workflow.

B:

Postconditions validate resultant resource or data-source attributes and prevent dependents from relying on invalid results; this mechanism is useful when the job is to guard a dependent consumer against a provider result that violates an invariant, whereas the current scenario requires the engineer to distinguish static configuration checks from conditions requiring actual resource values. 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 distinguish static configuration checks from conditions requiring actual resource values. These operations have different effects in the stated Terraform workflow.

Question 311

A runbook lists “An API token for CLI connectivity” for the task to authorize a Terraform CLI workflow to access an HCP Terraform organization. Which technical effect should its description include?

  1. A VCS-connected workspace coordinates code changes, speculative plans and controlled applies through supported repository integration.
  2. The HCP service token controls platform API authentication and is distinct from provider credentials used to modify cloud infrastructure.
  3. The cloud workspaces block supports a project setting for organizing related workspace integration.
  4. Migration requires setting HCP Terraform integration and handling state transfer rather than starting a blank workspace against existing objects.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to authorize a Terraform CLI workflow to access an HCP Terraform organization, so it produces the behavior described. In contrast, a cloud block project selector serves a different goal: associate an HCP Terraform workspace with an intended project during configuration, not authorize a Terraform CLI workflow to access an HCP Terraform organization.

Incorrect Answers

A:

The description applies to HCP Terraform VCS integration when an engineer needs to connect reviewed repository commits to automated infrastructure plans; the named an API token for CLI connectivity instead handles the requirement to authorize a Terraform CLI workflow to access an HCP Terraform organization, so this behavior does not describe An API token for CLI connectivity in the situation named.

C:

The description applies to a cloud block project selector when an engineer needs to associate an HCP Terraform workspace with an intended project during configuration; the named an API token for CLI connectivity instead handles the requirement to authorize a Terraform CLI workflow to access an HCP Terraform organization, so this behavior does not describe An API token for CLI connectivity in the situation named.

D:

The description applies to migrating state to HCP Terraform when an engineer needs to move an established root configuration from local state into a managed HCP workspace; the named an API token for CLI connectivity instead handles the requirement to authorize a Terraform CLI workflow to access an HCP Terraform organization, so this behavior does not describe An API token for CLI connectivity in the situation named.

Question 312

An engineer intends to identify a resource instance by its type and local name and is reviewing “The resource address format”. What consequence follows from using it as intended?

  1. Parent configurations access child outputs using module.CHILD.OUTPUT; private child resource addresses are not automatically exported.
  2. The depends_on meta-argument adds dependency edges for a known relationship that Terraform cannot otherwise infer.
  3. For a map-based for_each collection, each.value exposes the value associated with the current each.key.
  4. A resource address inside a module ordinarily uses TYPE.NAME, with optional instance indexing when count or for_each is used.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to identify a resource instance by its type and local name, so it produces the behavior described. In contrast, explicit depends_on serves a different goal: order resources when there is a dependency not expressed by attribute references, not identify a resource instance by its type and local name.

Incorrect Answers

A:

The description applies to a module output reference when an engineer needs to use a child module's published value in a parent resource; the named the resource address format instead handles the requirement to identify a resource instance by its type and local name, so this behavior does not describe The resource address format in the situation named.

B:

The description applies to explicit depends_on when an engineer needs to order resources when there is a dependency not expressed by attribute references; the named the resource address format instead handles the requirement to identify a resource instance by its type and local name, so this behavior does not describe The resource address format in the situation named.

C:

The description applies to each.value when an engineer needs to read the per-instance map value when iterating with for_each; the named the resource address format instead handles the requirement to identify a resource instance by its type and local name, so this behavior does not describe The resource address format in the situation named.

Question 313

A root module integrating child modules needs to use a nested module stored below a repository's root directory. Which feature or operation is the most direct match?

  1. terraform init for modules
  2. Registry module documentation
  3. The double-slash source subdirectory
  4. A public registry module source

Explanation

Correct Answer

C:

Module source syntax places //subdir after the package address to select the intended directory within the downloaded package; this directly meets the requirement to use a nested module stored below a repository's root directory. By comparison, a public registry module source is intended to download a community module published with an official registry address, which is a different task from use a nested module stored below a repository's root directory.

Incorrect Answers

A:

Initialization retrieves module sources and populates .terraform/modules while preparing other required dependencies; this mechanism is useful when the job is to install all referenced remote child modules before planning, whereas the current scenario requires the engineer to use a nested module stored below a repository's root directory. These operations have different effects in the stated Terraform workflow.

B:

Published module documentation and metadata describe the module interface and help consumers understand required arguments; this mechanism is useful when the job is to determine a module's declared inputs, outputs, providers and usage examples, whereas the current scenario requires the engineer to use a nested module stored below a repository's root directory. These operations have different effects in the stated Terraform workflow.

D:

Registry module sources use the namespace/name/provider address form and can support a separate version argument; this mechanism is useful when the job is to download a community module published with an official registry address, whereas the current scenario requires the engineer to use a nested module stored below a repository's root directory. These operations have different effects in the stated Terraform workflow.

Question 314

A Terraform runbook prescribes “A module with count” to control which published module release a root configuration consumes, but it does not meet the requirement. What does that step actually accomplish?

  1. All Terraform configuration files in a module directory are combined as one module; filenames do not define separate execution units.
  2. depends_on on a module call affects all resources and data sources inside that module and can constrain concurrency.
  3. The module block's version argument can constrain registry modules and is separate from Terraform CLI and provider version settings.
  4. The count meta-argument creates numerically indexed module instances such as module.worker[0].

Explanation

Correct Answer

D:

A module with count is used when an operator needs to instantiate a fixed number of child module copies. Consequently, this choice cannot meet the separate requirement to control which published module release a root configuration consumes. The intended action would instead require Using a module registry version.

Incorrect Answers

A:

This behavior belongs to A module root directory, which helps engineers understand which source files Terraform loads as one module rather than satisfying the separate requirement to control which published module release a root configuration consumes. The attempted technique was A module with count; it would instead be used to instantiate a fixed number of child module copies, not to produce the effect associated with A module root directory.

B:

This behavior belongs to Module-level depends_on, which helps engineers create an explicit ordering edge for module resources that have a real hidden dependency rather than satisfying the separate requirement to control which published module release a root configuration consumes. The attempted technique was A module with count; it would instead be used to instantiate a fixed number of child module copies, not to produce the effect associated with Module-level depends_on.

C:

That outcome belongs to Using a module registry version, the mechanism that can control which published module release a root configuration consumes. The question concerns the engineer’s actual proposal, A module with count; it is directed at instantiate a fixed number of child module copies, not that result.

Question 315

An engineer proposes “Provider integrity hashes” to avoid hard-coding a provider's API credential into .tf files. Which outcome does the proposed technique actually provide?

  1. The namespace portion of a source address separates provider publishers in the registry.
  2. A provider block can configure an endpoint, region or authentication parameters but should not carry the provider's version constraint.
  3. Terraform checks downloaded provider package checksums against lock information where hashes are available.
  4. Many provider plugins can read credentials from provider-specific environment variables or identity mechanisms, reducing secret exposure in configuration.

Explanation

Correct Answer

C:

Provider integrity hashes is used when an operator needs to detect a mismatched plugin distribution package. Consequently, this choice cannot meet the separate requirement to avoid hard-coding a provider's API credential into .tf files. The intended action would instead require Provider authentication environment variables.

Incorrect Answers

A:

This behavior belongs to The provider registry namespace, which helps engineers identify the publisher when providers share a type name rather than satisfying the separate requirement to avoid hard-coding a provider's API credential into .tf files. The attempted technique was Provider integrity hashes; it would instead be used to detect a mismatched plugin distribution package, not to produce the effect associated with The provider registry namespace.

B:

This behavior belongs to The provider block, which helps engineers configure API connection settings for an already required provider rather than satisfying the separate requirement to avoid hard-coding a provider's API credential into .tf files. The attempted technique was Provider integrity hashes; it would instead be used to detect a mismatched plugin distribution package, not to produce the effect associated with The provider block.

D:

That outcome belongs to Provider authentication environment variables, the mechanism that can avoid hard-coding a provider's API credential into .tf files. The question concerns the engineer’s actual proposal, Provider integrity hashes; it is directed at detect a mismatched plugin distribution package, not that result.

Question 316

A Terraform change proposal names “HCP Terraform run tasks integration” to send proposed changes to a third-party quality or security check service. Which outcome can reviewers attribute to that particular mechanism?

  1. The cloud workspaces block supports a project setting for organizing related workspace integration.
  2. The login command stores a CLI API token for the selected service host so CLI-driven workflows can authenticate.
  3. Run tasks integrate external systems into workflow checkpoints without changing the Terraform resource graph directly.
  4. Running init processes the cloud block and configures workspace connectivity before plans or applies.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to send proposed changes to a third-party quality or security check service, so it produces the behavior described. In contrast, terraform init after adding cloud integration serves a different goal: configure the local working directory to connect with the selected HCP workspace, not send proposed changes to a third-party quality or security check service.

Incorrect Answers

A:

The description applies to a cloud block project selector when an engineer needs to associate an HCP Terraform workspace with an intended project during configuration; the named HCP Terraform run tasks integration instead handles the requirement to send proposed changes to a third-party quality or security check service, so this behavior does not describe HCP Terraform run tasks integration in the situation named.

B:

The description applies to terraform login when an engineer needs to authenticate the local Terraform CLI to an HCP Terraform or Terraform Enterprise hostname; the named HCP Terraform run tasks integration instead handles the requirement to send proposed changes to a third-party quality or security check service, so this behavior does not describe HCP Terraform run tasks integration in the situation named.

D:

The description applies to terraform init after adding cloud integration when an engineer needs to configure the local working directory to connect with the selected HCP workspace; the named HCP Terraform run tasks integration instead handles the requirement to send proposed changes to a third-party quality or security check service, so this behavior does not describe HCP Terraform run tasks integration in the situation named.

Question 317

An engineer intends to refer specifically to the second object of a count-created resource and is reviewing “An instance address with count”. What consequence follows from using it as intended?

  1. The depends_on meta-argument adds dependency edges for a known relationship that Terraform cannot otherwise infer.
  2. Count instances have numeric indexes such as aws_instance.web[1] for the second instance.
  3. Parent configurations access child outputs using module.CHILD.OUTPUT; private child resource addresses are not automatically exported.
  4. Terraform cannot order a cycle of dependencies; restructure references or resource design to remove the circular edge.
  5. The syntax local.NAME accesses a locally defined expression evaluated in the current module.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to refer specifically to the second object of a count-created resource, so it produces the behavior described. In contrast, a local value reference serves a different goal: share one calculated expression among multiple resources in a module, not refer specifically to the second object of a count-created resource.

Incorrect Answers

A:

The description applies to explicit depends_on when an engineer needs to order resources when there is a dependency not expressed by attribute references; the named an instance address with count instead handles the requirement to refer specifically to the second object of a count-created resource, so this behavior does not describe An instance address with count in the situation named.

C:

The description applies to a module output reference when an engineer needs to use a child module's published value in a parent resource; the named an instance address with count instead handles the requirement to refer specifically to the second object of a count-created resource, so this behavior does not describe An instance address with count in the situation named.

D:

The description applies to avoiding dependency cycles when an engineer needs to resolve a graph where two resources each depend on the other; the named an instance address with count instead handles the requirement to refer specifically to the second object of a count-created resource, so this behavior does not describe An instance address with count in the situation named.

E:

The description applies to a local value reference when an engineer needs to share one calculated expression among multiple resources in a module; the named an instance address with count instead handles the requirement to refer specifically to the second object of a count-created resource, so this behavior does not describe An instance address with count in the situation named.

Question 318

A change request asks an engineer to create instances using stable logical keys rather than shifting numeric indexes. Which choice best implements the requested behavior?

  1. A tuple type
  2. for_each with a map
  3. The any type constraint
  4. A number variable type

Explanation

Correct Answer

B:

A resource's for_each meta-argument accepts maps or sets of strings; map keys appear in resource addresses; this directly meets the requirement to create instances using stable logical keys rather than shifting numeric indexes. By comparison, a number variable type is intended to represent arithmetic quantities without parsing string parameters manually, which is a different task from create instances using stable logical keys rather than shifting numeric indexes.

Incorrect Answers

A:

tuple([string, number]) enforces a position-specific sequence with different type constraints; this mechanism is useful when the job is to require a fixed sequence of potentially different element types, whereas the current scenario requires the engineer to create instances using stable logical keys rather than shifting numeric indexes. These operations have different effects in the stated Terraform workflow.

C:

The any constraint is a placeholder for any compatible concrete type; explicit types generally provide better module contracts; this mechanism is useful when the job is to accept values without imposing a specific static input shape, whereas the current scenario requires the engineer to create instances using stable logical keys rather than shifting numeric indexes. These operations have different effects in the stated Terraform workflow.

D:

The number type supports numerical operations and validation such as comparisons or addition; this mechanism is useful when the job is to represent arithmetic quantities without parsing string parameters manually, whereas the current scenario requires the engineer to create instances using stable logical keys rather than shifting numeric indexes. These operations have different effects in the stated Terraform workflow.

Question 319

A change-control meeting for a root module requires a way to modify and re-plan after a change request is rejected. Which Terraform approach most directly fulfills that request?

  1. Review a plan before apply
  2. Iterate after feedback
  3. Check infrastructure after apply
  4. Write configuration first

Explanation

Correct Answer

B:

A revised configuration must be planned again because a prior plan does not automatically incorporate later edits; this directly meets the requirement to modify and re-plan after a change request is rejected. By comparison, write configuration first is intended to express the intended infrastructure before asking Terraform for a plan, which is a different task from modify and re-plan after a change request is rejected.

Incorrect Answers

A:

The plan stage compares desired configuration with observed resource state and shows the proposed operations for review; this mechanism is useful when the job is to inspect predicted create, update and delete actions prior to making changes, whereas the current scenario requires the engineer to modify and re-plan after a change request is rejected. These operations have different effects in the stated Terraform workflow.

C:

Following apply, output values and state inspection can reveal created identifiers while a new plan can test for remaining drift; this mechanism is useful when the job is to confirm deployed outputs and state match the expected result, whereas the current scenario requires the engineer to modify and re-plan after a change request is rejected. These operations have different effects in the stated Terraform workflow.

D:

The workflow begins by declaring resources, inputs and dependencies that describe what Terraform should manage; this mechanism is useful when the job is to express the intended infrastructure before asking Terraform for a plan, whereas the current scenario requires the engineer to modify and re-plan after a change request is rejected. These operations have different effects in the stated Terraform workflow.

Question 320

A Terraform change proposal names “A write-only resource argument” to pass a secret to a resource without persisting that argument's value. Which outcome can reviewers attribute to that particular mechanism?

  1. Saved plan files may contain sensitive values and must be handled as confidential artifacts rather than safe public summaries.
  2. Vault's dynamic credentials can provide expiring access with centrally enforced policies instead of permanent embedded keys.
  3. A sensitive output is redacted in regular presentation, while JSON or raw output modes may reveal its value.
  4. Provider-defined write-only arguments introduced in Terraform 1.11 are available only when the resource schema supports them.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to pass a secret to a resource without persisting that argument's value, so it produces the behavior described. In contrast, sensitive = true on an output serves a different goal: prevent a private output from appearing in normal human-readable CLI output, not pass a secret to a resource without persisting that argument's value.

Incorrect Answers

A:

The description applies to preventing credential leaks in plans when an engineer needs to avoid sharing a plan artifact publicly just because console values appear redacted; the named a write-only resource argument instead handles the requirement to pass a secret to a resource without persisting that argument's value, so this behavior does not describe A write-only resource argument in the situation named.

B:

The description applies to vault short-lived credentials when an engineer needs to limit the lifetime and scope of identities used by infrastructure automation; the named a write-only resource argument instead handles the requirement to pass a secret to a resource without persisting that argument's value, so this behavior does not describe A write-only resource argument in the situation named.

C:

The description applies to sensitive = true on an output when an engineer needs to prevent a private output from appearing in normal human-readable CLI output; the named a write-only resource argument instead handles the requirement to pass a secret to a resource without persisting that argument's value, so this behavior does not describe A write-only resource argument in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests