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

Question 950

The team evaluates “A tuple type” for a requirement to require a fixed sequence of potentially different element types. Which observed behavior belongs to that mechanism rather than a different Terraform feature?

  1. tolist converts compatible values to a list, but a source set's original order is not inherently meaningful.
  2. A resource's for_each meta-argument accepts maps or sets of strings; map keys appear in resource addresses.
  3. toset converts a collection into a set; duplicate elements are removed and original positional ordering is not preserved.
  4. tuple([string, number]) enforces a position-specific sequence with different type constraints.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to require a fixed sequence of potentially different element types, so it produces the behavior described. In contrast, tolist conversion serves a different goal: coerce a suitable collection into a list for ordered operations, not require a fixed sequence of potentially different element types.

Incorrect Answers

A:

The description applies to tolist conversion when an engineer needs to coerce a suitable collection into a list for ordered operations; the named a tuple type instead handles the requirement to require a fixed sequence of potentially different element types, so this behavior does not describe A tuple type in the situation named.

B:

The description applies to for_each with a map when an engineer needs to create instances using stable logical keys rather than shifting numeric indexes; the named a tuple type instead handles the requirement to require a fixed sequence of potentially different element types, so this behavior does not describe A tuple type in the situation named.

C:

The description applies to toset conversion when an engineer needs to deduplicate a collection of string identifiers for keyed iteration; the named a tuple type instead handles the requirement to require a fixed sequence of potentially different element types, so this behavior does not describe A tuple type in the situation named.

Question 951

During a design review, the requirement is to upload local configuration for execution through HCP Terraform rather than relying on Git webhooks. Which option should the engineer select?

  1. A speculative HCP plan
  2. A CLI-driven workspace
  3. Workspace outputs
  4. A VCS-connected workspace

Explanation

Correct Answer

B:

A CLI workflow can send configuration from the Terraform CLI to HCP Terraform for workspace runs; this directly meets the requirement to upload local configuration for execution through HCP Terraform rather than relying on Git webhooks. By comparison, a VCS-connected workspace is intended to trigger infrastructure runs from changes in a configured version-control repository, which is a different task from upload local configuration for execution through HCP Terraform rather than relying on Git webhooks.

Incorrect Answers

A:

HCP Terraform can perform speculative plans for VCS changes to preview impact before merge or approval; this mechanism is useful when the job is to evaluate a pull request's proposed changes without immediately applying them, whereas the current scenario requires the engineer to upload local configuration for execution through HCP Terraform rather than relying on Git webhooks. These operations have different effects in the stated Terraform workflow.

C:

Workspace output values come from root module output blocks and can be consumed through supported interfaces; this mechanism is useful when the job is to publish selected values produced by an HCP Terraform run, whereas the current scenario requires the engineer to upload local configuration for execution through HCP Terraform rather than relying on Git webhooks. These operations have different effects in the stated Terraform workflow.

D:

HCP Terraform can connect a workspace to a VCS repository and create runs when relevant commits are pushed; this mechanism is useful when the job is to trigger infrastructure runs from changes in a configured version-control repository, whereas the current scenario requires the engineer to upload local configuration for execution through HCP Terraform rather than relying on Git webhooks. These operations have different effects in the stated Terraform workflow.

Question 952

A runbook lists “Explicit depends_on” for the task to order resources when there is a dependency not expressed by attribute references. Which technical effect should its description include?

  1. The depends_on meta-argument adds dependency edges for a known relationship that Terraform cannot otherwise infer.
  2. In a for_each resource block, each.key identifies the current map key or set element for that instance.
  3. A resource address inside a module ordinarily uses TYPE.NAME, with optional instance indexing when count or for_each is used.
  4. The syntax data.TYPE.NAME.ATTRIBUTE accesses attributes returned by an existing-object query.

Explanation

Correct Answer

A:

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

Incorrect Answers

B:

The description applies to each.key when an engineer needs to refer to the stable key of a for_each resource instance; the named explicit depends_on instead handles the requirement to order resources when there is a dependency not expressed by attribute references, so this behavior does not describe Explicit depends_on in the situation named.

C:

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

D:

The description applies to a data attribute reference when an engineer needs to read a field from a configured data source in another expression; the named explicit depends_on instead handles the requirement to order resources when there is a dependency not expressed by attribute references, so this behavior does not describe Explicit depends_on in the situation named.

Question 953

A Terraform module author has a concrete implementation goal: associate arbitrary string keys with string values. What is the most appropriate Terraform mechanism?

  1. tomap conversion
  2. An unknown plan-time value
  3. A map of strings type
  4. The null value

Explanation

Correct Answer

C:

The map(string) type models uniform values accessed by key rather than by positional index; this directly meets the requirement to associate arbitrary string keys with string values. By comparison, tomap conversion is intended to turn a compatible collection into a uniform-keyed map, which is a different task from associate arbitrary string keys with string values.

Incorrect Answers

A:

tomap attempts to convert an input value into a map whose values share a compatible element type; this mechanism is useful when the job is to turn a compatible collection into a uniform-keyed map, whereas the current scenario requires the engineer to associate arbitrary string keys with string values. These operations have different effects in the stated Terraform workflow.

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 associate arbitrary string keys with string values. These operations have different effects in the stated Terraform workflow.

D:

In supported contexts, setting an optional resource argument to null behaves like leaving that argument unset; this mechanism is useful when the job is to represent the absence of an optional argument value, whereas the current scenario requires the engineer to associate arbitrary string keys with string values. These operations have different effects in the stated Terraform workflow.

Question 954

An HCP Terraform workspace design requires a way to consume a module managed by the organization's HCP private registry. Which Terraform approach most directly fulfills that request?

  1. terraform init after adding cloud integration
  2. An HCP private registry module source
  3. Terraform Enterprise hostname selection
  4. Mutual exclusivity of cloud and backend

Explanation

Correct Answer

B:

A module source can reference a private registry hostname and namespace after the client has appropriate authentication; this directly meets the requirement to consume a module managed by the organization's HCP private registry. By comparison, Terraform Enterprise hostname selection is intended to connect the CLI to a privately deployed Terraform Enterprise service rather than app.terraform.io, which is a different task from consume a module managed by the organization's HCP private registry.

Incorrect Answers

A:

Running init processes the cloud block and configures workspace connectivity before plans or applies; this mechanism is useful when the job is to configure the local working directory to connect with the selected HCP workspace, whereas the current scenario requires the engineer to consume a module managed by the organization's HCP private registry. These operations have different effects in the stated Terraform workflow.

C:

The cloud hostname setting and login host identify the relevant service installation for organization operations; this mechanism is useful when the job is to connect the CLI to a privately deployed Terraform Enterprise service rather than app.terraform.io, whereas the current scenario requires the engineer to consume a module managed by the organization's HCP private registry. These operations have different effects in the stated Terraform workflow.

D:

Terraform does not allow simultaneous cloud and backend blocks because both would compete to control the state and execution connection; this mechanism is useful when the job is to avoid declaring both HCP cloud integration and a standard backend in the same root module, whereas the current scenario requires the engineer to consume a module managed by the organization's HCP private registry. These operations have different effects in the stated Terraform workflow.

Question 955

A Terraform reviewer encounters “A Git HTTPS module source” while assessing how to fetch module code directly from a remote Git repository. Which statement correctly describes its actual behavior?

  1. Registry module sources use the namespace/name/provider address form and can support a separate version argument.
  2. Initialization retrieves module sources and populates .terraform/modules while preparing other required dependencies.
  3. The terraform get command updates downloaded module sources only; routine workflows generally prefer terraform init.
  4. A git::https:// source can retrieve a Terraform module from version control rather than from the module registry.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to fetch module code directly from a remote Git repository, so it produces the behavior described. In contrast, terraform get serves a different goal: retrieve child modules without running the complete backend and provider setup steps, not fetch module code directly from a remote Git repository.

Incorrect Answers

A:

The description applies to a public registry module source when an engineer needs to download a community module published with an official registry address; the named a Git HTTPS module source instead handles the requirement to fetch module code directly from a remote Git repository, so this behavior does not describe A Git HTTPS module source in the situation named.

B:

The description applies to terraform init for modules when an engineer needs to install all referenced remote child modules before planning; the named a Git HTTPS module source instead handles the requirement to fetch module code directly from a remote Git repository, so this behavior does not describe A Git HTTPS module source in the situation named.

C:

The description applies to terraform get when an engineer needs to retrieve child modules without running the complete backend and provider setup steps; the named a Git HTTPS module source instead handles the requirement to fetch module code directly from a remote Git repository, so this behavior does not describe A Git HTTPS module source in the situation named.

Question 956

An engineer intends to count elements in a collection or characters in a string and is reviewing “The length function”. What consequence follows from using it as intended?

  1. file reads existing local text; it does not wait for a provisioner to create the file during apply.
  2. templatefile reads a template and evaluates placeholders using the supplied variable map.
  3. cidrsubnet derives a subnet CIDR using additional prefix bits and a network number, without provisioning a network resource.
  4. length returns the collection size or string character count; it does not find an element's index.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to count elements in a collection or characters in a string, so it produces the behavior described. In contrast, the templatefile function serves a different goal: render a file containing template expressions with an object of variables, not count elements in a collection or characters in a string.

Incorrect Answers

A:

The description applies to the file function when an engineer needs to read UTF-8 content already present in a local file during evaluation; the named the length function instead handles the requirement to count elements in a collection or characters in a string, so this behavior does not describe The length function in the situation named.

B:

The description applies to the templatefile function when an engineer needs to render a file containing template expressions with an object of variables; the named the length function instead handles the requirement to count elements in a collection or characters in a string, so this behavior does not describe The length function in the situation named.

C:

The description applies to the cidrsubnet function when an engineer needs to calculate a nested network prefix from a parent CIDR range; the named the length function instead handles the requirement to count elements in a collection or characters in a string, so this behavior does not describe The length function in the situation named.

Question 957

An infrastructure drift investigation has a concrete implementation goal: recognize why ephemeral build agents should not rely on a machine-local state file. What is the most appropriate Terraform mechanism?

  1. Local workspace state directories
  2. The local backend's lack of team collaboration features
  3. A local state backup file
  4. Local state in CI

Explanation

Correct Answer

D:

A temporary runner may lose its filesystem after a job, so durable shared state is usually needed for repeatable team automation; this directly meets the requirement to recognize why ephemeral build agents should not rely on a machine-local state file. By comparison, local workspace state directories is intended to identify how the local backend stores nondefault workspaces, which is a different task from recognize why ephemeral build agents should not rely on a machine-local state file.

Incorrect Answers

A:

When local workspaces are used, nondefault state snapshots are placed under a terraform.tfstate.d directory structure; this mechanism is useful when the job is to identify how the local backend stores nondefault workspaces, whereas the current scenario requires the engineer to recognize why ephemeral build agents should not rely on a machine-local state file. These operations have different effects in the stated Terraform workflow.

B:

Local files do not provide an organization-wide shared state or distributed locking comparable to an appropriately configured remote backend; this mechanism is useful when the job is to avoid concurrent writes from multiple operators on different machines, whereas the current scenario requires the engineer to recognize why ephemeral build agents should not rely on a machine-local state file. These operations have different effects in the stated Terraform workflow.

C:

Terraform commonly writes backup snapshots for local state updates, but backups require the same confidentiality controls as state; this mechanism is useful when the job is to recover from a state change without relying solely on an unversioned primary file, whereas the current scenario requires the engineer to recognize why ephemeral build agents should not rely on a machine-local state file. These operations have different effects in the stated Terraform workflow.

Question 958

A team consuming shared Terraform modules needs to control behavioral changes after moving to a new module release. Which feature or operation is the most direct match?

  1. Reviewing module upgrade changes
  2. A Git tag pin for a module
  3. Provider and module version separation
  4. Init -upgrade for registry modules

Explanation

Correct Answer

A:

A module upgrade can change resource definitions and outputs, so the consumer should inspect the new source and resulting Terraform plan; this directly meets the requirement to control behavioral changes after moving to a new module release. 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 control behavioral changes after moving to a new module release.

Incorrect Answers

B:

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 control behavioral changes after moving to a new module release. These operations have different effects in the stated Terraform workflow.

C:

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 control behavioral changes after moving to a new module release. These operations have different effects in the stated Terraform workflow.

D:

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 control behavioral changes after moving to a new module release. These operations have different effects in the stated Terraform workflow.

Question 959

During an infrastructure design review about how to disable updates to all managed resource attributes after creation, a maintainer asks what “ignore_changes = all” does. Which description is accurate?

  1. The -target option narrows an operation to selected objects and prerequisites; routine selective deployment is not its intended model.
  2. With all attributes ignored during updates, Terraform can still create and destroy the resource but does not reconcile field-level changes.
  3. The depends_on edge can relate the whole counted resource block to an upstream resource, rather than computing one edge by list position.
  4. A module block can declare depends_on so all managed objects inside it observe the specified dependency relationship.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to disable updates to all managed resource attributes after creation, so it produces the behavior described. In contrast, count and depends_on together serves a different goal: make multiple resource instances wait for a shared prerequisite, not disable updates to all managed resource attributes after creation.

Incorrect Answers

A:

The description applies to resource targeting as an exception when an engineer needs to repair an isolated broken dependency while acknowledging incomplete plan coverage; the named ignore_changes = all instead handles the requirement to disable updates to all managed resource attributes after creation, so this behavior does not describe ignore_changes = all in the situation named.

C:

The description applies to count and depends_on together when an engineer needs to make multiple resource instances wait for a shared prerequisite; the named ignore_changes = all instead handles the requirement to disable updates to all managed resource attributes after creation, so this behavior does not describe ignore_changes = all in the situation named.

D:

The description applies to depends_on for module calls when an engineer needs to wait for prerequisite objects before considering resources in another module; the named ignore_changes = all instead handles the requirement to disable updates to all managed resource attributes after creation, so this behavior does not describe ignore_changes = all in the situation named.

Question 960

A team consuming shared Terraform modules requires a way to download a community module published with an official registry address. Which Terraform approach most directly fulfills that request?

  1. terraform get
  2. A Git SSH module source
  3. The double-slash source subdirectory
  4. A public registry module source

Explanation

Correct Answer

D:

Registry module sources use the namespace/name/provider address form and can support a separate version argument; this directly meets the requirement to download a community module published with an official registry address. By comparison, terraform get is intended to retrieve child modules without running the complete backend and provider setup steps, which is a different task from download a community module published with an official registry address.

Incorrect Answers

A:

The terraform get command updates downloaded module sources only; routine workflows generally prefer terraform init; this mechanism is useful when the job is to retrieve child modules without running the complete backend and provider setup steps, whereas the current scenario requires the engineer to download a community module published with an official registry address. These operations have different effects in the stated Terraform workflow.

B:

A git::ssh:// module source delegates repository authentication to Git and SSH rather than a Terraform registry token; this mechanism is useful when the job is to obtain module code from a repository that requires SSH-based access, whereas the current scenario requires the engineer to download a community module published with an official registry address. These operations have different effects in the stated Terraform workflow.

C:

Module source syntax places //subdir after the package address to select the intended directory within the downloaded package; this mechanism is useful when the job is to use a nested module stored below a repository's root directory, whereas the current scenario requires the engineer to download a community module published with an official registry address. These operations have different effects in the stated Terraform workflow.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests