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

Question 1010

An engineer troubleshooting a .tf configuration needs to turn a compatible collection into a uniform-keyed map. Which feature or operation is the most direct match?

  1. tomap conversion
  2. The null value
  3. A conditional expression
  4. count with a number

Explanation

Correct Answer

A:

tomap attempts to convert an input value into a map whose values share a compatible element type; this directly meets the requirement to turn a compatible collection into a uniform-keyed map. By comparison, count with a number is intended to create a specified number of similarly configured resource instances, which is a different task from turn a compatible collection into a uniform-keyed map.

Incorrect Answers

B:

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 turn a compatible collection into a uniform-keyed map. These operations have different effects in the stated Terraform workflow.

C:

Terraform's condition ? true_value : false_value syntax chooses one branch while reconciling compatible result types; this mechanism is useful when the job is to select between two expression results based on a boolean predicate, whereas the current scenario requires the engineer to turn a compatible collection into a uniform-keyed map. These operations have different effects in the stated Terraform workflow.

D:

The count meta-argument uses an integer expression and creates zero-based numeric instance addresses; this mechanism is useful when the job is to create a specified number of similarly configured resource instances, whereas the current scenario requires the engineer to turn a compatible collection into a uniform-keyed map. These operations have different effects in the stated Terraform workflow.

Question 1011

An engineer proposes “terraform plan -out” to explain why two unrelated resources can be planned and applied in parallel. Which outcome does the proposed technique actually provide?

  1. The -replace=ADDRESS option requests replacement of a particular managed instance even if ordinary change detection would update it in place or do nothing.
  2. Terraform graph nodes can run concurrently when no dependency edge requires a particular order.
  3. Planning calculates an execution proposal after reading configuration and usually refreshing managed resource data.
  4. The -out option writes a saved plan so the reviewed actions can be supplied to terraform apply without recomputing from modified inputs.

Explanation

Correct Answer

D:

terraform plan -out is used when an operator needs to save an execution plan to a binary file for later application. Consequently, this choice cannot meet the separate requirement to explain why two unrelated resources can be planned and applied in parallel. The intended action would instead require The dependency graph during planning.

Incorrect Answers

A:

This behavior belongs to terraform plan -replace, which helps engineers force a resource instance to be replaced during planning rather than satisfying the separate requirement to explain why two unrelated resources can be planned and applied in parallel. The attempted technique was terraform plan -out; it would instead be used to save an execution plan to a binary file for later application, not to produce the effect associated with terraform plan -replace.

B:

That outcome belongs to The dependency graph during planning, the mechanism that can explain why two unrelated resources can be planned and applied in parallel. The question concerns the engineer’s actual proposal, terraform plan -out; it is directed at save an execution plan to a binary file for later application, not that result.

C:

This behavior belongs to terraform plan, which helps engineers preview resource actions implied by the current configuration and state rather than satisfying the separate requirement to explain why two unrelated resources can be planned and applied in parallel. The attempted technique was terraform plan -out; it would instead be used to save an execution plan to a binary file for later application, not to produce the effect associated with terraform plan.

Question 1012

A change request asks an engineer to make a CI formatting gate detect source files that need formatting. Which choice best implements the requested behavior?

  1. Canonical HCL alignment
  2. terraform fmt -check
  3. terraform fmt -diff
  4. Formatting versus validation

Explanation

Correct Answer

B:

Check mode verifies formatting and returns a failure when changes would be required instead of writing edited files; this directly meets the requirement to make a CI formatting gate detect source files that need formatting. By comparison, canonical HCL alignment is intended to keep spacing and indentation consistent between developers, which is a different task from make a CI formatting gate detect source files that need formatting.

Incorrect Answers

A:

The fmt operation normalizes the presentation of configuration source, not the meaning of provider API calls; this mechanism is useful when the job is to keep spacing and indentation consistent between developers, whereas the current scenario requires the engineer to make a CI formatting gate detect source files that need formatting. These operations have different effects in the stated Terraform workflow.

C:

The diff switch displays textual differences between current file formatting and the canonical formatting result; this mechanism is useful when the job is to show which HCL formatting edits Terraform would make, whereas the current scenario requires the engineer to make a CI formatting gate detect source files that need formatting. These operations have different effects in the stated Terraform workflow.

D:

terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable; this concerns the task to distinguish style-only issues from Terraform type and schema errors, not the current need to make a CI formatting gate detect source files that need formatting. A terraform fmt -check approach is appropriate here; the substituted Formatting versus validation option does not supply the specified Terraform capability.

Question 1013

An engineer proposes “A local value confined to its module” to instantiate the same module with distinct environment inputs. Which outcome does the proposed technique actually provide?

  1. Each call has its own variable assignments and resource instances, even when both calls reference the same module source directory.
  2. Root variables accept runtime assignments, whereas a child module normally receives its inputs through the parent's module call.
  3. A child module may validate its input variables using conditions and errors independent of the parent's variable definitions.
  4. Locals live within the module where defined and cannot be referenced from another module without passing or exposing a value.

Explanation

Correct Answer

D:

A local value confined to its module is used when an operator needs to avoid assuming a local calculation is automatically visible in a parent module. Consequently, this choice cannot meet the separate requirement to instantiate the same module with distinct environment inputs. The intended action would instead require Different values for two module calls.

Incorrect Answers

A:

That outcome belongs to Different values for two module calls, the mechanism that can instantiate the same module with distinct environment inputs. The question concerns the engineer’s actual proposal, A local value confined to its module; it is directed at avoid assuming a local calculation is automatically visible in a parent module, not that result.

B:

This behavior belongs to Root input variable scope, which helps engineers read command-line and tfvars input values for the root module rather than satisfying the separate requirement to instantiate the same module with distinct environment inputs. The attempted technique was A local value confined to its module; it would instead be used to avoid assuming a local calculation is automatically visible in a parent module, not to produce the effect associated with Root input variable scope.

C:

This behavior belongs to Variable validation inside a module, which helps engineers enforce a reusable module's own input contract rather than satisfying the separate requirement to instantiate the same module with distinct environment inputs. The attempted technique was A local value confined to its module; it would instead be used to avoid assuming a local calculation is automatically visible in a parent module, not to produce the effect associated with Variable validation inside a module.

Question 1014

A Terraform change proposal names “terraform force-unlock” to release a stale lock when the original process is definitively gone. Which outcome can reviewers attribute to that particular mechanism?

  1. Terraform uses lock information to distinguish a specific operation's lock from unrelated lock holders.
  2. The -lock=false option bypasses locking safeguards and increases the risk of two runs writing inconsistent state.
  3. Supported backends acquire a state lock so simultaneous writers cannot corrupt or overwrite each other's state changes.
  4. The force-unlock command removes a lock by its identifier; using it during an active operation can cause state corruption.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to release a stale lock when the original process is definitively gone, so it produces the behavior described. In contrast, a backend state lock serves a different goal: serialize operations that write the same Terraform state, not release a stale lock when the original process is definitively gone.

Incorrect Answers

A:

The description applies to a lock identifier when an engineer needs to ensure a force-unlock targets the correct held state lock; the named terraform force-unlock instead handles the requirement to release a stale lock when the original process is definitively gone, so this behavior does not describe terraform force-unlock in the situation named.

B:

The description applies to not disabling locking for speed when an engineer needs to avoid conflicting state updates during concurrent deployments; the named terraform force-unlock instead handles the requirement to release a stale lock when the original process is definitively gone, so this behavior does not describe terraform force-unlock in the situation named.

C:

The description applies to a backend state lock when an engineer needs to serialize operations that write the same Terraform state; the named terraform force-unlock instead handles the requirement to release a stale lock when the original process is definitively gone, so this behavior does not describe terraform force-unlock in the situation named.

Question 1015

A runbook lists “State-backed object tracking” for the task to retain the association between a configuration address and its actual managed object. Which technical effect should its description include?

  1. Terraform derives dependency edges from references, using the graph to order dependent changes and permit safe parallel operations.
  2. Terraform state records mappings and attributes needed to compare future plans without rediscovering every object's identity from scratch.
  3. Infrastructure configuration can be committed and reviewed in version control so the intended change is traceable before a Terraform run.
  4. Terraform reads .tf files written in HCL, including blocks, arguments, expressions and references that describe the intended objects.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to retain the association between a configuration address and its actual managed object, so it produces the behavior described. In contrast, a resource graph serves a different goal: determine a safe sequence for creating objects with references between them, not retain the association between a configuration address and its actual managed object.

Incorrect Answers

A:

The description applies to a resource graph when an engineer needs to determine a safe sequence for creating objects with references between them; the named state-backed object tracking instead handles the requirement to retain the association between a configuration address and its actual managed object, so this behavior does not describe State-backed object tracking in the situation named.

C:

The description applies to version-controlled infrastructure definition when an engineer needs to review a proposed infrastructure change before team members deploy it; the named state-backed object tracking instead handles the requirement to retain the association between a configuration address and its actual managed object, so this behavior does not describe State-backed object tracking in the situation named.

D:

The statement describes HCL configuration files, which is appropriate when engineers need to represent managed infrastructure using Terraform's native declarative language; it does not explain State-backed object tracking, the construct used to retain the association between a configuration address and its actual managed object. The two behaviors are separate.

Question 1016

A configuration review for an application stack has a concrete implementation goal: limit a feature toggle to true or false values. What is the most appropriate Terraform mechanism?

  1. A conditional expression
  2. toset conversion
  3. A bool variable type
  4. The null value

Explanation

Correct Answer

C:

The bool primitive type represents logical truth values used in conditionals and comparisons; this directly meets the requirement to limit a feature toggle to true or false values. By comparison, toset conversion is intended to deduplicate a collection of string identifiers for keyed iteration, which is a different task from limit a feature toggle to true or false values.

Incorrect Answers

A:

Terraform's condition ? true_value : false_value syntax chooses one branch while reconciling compatible result types; this mechanism is useful when the job is to select between two expression results based on a boolean predicate, whereas the current scenario requires the engineer to limit a feature toggle to true or false values. These operations have different effects in the stated Terraform workflow.

B:

toset converts a collection into a set; duplicate elements are removed and original positional ordering is not preserved; this mechanism is useful when the job is to deduplicate a collection of string identifiers for keyed iteration, whereas the current scenario requires the engineer to limit a feature toggle to true or false 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 limit a feature toggle to true or false values. These operations have different effects in the stated Terraform workflow.

Question 1017

A Terraform deployment has independent requirements: (1) distinguish style-only issues from Terraform type and schema errors; (2) prepare a newly cloned root module for local Terraform operations. Which TWO mechanisms directly address these needs? Choose TWO.

  1. Formatting versus validation
  2. Initialize after checkout
  3. Canonical HCL alignment
  4. Review a plan before apply
  5. Write configuration first

Explanation

Correct Answers

A:

terraform fmt addresses canonical HCL layout while terraform validate checks whether the configuration is structurally acceptable; this meets the requirement to distinguish style-only issues from Terraform type and schema errors, while the other selected techniques address prepare a newly cloned root module for local Terraform operations, which require their own distinct Terraform mechanisms.

B:

Running terraform init configures backend access, child modules and required providers before plans can run; this meets the requirement to prepare a newly cloned root module for local Terraform operations, while the other selected techniques address distinguish style-only issues from Terraform type and schema errors, which require their own distinct Terraform mechanisms.

Incorrect Answers

C:

The fmt operation normalizes the presentation of configuration source, not the meaning of provider API calls; it addresses keep spacing and indentation consistent between developers, but this delivery instead requires distinguish style-only issues from Terraform type and schema errors and prepare a newly cloned root module for local Terraform operations. The required combination involves Initialize after checkout and Formatting versus validation, not the behavior of Canonical HCL alignment.

D:

The plan stage compares desired configuration with observed resource state and shows the proposed operations for review; it addresses inspect predicted create, update and delete actions prior to making changes, but this delivery instead requires distinguish style-only issues from Terraform type and schema errors and prepare a newly cloned root module for local Terraform operations. The required combination involves Initialize after checkout and Formatting versus validation, not the behavior of Review a plan before apply.

E:

The workflow begins by declaring resources, inputs and dependencies that describe what Terraform should manage; it addresses express the intended infrastructure before asking Terraform for a plan, but this delivery instead requires distinguish style-only issues from Terraform type and schema errors and prepare a newly cloned root module for local Terraform operations. The required combination involves Initialize after checkout and Formatting versus validation, not the behavior of Write configuration first.

Question 1018

A platform team separating infrastructure deployments has a concrete implementation goal: identify remote infrastructure deviations through scheduled or managed health assessments. What is the most appropriate Terraform mechanism?

  1. Organization variable sets
  2. A restricted private registry
  3. Run triggers
  4. Drift detection in HCP Terraform

Explanation

Correct Answer

D:

HCP Terraform health features can detect changes made outside the workspace's managed Terraform workflow; this directly meets the requirement to identify remote infrastructure deviations through scheduled or managed health assessments. By comparison, organization variable sets is intended to supply shared environment or Terraform input values across several workspaces, which is a different task from identify remote infrastructure deviations through scheduled or managed health assessments.

Incorrect Answers

A:

Variable sets let administrators manage common workspace variables centrally and scope them to intended workspaces or projects; this mechanism is useful when the job is to supply shared environment or Terraform input values across several workspaces, whereas the current scenario requires the engineer to identify remote infrastructure deviations through scheduled or managed health assessments. These operations have different effects in the stated Terraform workflow.

B:

Registry access and publishing permissions help centralize reusable module governance across teams; this mechanism is useful when the job is to let approved teams discover modules while controlling publication rights, whereas the current scenario requires the engineer to identify remote infrastructure deviations through scheduled or managed health assessments. These operations have different effects in the stated Terraform workflow.

C:

Run triggers coordinate dependent HCP Terraform workspaces through an event relationship without merging their states; this mechanism is useful when the job is to start downstream workspace runs after upstream workspace changes complete, whereas the current scenario requires the engineer to identify remote infrastructure deviations through scheduled or managed health assessments. These operations have different effects in the stated Terraform workflow.

Question 1019

Reviewers reject “Provider-local name mapping” as a way to supply provider configurations from the root module to reusable child modules. Which actual behavior explains why the proposal is unsuitable?

  1. List both plugins under required_providers and configure each service's provider independently as needed.
  2. Reusable child modules should primarily declare provider requirements and receive configurations from callers rather than embedding fixed credentials.
  3. A data block can set provider = aws.secondary to query through an alternate provider configuration.
  4. The required_providers entry maps the chosen local name to a specific fully qualified provider source address.

Explanation

Correct Answer

D:

Provider-local name mapping is used when an operator needs to reuse a provider whose source address differs from its short local identifier. Consequently, this choice cannot meet the separate requirement to supply provider configurations from the root module to reusable child modules. The intended action would instead require Provider configuration at the root.

Incorrect Answers

A:

This behavior belongs to Separate required provider names, which helps engineers use two unrelated service APIs in one root configuration rather than satisfying the separate requirement to supply provider configurations from the root module to reusable child modules. The attempted technique was Provider-local name mapping; it would instead be used to reuse a provider whose source address differs from its short local identifier, not to produce the effect associated with Separate required provider names.

B:

That outcome belongs to Provider configuration at the root, the mechanism that can supply provider configurations from the root module to reusable child modules. The question concerns the engineer’s actual proposal, Provider-local name mapping; it is directed at reuse a provider whose source address differs from its short local identifier, not that result.

C:

This behavior belongs to Explicit provider selection on data blocks, which helps engineers read an object from a secondary account rather than the default account rather than satisfying the separate requirement to supply provider configurations from the root module to reusable child modules. The attempted technique was Provider-local name mapping; it would instead be used to reuse a provider whose source address differs from its short local identifier, not to produce the effect associated with Explicit provider selection on data blocks.

Question 1020

A Terraform reviewer encounters “terraform plan -detailed-exitcode” while assessing how to distinguish no changes from proposed changes in automation. Which statement correctly describes its actual behavior?

  1. Plans show replacement when the provider cannot update a changed property in place; create-before-destroy can change the replacement order.
  2. Detailed exit codes are 0 for no diff, 2 for a nonempty successful plan and 1 for an error.
  3. In human-readable plan diffs, ~ indicates that Terraform proposes updating existing resource attributes.
  4. Terraform may mark attributes as known after apply because a provider assigns their values only when creating or updating a real object.
  5. Disabling refresh reduces remote reads but can hide drift and produce an inaccurate plan based on stale observations.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to distinguish no changes from proposed changes in automation, so it produces the behavior described. In contrast, a resource action marked tilde serves a different goal: identify an in-place change rather than object recreation, not distinguish no changes from proposed changes in automation.

Incorrect Answers

A:

The description applies to a replacement action in the plan when an engineer needs to recognize a destroy-and-create operation for an immutable argument; the named terraform plan -detailed-exitcode instead handles the requirement to distinguish no changes from proposed changes in automation, so this behavior does not describe terraform plan -detailed-exitcode in the situation named.

C:

The description applies to a resource action marked tilde when an engineer needs to identify an in-place change rather than object recreation; the named terraform plan -detailed-exitcode instead handles the requirement to distinguish no changes from proposed changes in automation, so this behavior does not describe terraform plan -detailed-exitcode in the situation named.

D:

The description applies to an unknown value until apply when an engineer needs to understand why a computed attribute is unavailable in the preview; the named terraform plan -detailed-exitcode instead handles the requirement to distinguish no changes from proposed changes in automation, so this behavior does not describe terraform plan -detailed-exitcode in the situation named.

E:

The description applies to terraform plan -refresh=false when an engineer needs to skip routine state refresh for a constrained preview; the named terraform plan -detailed-exitcode instead handles the requirement to distinguish no changes from proposed changes in automation, so this behavior does not describe terraform plan -detailed-exitcode in the situation named.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests