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

Question 1040

During an infrastructure design review about how to inspect the addresses of instances currently tracked in state, a maintainer asks what “terraform state list” does. Which description is accurate?

  1. The state list command enumerates Terraform resource addresses without creating or deleting infrastructure.
  2. State can retain dependency information needed to correctly destroy objects no longer declared in configuration.
  3. A backend with state-locking support obtains a lock during operations that can modify state, avoiding conflicting simultaneous writes.
  4. Reading a remote state output still requires access to the underlying snapshot; exporting data through a narrower interface can reduce exposure.
  5. State may contain secret values even when CLI output is redacted, so storage encryption and access controls matter.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to inspect the addresses of instances currently tracked in state, so it produces the behavior described. In contrast, remote state sharing boundaries serves a different goal: avoid exposing full state when another stack only needs a published identifier, not inspect the addresses of instances currently tracked in state.

Incorrect Answers

B:

The description applies to state-backed dependency links when an engineer needs to maintain dependencies for resources that have been removed from configuration; the named terraform state list instead handles the requirement to inspect the addresses of instances currently tracked in state, so this behavior does not describe terraform state list in the situation named.

C:

The description applies to state locking when an engineer needs to prevent concurrent state writers from overwriting each other's updates; the named terraform state list instead handles the requirement to inspect the addresses of instances currently tracked in state, so this behavior does not describe terraform state list in the situation named.

D:

The description applies to remote state sharing boundaries when an engineer needs to avoid exposing full state when another stack only needs a published identifier; the named terraform state list instead handles the requirement to inspect the addresses of instances currently tracked in state, so this behavior does not describe terraform state list in the situation named.

E:

The description applies to state access protection when an engineer needs to treat a Terraform state file as potentially sensitive data; the named terraform state list instead handles the requirement to inspect the addresses of instances currently tracked in state, so this behavior does not describe terraform state list in the situation named.

Question 1041

A Terraform reviewer encounters “State migration from local storage” while assessing how to move an established project to remote state without abandoning resource identity. Which statement correctly describes its actual behavior?

  1. Local state can hold raw provider attributes and secrets, so filesystem access controls and encryption matter.
  2. Without another backend, Terraform uses the local backend and writes its default workspace state to terraform.tfstate.
  3. Changing the root backend and running init -migrate-state can transfer the existing snapshot to the newly configured destination.
  4. Local files do not provide an organization-wide shared state or distributed locking comparable to an appropriately configured remote backend.
  5. The default workspace's local state is kept as terraform.tfstate; this file may contain sensitive infrastructure details.

Explanation

Correct Answer

C:

The named mechanism is used when the objective is to move an established project to remote state without abandoning resource identity, so it produces the behavior described. In contrast, the local backend's lack of team collaboration features serves a different goal: avoid concurrent writes from multiple operators on different machines, not move an established project to remote state without abandoning resource identity.

Incorrect Answers

A:

The description applies to state file confidentiality when an engineer needs to protect a workstation's local state file even when output values are hidden; the named state migration from local storage instead handles the requirement to move an established project to remote state without abandoning resource identity, so this behavior does not describe State migration from local storage in the situation named.

B:

The description applies to the default local backend when an engineer needs to store Terraform state in a file in the working directory by default; the named state migration from local storage instead handles the requirement to move an established project to remote state without abandoning resource identity, so this behavior does not describe State migration from local storage in the situation named.

D:

The description applies to the local backend's lack of team collaboration features when an engineer needs to avoid concurrent writes from multiple operators on different machines; the named state migration from local storage instead handles the requirement to move an established project to remote state without abandoning resource identity, so this behavior does not describe State migration from local storage in the situation named.

E:

The description applies to the terraform.tfstate file when an engineer needs to identify Terraform's default local state artifact; the named state migration from local storage instead handles the requirement to move an established project to remote state without abandoning resource identity, so this behavior does not describe State migration from local storage in the situation named.

Question 1042

A reusable infrastructure definition requires a way to choose a blocking input constraint rather than a monitoring-style assertion. Which Terraform approach most directly fulfills that request?

  1. Data source postcondition
  2. Custom conditions with unknown values
  3. Input validation versus check blocks
  4. Preconditions for external assumptions

Explanation

Correct Answer

C:

Variable validation rejects unacceptable values, whereas failed check assertions are intended for diagnostic warnings; this directly meets the requirement to choose a blocking input constraint rather than a monitoring-style assertion. 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 choose a blocking input constraint rather than a monitoring-style assertion.

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 choose a blocking input constraint rather than a monitoring-style assertion. These operations have different effects in the stated Terraform workflow.

B:

Terraform may defer condition evaluation to apply when required expression values are unknown during planning; this mechanism is useful when the job is to understand when a validation cannot yet be decided at planning time, whereas the current scenario requires the engineer to choose a blocking input constraint rather than a monitoring-style assertion. These operations have different effects in the stated Terraform workflow.

D:

A precondition can express a domain requirement such as a selected image having an expected property before using it; this mechanism is useful when the job is to guard a resource against prerequisites outside the provider's basic schema, whereas the current scenario requires the engineer to choose a blocking input constraint rather than a monitoring-style assertion. These operations have different effects in the stated Terraform workflow.

Question 1043

A Terraform change proposal names “A module output reference” to use a network module's subnet IDs inside an application module call. Which outcome can reviewers attribute to that particular mechanism?

  1. All Terraform configuration files in a module directory are combined as one module; filenames do not define separate execution units.
  2. Module outputs provide explicit integration points between modules without relying on child resource addresses.
  3. The count meta-argument creates numerically indexed module instances such as module.worker[0].
  4. The module block's version argument can constrain registry modules and is separate from Terraform CLI and provider version settings.

Explanation

Correct Answer

B:

The named mechanism is used when the objective is to use a network module's subnet IDs inside an application module call, so it produces the behavior described. In contrast, using a module registry version serves a different goal: control which published module release a root configuration consumes, not use a network module's subnet IDs inside an application module call.

Incorrect Answers

A:

The description applies to a module root directory when an engineer needs to understand which source files Terraform loads as one module; the named a module output reference instead handles the requirement to use a network module's subnet IDs inside an application module call, so this behavior does not describe A module output reference 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 a module output reference instead handles the requirement to use a network module's subnet IDs inside an application module call, so this behavior does not describe A module output reference in the situation named.

D:

The description applies to using a module registry version when an engineer needs to control which published module release a root configuration consumes; the named a module output reference instead handles the requirement to use a network module's subnet IDs inside an application module call, so this behavior does not describe A module output reference in the situation named.

Question 1044

An output block uses the value expression length("node"). Assuming only the literal data shown, which result should be expected?

  1. 5
  2. 4
  3. 1
  4. 3

Explanation

Correct Answer

B:

The expression length("node") evaluates to 4 because the length of this string is the number of its four characters. This is Terraform's direct evaluation of the supplied literal arguments in length("node"), not an external provider lookup.

Incorrect Answers

A:

No extra delimiter or terminator is part of the Terraform string value. In this specific evaluation, the length of this string is the number of its four characters, which rules out the proposed alternative.

C:

This would count the entire string as a single collection item instead of characters. HCL evaluates length("node") using the supplied arguments: the length of this string is the number of its four characters; the listed result is therefore incorrect.

D:

The string has a final e that must also be counted. For length("node"), the length of this string is the number of its four characters; consequently this candidate is not the value Terraform computes.

Question 1045

A change request asks an engineer to skip routine state refresh for a constrained preview. Which choice best implements the requested behavior?

  1. The dependency graph during planning
  2. A resource action marked minus
  3. A resource action marked tilde
  4. terraform plan -refresh=false

Explanation

Correct Answer

D:

Disabling refresh reduces remote reads but can hide drift and produce an inaccurate plan based on stale observations; this directly meets the requirement to skip routine state refresh for a constrained preview. By comparison, the dependency graph during planning is intended to explain why two unrelated resources can be planned and applied in parallel, which is a different task from skip routine state refresh for a constrained preview.

Incorrect Answers

A:

Terraform graph nodes can run concurrently when no dependency edge requires a particular order; this mechanism is useful when the job is to explain why two unrelated resources can be planned and applied in parallel, whereas the current scenario requires the engineer to skip routine state refresh for a constrained preview. These operations have different effects in the stated Terraform workflow.

B:

In human-readable plans, - denotes a planned destruction of a managed resource; this mechanism is useful when the job is to interpret a plan showing a resource that Terraform will destroy, whereas the current scenario requires the engineer to skip routine state refresh for a constrained preview. These operations have different effects in the stated Terraform workflow.

C:

In human-readable plan diffs, ~ indicates that Terraform proposes updating existing resource attributes; this mechanism is useful when the job is to identify an in-place change rather than object recreation, whereas the current scenario requires the engineer to skip routine state refresh for a constrained preview. These operations have different effects in the stated Terraform workflow.

Question 1046

A Terraform reviewer encounters “Workspace run approvals” while assessing how to require an authorized person to approve a run before applying changes. Which statement correctly describes its actual behavior?

  1. HCP Terraform approval workflow separates viewing a plan from the permission to proceed with an apply.
  2. Sentinel policies can assess planned infrastructure and produce policy check outcomes before a run can apply when enforcement requires it.
  3. Continuous validation can evaluate configuration check blocks to identify operational health issues in supported workspaces.
  4. Registry access and publishing permissions help centralize reusable module governance across teams.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to require an authorized person to approve a run before applying changes, so it produces the behavior described. In contrast, sentinel policy enforcement serves a different goal: evaluate organizational infrastructure rules during HCP Terraform runs, not require an authorized person to approve a run before applying changes.

Incorrect Answers

B:

The description applies to sentinel policy enforcement when an engineer needs to evaluate organizational infrastructure rules during HCP Terraform runs; the named workspace run approvals instead handles the requirement to require an authorized person to approve a run before applying changes, so this behavior does not describe Workspace run approvals in the situation named.

C:

The description applies to HCP continuous validation when an engineer needs to monitor whether infrastructure-specific check assertions still pass after deployment; the named workspace run approvals instead handles the requirement to require an authorized person to approve a run before applying changes, so this behavior does not describe Workspace run approvals in the situation named.

D:

The description applies to a restricted private registry when an engineer needs to let approved teams discover modules while controlling publication rights; the named workspace run approvals instead handles the requirement to require an authorized person to approve a run before applying changes, so this behavior does not describe Workspace run approvals in the situation named.

Question 1047

An engineer intends to serialize operations that write the same Terraform state and is reviewing “A backend state lock”. What consequence follows from using it as intended?

  1. Supported backends acquire a state lock so simultaneous writers cannot corrupt or overwrite each other's state changes.
  2. Terraform obtains and releases supported backend locks around state-sensitive operations; a crash can sometimes leave manual recovery necessary.
  3. A state backend with locking helps serialize competing changes, complemented by pipeline approval and run coordination.
  4. The -lock=false option bypasses locking safeguards and increases the risk of two runs writing inconsistent state.

Explanation

Correct Answer

A:

The named mechanism is used when the objective is to serialize operations that write the same Terraform state, so it produces the behavior described. In contrast, lock release after completion serves a different goal: understand why a normal Terraform operation frees the lock, not serialize operations that write the same Terraform state.

Incorrect Answers

B:

The description applies to lock release after completion when an engineer needs to understand why a normal Terraform operation frees the lock; the named a backend state lock instead handles the requirement to serialize operations that write the same Terraform state, so this behavior does not describe A backend state lock in the situation named.

C:

The description applies to state consistency during CI when an engineer needs to keep two pipelines from changing the same infrastructure state simultaneously; the named a backend state lock instead handles the requirement to serialize operations that write the same Terraform state, so this behavior does not describe A backend state lock in the situation named.

D:

The description applies to not disabling locking for speed when an engineer needs to avoid conflicting state updates during concurrent deployments; the named a backend state lock instead handles the requirement to serialize operations that write the same Terraform state, so this behavior does not describe A backend state lock in the situation named.

Question 1048

A Terraform change proposal names “terraform apply -destroy” to execute a destroy-mode apply within a controlled workflow. Which outcome can reviewers attribute to that particular mechanism?

  1. Providers and remote APIs can reject deletion when dependencies, protection flags or permissions prevent removing the object.
  2. The lifecycle prevent_destroy setting rejects a plan that destroys or replaces a configured resource while the rule remains present.
  3. Reviewing a destroy plan is essential because a command can remove every managed instance within the relevant state scope.
  4. The destroy mode tells apply to plan removal of managed resources rather than ordinary convergence to resource declarations.

Explanation

Correct Answer

D:

The named mechanism is used when the objective is to execute a destroy-mode apply within a controlled workflow, so it produces the behavior described. In contrast, destroy plan risk review serves a different goal: identify which root-module-managed resources will be affected before a cleanup, not execute a destroy-mode apply within a controlled workflow.

Incorrect Answers

A:

The description applies to resource-specific delete restrictions when an engineer needs to diagnose why destroy fails despite valid Terraform syntax; the named terraform apply -destroy instead handles the requirement to execute a destroy-mode apply within a controlled workflow, so this behavior does not describe terraform apply -destroy in the situation named.

B:

The description applies to an explicit prevent_destroy rule when an engineer needs to block a destructive plan for a protected configured resource; the named terraform apply -destroy instead handles the requirement to execute a destroy-mode apply within a controlled workflow, so this behavior does not describe terraform apply -destroy in the situation named.

C:

The description applies to destroy plan risk review when an engineer needs to identify which root-module-managed resources will be affected before a cleanup; the named terraform apply -destroy instead handles the requirement to execute a destroy-mode apply within a controlled workflow, so this behavior does not describe terraform apply -destroy in the situation named.

Question 1049

A diagnostic incident during Terraform execution requires a way to return a shell session to ordinary Terraform logging after investigation. Which Terraform approach most directly fulfills that request?

  1. TF_LOG=DEBUG
  2. Disabling TF_LOG
  3. TF_LOG=INFO
  4. Redacting shared diagnostic logs

Explanation

Correct Answer

B:

Unsetting or disabling Terraform's TF_LOG environment setting removes extra diagnostic verbosity from later commands; this directly meets the requirement to return a shell session to ordinary Terraform logging after investigation. By comparison, TF_LOG=DEBUG is intended to enable diagnostic output with lower verbosity than TRACE, which is a different task from return a shell session to ordinary Terraform logging after investigation.

Incorrect Answers

A:

Setting TF_LOG to DEBUG exposes useful troubleshooting messages without the full trace-level volume; this mechanism is useful when the job is to enable diagnostic output with lower verbosity than TRACE, whereas the current scenario requires the engineer to return a shell session to ordinary Terraform logging after investigation. These operations have different effects in the stated Terraform workflow.

C:

INFO logging provides operational context with less detail than DEBUG and TRACE; this mechanism is useful when the job is to record higher-level operational messages during troubleshooting, whereas the current scenario requires the engineer to return a shell session to ordinary Terraform logging after investigation. These operations have different effects in the stated Terraform workflow.

D:

Terraform diagnostic logs can include sensitive data, so access control and careful review are required before sharing them; this mechanism is useful when the job is to prevent troubleshooting output from leaking credentials or resource attributes, whereas the current scenario requires the engineer to return a shell session to ordinary Terraform logging after investigation. These operations have different effects in the stated Terraform workflow.

Question 1050

During a design review, the requirement is to avoid unintended changes immediately after importing a remote object. Which option should the engineer select?

  1. An import configuration review
  2. The import block
  3. Provider permissions during import
  4. A matching resource declaration

Explanation

Correct Answer

D:

Imported infrastructure should have a corresponding resource block with configuration matching the desired attributes so the next plan is safe; this directly meets the requirement to avoid unintended changes immediately after importing a remote object. By comparison, an import configuration review is intended to correct provider-generated HCL rather than trusting every inferred argument, which is a different task from avoid unintended changes immediately after importing a remote object.

Incorrect Answers

A:

Generated resource declarations are a starting point and can include computed or unsuitable attributes requiring manual cleanup; this mechanism is useful when the job is to correct provider-generated HCL rather than trusting every inferred argument, whereas the current scenario requires the engineer to avoid unintended changes immediately after importing a remote object. These operations have different effects in the stated Terraform workflow.

B:

A top-level import block identifies a target resource address and import identity so the operation participates in plan and apply; this mechanism is useful when the job is to declare a managed import operation in configuration for planning and applying, whereas the current scenario requires the engineer to avoid unintended changes immediately after importing a remote object. These operations have different effects in the stated Terraform workflow.

C:

Import needs correct provider authentication and sufficient access to query the target resource using its provider-defined import ID; this mechanism is useful when the job is to read an existing cloud object so Terraform can associate it with state, whereas the current scenario requires the engineer to avoid unintended changes immediately after importing a remote object. These operations have different effects in the stated Terraform workflow.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests