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

Question 620

Two automation workers can run Terraform concurrently. The team must both avoid interrupting an active legitimate Terraform operation and clear a stale lock when the original owner is definitely inactive. Which paired choice implements those distinct goals?

  1. Recognize lock ownership metadata + Use a backend with state locking
  2. Wait for a held lock to be released + Use terraform force-unlock LOCK_ID only after verification
  3. Wait for a held lock to be released + Serialize applies in CI for a shared workspace
  4. Recognize lock acquisition occurs around state operations + Use terraform force-unlock LOCK_ID only after verification

Explanation

Correct Answer

B:

For the first criterion, a lock usually means another process is modifying the same state; waiting is safer than forcing unlock while the first run is still active; this behavior should be assessed against the concrete need to avoid interrupting an active legitimate Terraform operation and clear a stale lock when the original owner is definitely inactive; this directly addresses the need to avoid interrupting an active legitimate Terraform operation. For the separate second criterion, force-unlock bypasses normal safeguards and can permit conflicting state writes; the lock ID helps ensure the intended lock is targeted; this behavior should be assessed against the concrete need to avoid interrupting an active legitimate Terraform operation and clear a stale lock when the original owner is definitely inactive; this fulfills the need to clear a stale lock when the original owner is definitely inactive. Together they cover the independent tasks of avoid interrupting an active legitimate Terraform operation and clear a stale lock when the original owner is definitely inactive without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure is intended to diagnose whether another run or process holds a state lock: Lock reports can include identifying information about the holder and operation; investigate the legitimate owner before overriding anything; this behavior should be assessed against the concrete need to avoid interrupting an active legitimate Terraform operation and clear a stale lock when the original owner is definitely inactive. The second measure is intended to prevent simultaneous runs from overwriting shared state: Backends that support locking serialize state-changing operations; this guards consistency but does not replace change approval; this behavior should be assessed against the concrete need to avoid interrupting an active legitimate Terraform operation and clear a stale lock when the original owner is definitely inactive. Neither is the directly designated method for the separate goals of avoid interrupting an active legitimate Terraform operation and clear a stale lock when the original owner is definitely inactive in this review.

C:

The first measure meets the requirement to avoid interrupting an active legitimate Terraform operation, but its partner serves a different role: Pipeline serialization reduces contention and conflicting approval assumptions; backend locking is an additional integrity layer rather than a full deployment scheduler; this behavior should be assessed against the concrete need to avoid interrupting an active legitimate Terraform operation and clear a stale lock when the original owner is definitely inactive. That second component is designed to avoid overlapping infrastructure modifications even when locks exist, so the still-missing criterion is to clear a stale lock when the original owner is definitely inactive, while the first criterion remains avoid interrupting an active legitimate Terraform operation.

D:

The second measure does meet the clear a stale lock when the original owner is definitely inactive requirement, but the first is designed for another concern: Terraform may need to lock state for a safe plan or apply; a lock error is not itself an API authentication or HCL syntax error; this behavior should be assessed against the concrete need to avoid interrupting an active legitimate Terraform operation and clear a stale lock when the original owner is definitely inactive. That first component is designed to understand why a run can fail before any resource creation, which does not accomplish the requested task to avoid interrupting an active legitimate Terraform operation, even though the other measure satisfies clear a stale lock when the original owner is definitely inactive.

Question 621

A platform team is configuring remote state securely. The requirement is to initialize the configured state location before normal operations. Which Terraform mechanism directly meets this requirement?

  1. Use terraform init -migrate-state for a backend switch
  2. Use a backend with versioned object storage when possible
  3. Run terraform init after declaring a backend
  4. Use backend migration instead of copying arbitrary JSON

Explanation

Correct Answer

C:

Backend initialization validates configuration and can prompt to migrate existing state; declaring the block alone does not upload the prior snapshot; this behavior should be assessed against the concrete need to initialize the configured state location before normal operations. This directly supports the task to initialize the configured state location before normal operations during an automated release.

Incorrect Answers

A:

Migration helps preserve object bindings when changing backends; backup and verify the source state first because the operation affects management continuity; this behavior should be assessed against the concrete need to initialize the configured state location before normal operations. The stated requirement is to initialize the configured state location before normal operations, not to copy existing state to the new location during reinitialization; this alternative addresses a different control or phase.

B:

Storage-side version history can assist state recovery after mistakes; it does not automatically repair corrupt resource bindings or provider permissions; this behavior should be assessed against the concrete need to initialize the configured state location before normal operations. That can be useful when the aim is to retain recoverable previous snapshots for disaster response, but it does not directly deliver the requested ability to initialize the configured state location before normal operations.

D:

Terraform's migration workflow handles state snapshots and workspace considerations; manual files copied to the wrong state key can cause unexpected destructive plans; this behavior should be assessed against the concrete need to initialize the configured state location before normal operations. It may support a related workflow, but the question specifically requires the mechanism for initialize the configured state location before normal operations rather than preserve state metadata while switching storage.

Question 622

An infrastructure team is choosing safe state-refactoring and drift actions. A reviewer must determine how to enumerate the tracked resource addresses in the selected state. Which action is the appropriate choice?

  1. Compare stored state with a freshly evaluated plan
  2. Use an import block to adopt a preexisting object
  3. Use terraform state pull for an administrative snapshot
  4. Use terraform state rm to forget an object
  5. Use terraform state list to inspect bindings

Explanation

Correct Answer

E:

The command reports addresses, not a complete catalog of provider-side objects; unmanaged objects will not appear; this behavior should be assessed against the concrete need to enumerate the tracked resource addresses in the selected state. This directly supports the task to enumerate the tracked resource addresses in the selected state during a staged rollout.

Incorrect Answers

A:

State holds a previous observation rather than live inventory; a new normal plan asks the provider for current properties and can expose drift that a static state inspection alone would miss; this behavior should be assessed against the concrete need to enumerate the tracked resource addresses in the selected state. It may support a related workflow, but the question specifically requires the mechanism for enumerate the tracked resource addresses in the selected state rather than identify whether old recorded values still reflect remote reality after out-of-band changes.

B:

Import maps a remote ID to resource configuration; it does not automatically create the imported infrastructure from scratch; this behavior should be assessed against the concrete need to enumerate the tracked resource addresses in the selected state. The stated requirement is to enumerate the tracked resource addresses in the selected state, not to add an unmanaged object into the current state under a declared address; this alternative addresses a different control or phase.

C:

Pull emits the full state, potentially including secrets; it should not be treated as a public debugging log; this behavior should be assessed against the concrete need to enumerate the tracked resource addresses in the selected state. That can be useful when the aim is to download a copy of the current backend state for protected inspection, but it does not directly deliver the requested ability to enumerate the tracked resource addresses in the selected state.

D:

The command removes an address from state; the remote object remains, but a still-present resource block may plan a new object later; this behavior should be assessed against the concrete need to enumerate the tracked resource addresses in the selected state. The distinction matters here: using that mechanism to stop managing a specific binding without deleting the infrastructure would still leave the objective to enumerate the tracked resource addresses in the selected state unmet.

Question 623

A developer is using local Terraform state on a workstation. The team must both store state in a local filesystem file without configuring a remote backend and avoid exposing sensitive resource attributes in repository history. Which paired choice implements those distinct goals?

  1. Use the default local backend + Keep local state out of Git
  2. Use the default local backend + Protect local workstation backups
  3. Avoid deleting state to repair an ordinary HCL error + Keep local state out of Git
  4. Use a remote backend for collaborative state + Recognize terraform.tfstate.backup

Explanation

Correct Answer

A:

For the first criterion, by default Terraform writes state in the working directory, typically terraform.tfstate; local storage does not supply shared team coordination; this behavior should be assessed against the concrete need to store state in a local filesystem file without configuring a remote backend and avoid exposing sensitive resource attributes in repository history; this directly addresses the need to store state in a local filesystem file without configuring a remote backend. For the separate second criterion, state can contain secrets even if outputs are redacted; a version-control checkout is not a secure state database or concurrency mechanism; this behavior should be assessed against the concrete need to store state in a local filesystem file without configuring a remote backend and avoid exposing sensitive resource attributes in repository history; this fulfills the need to avoid exposing sensitive resource attributes in repository history. Together they cover the independent tasks of store state in a local filesystem file without configuring a remote backend and avoid exposing sensitive resource attributes in repository history without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure meets the requirement to store state in a local filesystem file without configuring a remote backend, but its partner serves a different role: Copies of state and plan files can expose provider-returned secrets; encrypting disks and limiting file access remain important even for demonstration environments; this behavior should be assessed against the concrete need to store state in a local filesystem file without configuring a remote backend and avoid exposing sensitive resource attributes in repository history. That second component is designed to include state confidentiality in developer-machine security, so the still-missing criterion is to avoid exposing sensitive resource attributes in repository history, while the first criterion remains store state in a local filesystem file without configuring a remote backend.

C:

The second measure does meet the avoid exposing sensitive resource attributes in repository history requirement, but the first is designed for another concern: Removing state does not delete remote objects, but it removes their managed mappings; a later plan may attempt duplicate creation rather than fixing source syntax; this behavior should be assessed against the concrete need to store state in a local filesystem file without configuring a remote backend and avoid exposing sensitive resource attributes in repository history. That first component is designed to prevent Terraform from losing track of existing objects, which does not accomplish the requested task to store state in a local filesystem file without configuring a remote backend, even though the other measure satisfies avoid exposing sensitive resource attributes in repository history.

D:

The first measure is intended to share one authoritative object mapping across team members: Remote state centralizes updates and often supports distributed locking; this reduces the risk of divergent local state files; this behavior should be assessed against the concrete need to store state in a local filesystem file without configuring a remote backend and avoid exposing sensitive resource attributes in repository history. The second measure is intended to understand a local backup snapshot that may contain sensitive information: Terraform can write a previous state snapshot as a backup during updates; this file is not a replacement for deliberate disaster recovery planning; this behavior should be assessed against the concrete need to store state in a local filesystem file without configuring a remote backend and avoid exposing sensitive resource attributes in repository history. Neither is the directly designated method for the separate goals of store state in a local filesystem file without configuring a remote backend and avoid exposing sensitive resource attributes in repository history in this review.

Question 624

A team needs to understand lock contention. The requirement is to avoid overlapping infrastructure modifications even when locks exist. Which Terraform mechanism directly meets this requirement?

  1. Avoid -lock=false for shared production state
  2. Serialize applies in CI for a shared workspace
  3. Use terraform force-unlock LOCK_ID only after verification
  4. Recognize lock ownership metadata

Explanation

Correct Answer

B:

Pipeline serialization reduces contention and conflicting approval assumptions; backend locking is an additional integrity layer rather than a full deployment scheduler; this behavior should be assessed against the concrete need to avoid overlapping infrastructure modifications even when locks exist. This directly supports the task to avoid overlapping infrastructure modifications even when locks exist during an automated release.

Incorrect Answers

A:

Disabling locking increases risk of simultaneous updates and state corruption; it is not a substitute for resolving a stale lock; this behavior should be assessed against the concrete need to avoid overlapping infrastructure modifications even when locks exist. The distinction matters here: using that mechanism to keep concurrency protection during normal writes would still leave the objective to avoid overlapping infrastructure modifications even when locks exist unmet.

C:

Force-unlock bypasses normal safeguards and can permit conflicting state writes; the lock ID helps ensure the intended lock is targeted; this behavior should be assessed against the concrete need to avoid overlapping infrastructure modifications even when locks exist. The stated requirement is to avoid overlapping infrastructure modifications even when locks exist, not to clear a stale lock when the original owner is definitely inactive; this alternative addresses a different control or phase.

D:

Lock reports can include identifying information about the holder and operation; investigate the legitimate owner before overriding anything; this behavior should be assessed against the concrete need to avoid overlapping infrastructure modifications even when locks exist. That can be useful when the aim is to diagnose whether another run or process holds a state lock, but it does not directly deliver the requested ability to avoid overlapping infrastructure modifications even when locks exist.

Question 625

A build pipeline must initialize an external state service. A reviewer must determine how to protect the authoritative snapshot from concurrent writers. Which action is the appropriate choice?

  1. Use a partial backend configuration
  2. Declare terraform { backend "s3" { ... } }
  3. Run terraform init after declaring a backend
  4. Enable state locking when supported

Explanation

Correct Answer

D:

Storage alone does not coordinate multiple applies; the backend's documented locking behavior must be configured and understood; this behavior should be assessed against the concrete need to protect the authoritative snapshot from concurrent writers. This directly supports the task to protect the authoritative snapshot from concurrent writers during a staged rollout.

Incorrect Answers

A:

A backend block can omit settings that init receives separately; terraform persists merged backend settings in local metadata, so avoid putting raw secrets there; this behavior should be assessed against the concrete need to protect the authoritative snapshot from concurrent writers. That can be useful when the aim is to supply environment-specific backend keys at initialization time, but it does not directly deliver the requested ability to protect the authoritative snapshot from concurrent writers.

B:

A backend block chooses Terraform state storage and related settings; it does not configure the AWS provider used for managed resources; this behavior should be assessed against the concrete need to protect the authoritative snapshot from concurrent writers. The distinction matters here: using that mechanism to select a supported remote state storage implementation would still leave the objective to protect the authoritative snapshot from concurrent writers unmet.

C:

Backend initialization validates configuration and can prompt to migrate existing state; declaring the block alone does not upload the prior snapshot; this behavior should be assessed against the concrete need to protect the authoritative snapshot from concurrent writers. It may support a related workflow, but the question specifically requires the mechanism for protect the authoritative snapshot from concurrent writers rather than initialize the configured state location before normal operations.

Question 626

The immediate Terraform task is to prevent inconsistent serials, lineages, attributes, and provider references. Which method handles that task most directly?

  1. Treat a deleted remote object as drift
  2. Avoid editing raw state JSON
  3. Treat out-of-band tag updates as drift
  4. Use a removed block with destroy = false
  5. Compare stored state with a freshly evaluated plan

Explanation

Correct Answer

B:

Supported state commands and declarative refactoring blocks are safer; incorrect manual edits can make future plans target the wrong objects; this behavior should be assessed against the concrete need to prevent inconsistent serials, lineages, attributes, and provider references. This directly supports the task to prevent inconsistent serials, lineages, attributes, and provider references during a configuration change.

Incorrect Answers

A:

If a tracked object no longer exists but configuration still declares it, a normal plan may propose recreating it; state alone cannot revive the original object; this behavior should be assessed against the concrete need to prevent inconsistent serials, lineages, attributes, and provider references. The stated requirement is to prevent inconsistent serials, lineages, attributes, and provider references, not to understand why Terraform may propose creation again; this alternative addresses a different control or phase.

C:

Terraform may plan to restore declared tags unless lifecycle rules deliberately ignore certain changes; the external edit does not automatically rewrite HCL; this behavior should be assessed against the concrete need to prevent inconsistent serials, lineages, attributes, and provider references. The distinction matters here: using that mechanism to understand reconciliation when provider-observed values differ from HCL would still leave the objective to prevent inconsistent serials, lineages, attributes, and provider references unmet.

D:

The removed block records the intentional withdrawal of management without instructing the provider to delete the remote object; it is not a mere address rename like a moved block; this behavior should be assessed against the concrete need to prevent inconsistent serials, lineages, attributes, and provider references. It may support a related workflow, but the question specifically requires the mechanism for prevent inconsistent serials, lineages, attributes, and provider references rather than document a handoff where Terraform relinquishes ownership but leaves deployed infrastructure untouched.

E:

State holds a previous observation rather than live inventory; a new normal plan asks the provider for current properties and can expose drift that a static state inspection alone would miss; this behavior should be assessed against the concrete need to prevent inconsistent serials, lineages, attributes, and provider references. The stated requirement is to prevent inconsistent serials, lineages, attributes, and provider references, not to identify whether old recorded values still reflect remote reality after out-of-band changes; this alternative addresses a different control or phase.

Question 627

A small lab needs to understand file-based state storage. Two independent changes are requested: first, include state confidentiality in developer-machine security; second, prevent Terraform from losing track of existing objects. Which pair of measures fulfills both?

  1. Protect local workstation backups + Avoid deleting state to repair an ordinary HCL error
  2. Protect local workstation backups + Use CLI workspaces for separate local state snapshots
  3. Reinitialize after changing backend configuration + Avoid deleting state to repair an ordinary HCL error
  4. Keep local state out of Git + Understand a local backend's locking mechanism

Explanation

Correct Answer

A:

For the first criterion, copies of state and plan files can expose provider-returned secrets; encrypting disks and limiting file access remain important even for demonstration environments; this behavior should be assessed against the concrete need to include state confidentiality in developer-machine security and prevent Terraform from losing track of existing objects; this directly addresses the need to include state confidentiality in developer-machine security. For the separate second criterion, removing state does not delete remote objects, but it removes their managed mappings; a later plan may attempt duplicate creation rather than fixing source syntax; this behavior should be assessed against the concrete need to include state confidentiality in developer-machine security and prevent Terraform from losing track of existing objects; this fulfills the need to prevent Terraform from losing track of existing objects. Together they cover the independent tasks of include state confidentiality in developer-machine security and prevent Terraform from losing track of existing objects without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure meets the requirement to include state confidentiality in developer-machine security, but its partner serves a different role: Terraform CLI workspaces select different state instances; local nondefault workspaces use workspace-specific file locations; they do not establish HCP workspace permissions; this behavior should be assessed against the concrete need to include state confidentiality in developer-machine security and prevent Terraform from losing track of existing objects. That second component is designed to isolate environments while sharing the same root configuration, so the still-missing criterion is to prevent Terraform from losing track of existing objects, while the first criterion remains include state confidentiality in developer-machine security.

C:

The second measure does meet the prevent Terraform from losing track of existing objects requirement, but the first is designed for another concern: Backend setting changes require init to recognize and potentially migrate state; a subsequent plan alone cannot safely change backend storage; this behavior should be assessed against the concrete need to include state confidentiality in developer-machine security and prevent Terraform from losing track of existing objects. That first component is designed to make Terraform adopt the new local or remote state location, which does not accomplish the requested task to include state confidentiality in developer-machine security, even though the other measure satisfies prevent Terraform from losing track of existing objects.

D:

The first measure is intended to avoid exposing sensitive resource attributes in repository history: State can contain secrets even if outputs are redacted; a version-control checkout is not a secure state database or concurrency mechanism; this behavior should be assessed against the concrete need to include state confidentiality in developer-machine security and prevent Terraform from losing track of existing objects. The second measure is intended to recognize that local state can be locked to avoid concurrent local access: The local backend uses local filesystem locking where supported; it does not coordinate developers operating separate copies on different machines; this behavior should be assessed against the concrete need to include state confidentiality in developer-machine security and prevent Terraform from losing track of existing objects. Neither is the directly designated method for the separate goals of include state confidentiality in developer-machine security and prevent Terraform from losing track of existing objects in this review.

Question 628

An operator is resolving a blocked state update. A reviewer must determine how to distinguish genuine active operations from abandoned lock records. Which action is the appropriate choice?

  1. Understand a crash can leave a stale lock
  2. Recognize lock acquisition occurs around state operations
  3. Use -lock-timeout=5m where supported
  4. Recognize lock ownership metadata

Explanation

Correct Answer

A:

Abnormal termination may prevent normal unlock; verify process inactivity and current state integrity before administrative cleanup; this behavior should be assessed against the concrete need to distinguish genuine active operations from abandoned lock records. This directly supports the task to distinguish genuine active operations from abandoned lock records during a staged rollout.

Incorrect Answers

B:

Terraform may need to lock state for a safe plan or apply; a lock error is not itself an API authentication or HCL syntax error; this behavior should be assessed against the concrete need to distinguish genuine active operations from abandoned lock records. The stated requirement is to distinguish genuine active operations from abandoned lock records, not to understand why a run can fail before any resource creation; this alternative addresses a different control or phase.

C:

The timeout specifies how long to wait for lock availability before failing; it does not forcibly terminate another process; this behavior should be assessed against the concrete need to distinguish genuine active operations from abandoned lock records. That can be useful when the aim is to let a Terraform operation retry acquiring a busy state lock, but it does not directly deliver the requested ability to distinguish genuine active operations from abandoned lock records.

D:

Lock reports can include identifying information about the holder and operation; investigate the legitimate owner before overriding anything; this behavior should be assessed against the concrete need to distinguish genuine active operations from abandoned lock records. The distinction matters here: using that mechanism to diagnose whether another run or process holds a state lock would still leave the objective to distinguish genuine active operations from abandoned lock records unmet.

Question 629

The immediate Terraform task is to supply environment-specific backend keys at initialization time. Which method handles that task most directly?

  1. Avoid committing .terraform/ backend metadata
  2. Use a partial backend configuration
  3. Run terraform init after declaring a backend
  4. Use backend-specific environment variables for credentials

Explanation

Correct Answer

B:

A backend block can omit settings that init receives separately; terraform persists merged backend settings in local metadata, so avoid putting raw secrets there; this behavior should be assessed against the concrete need to supply environment-specific backend keys at initialization time. This directly supports the task to supply environment-specific backend keys at initialization time during a configuration change.

Incorrect Answers

A:

Terraform records initialized backend configuration in its generated data directory; this is separate from the tracked HCL declarations; this behavior should be assessed against the concrete need to supply environment-specific backend keys at initialization time. The distinction matters here: using that mechanism to prevent local initialization secrets and settings from entering Git would still leave the objective to supply environment-specific backend keys at initialization time unmet.

C:

Backend initialization validates configuration and can prompt to migrate existing state; declaring the block alone does not upload the prior snapshot; this behavior should be assessed against the concrete need to supply environment-specific backend keys at initialization time. The stated requirement is to supply environment-specific backend keys at initialization time, not to initialize the configured state location before normal operations; this alternative addresses a different control or phase.

D:

Environment-based authentication can reduce disclosure in saved metadata and plans; backend permissions must still permit the required state operations; this behavior should be assessed against the concrete need to supply environment-specific backend keys at initialization time. That can be useful when the aim is to avoid hardcoding secret authentication fields in HCL or init flags, but it does not directly deliver the requested ability to supply environment-specific backend keys at initialization time.

Question 630

In an automated release, the requested result is to preview a state update that accepts the current remote attributes. What should the engineer select?

  1. Treat out-of-band tag updates as drift
  2. Avoid editing raw state JSON
  3. Use terraform state list to inspect bindings
  4. Use terraform plan -refresh-only

Explanation

Correct Answer

D:

Refresh-only does not plan corrective resource changes; applying that plan updates Terraform's state representation of the observed infrastructure; this behavior should be assessed against the concrete need to preview a state update that accepts the current remote attributes. This directly supports the task to preview a state update that accepts the current remote attributes during a module implementation.

Incorrect Answers

A:

Terraform may plan to restore declared tags unless lifecycle rules deliberately ignore certain changes; the external edit does not automatically rewrite HCL; this behavior should be assessed against the concrete need to preview a state update that accepts the current remote attributes. That can be useful when the aim is to understand reconciliation when provider-observed values differ from HCL, but it does not directly deliver the requested ability to preview a state update that accepts the current remote attributes.

B:

Supported state commands and declarative refactoring blocks are safer; incorrect manual edits can make future plans target the wrong objects; this behavior should be assessed against the concrete need to preview a state update that accepts the current remote attributes. The distinction matters here: using that mechanism to prevent inconsistent serials, lineages, attributes, and provider references would still leave the objective to preview a state update that accepts the current remote attributes unmet.

C:

The command reports addresses, not a complete catalog of provider-side objects; unmanaged objects will not appear; this behavior should be assessed against the concrete need to preview a state update that accepts the current remote attributes. It may support a related workflow, but the question specifically requires the mechanism for preview a state update that accepts the current remote attributes rather than enumerate the tracked resource addresses in the selected state.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests