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

Question 670

An engineer needs to accept new backend settings without copying old state as part of an automated release. Which option is the best fit?

  1. Use backend migration instead of copying arbitrary JSON
  2. Declare terraform { backend "s3" { ... } }
  3. Use terraform init -reconfigure when not migrating
  4. Use a partial backend configuration

Explanation

Correct Answer

C:

Reconfiguration forgets the previously initialized backend relationship; it is dangerous if the operator mistakenly believes existing bindings moved with it; this behavior should be assessed against the concrete need to accept new backend settings without copying old state. This directly supports the task to accept new backend settings without copying old state during an infrastructure audit.

Incorrect Answers

A:

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 accept new backend settings without copying old state. The distinction matters here: using that mechanism to preserve state metadata while switching storage would still leave the objective to accept new backend settings without copying old state unmet.

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 accept new backend settings without copying old state. It may support a related workflow, but the question specifically requires the mechanism for accept new backend settings without copying old state rather than select a supported remote state storage implementation.

D:

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 accept new backend settings without copying old state. 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 accept new backend settings without copying old state.

Question 671

A Terraform resource has been renamed or modified outside code. The requirement is to rename a Terraform resource address while preserving ongoing management of the same remote object. Which Terraform mechanism directly meets this requirement?

  1. Use a moved block for an address rename
  2. Use terraform state rm to forget an object
  3. Use terraform plan -refresh-only
  4. Use terraform state list to inspect bindings

Explanation

Correct Answer

A:

The from/to mapping teaches Terraform how to refactor tracked addresses before planning; it prevents an unnecessary destroy/create caused solely by a configuration rename; this behavior should be assessed against the concrete need to rename a Terraform resource address while preserving ongoing management of the same remote object. This directly supports the task to rename a Terraform resource address while preserving ongoing management of the same remote object during a planned migration.

Incorrect Answers

B:

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 rename a Terraform resource address while preserving ongoing management of the same remote object. The distinction matters here: using that mechanism to stop managing a specific binding without deleting the infrastructure would still leave the objective to rename a Terraform resource address while preserving ongoing management of the same remote object unmet.

C:

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 rename a Terraform resource address while preserving ongoing management of the same remote object. It may support a related workflow, but the question specifically requires the mechanism for rename a Terraform resource address while preserving ongoing management of the same remote object rather than preview a state update that accepts the current remote attributes.

D:

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 rename a Terraform resource address while preserving ongoing management of the same remote object. The stated requirement is to rename a Terraform resource address while preserving ongoing management of the same remote object, not to enumerate the tracked resource addresses in the selected state; this alternative addresses a different control or phase.

Question 672

A platform team is configuring remote state securely. The requirement is to secure a centrally stored record of infrastructure attributes. Which Terraform mechanism directly meets this requirement?

  1. Enable state locking when supported
  2. Understand terraform_remote_state reads root outputs
  3. Use backend-specific environment variables for credentials
  4. Protect remote state with encryption and restricted IAM

Explanation

Correct Answer

D:

Remote state can include secrets, IDs, and metadata; confidentiality and access authorization are required even when console outputs are marked sensitive; this behavior should be assessed against the concrete need to secure a centrally stored record of infrastructure attributes. This directly supports the task to secure a centrally stored record of infrastructure attributes during a planned migration.

Incorrect Answers

A:

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 secure a centrally stored record of infrastructure attributes. It may support a related workflow, but the question specifically requires the mechanism for secure a centrally stored record of infrastructure attributes rather than protect the authoritative snapshot from concurrent writers.

B:

The built-in data source consumes outputs from a different state; it does not give Terraform lifecycle ownership of the remote objects stored there; this behavior should be assessed against the concrete need to secure a centrally stored record of infrastructure attributes. The stated requirement is to secure a centrally stored record of infrastructure attributes, not to share selected information from another state rather than taking over its resources; this alternative addresses a different control or phase.

C:

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 secure a centrally stored record of infrastructure attributes. 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 secure a centrally stored record of infrastructure attributes.

Question 673

An infrastructure team is choosing safe state-refactoring and drift actions. A reviewer must determine how to stop managing a specific binding without deleting the infrastructure. Which action is the appropriate choice?

  1. Treat out-of-band tag updates as drift
  2. Use terraform state rm to forget an object
  3. Use a moved block for an address rename
  4. Use terraform state pull for an administrative snapshot

Explanation

Correct Answer

B:

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 stop managing a specific binding without deleting the infrastructure. This directly supports the task to stop managing a specific binding without deleting the infrastructure during a cross-team handoff.

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 stop managing a specific binding without deleting the infrastructure. The distinction matters here: using that mechanism to understand reconciliation when provider-observed values differ from HCL would still leave the objective to stop managing a specific binding without deleting the infrastructure unmet.

C:

The from/to mapping teaches Terraform how to refactor tracked addresses before planning; it prevents an unnecessary destroy/create caused solely by a configuration rename; this behavior should be assessed against the concrete need to stop managing a specific binding without deleting the infrastructure. The stated requirement is to stop managing a specific binding without deleting the infrastructure, not to rename a Terraform resource address while preserving ongoing management of the same remote object; this alternative addresses a different control or phase.

D:

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 stop managing a specific binding without deleting the infrastructure. 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 stop managing a specific binding without deleting the infrastructure.

Question 674

A resource already exists outside Terraform management. The requirement is to detect discrepancies between adopted object settings and desired HCL. Which Terraform mechanism directly meets this requirement?

  1. Review the first post-import plan
  2. Avoid importing the same object under unrelated addresses
  3. Use module-qualified import addresses
  4. Select the correct resource type for import

Explanation

Correct Answer

A:

The first plan can expose fields that require deliberate configuration; importing does not promise a no-op next plan; this behavior should be assessed against the concrete need to detect discrepancies between adopted object settings and desired HCL. This directly supports the task to detect discrepancies between adopted object settings and desired HCL during an automated release.

Incorrect Answers

B:

Terraform assumes one managed binding for a remote object; duplicate ownership can lead to conflicting updates and deletions; this behavior should be assessed against the concrete need to detect discrepancies between adopted object settings and desired HCL. It may support a related workflow, but the question specifically requires the mechanism for detect discrepancies between adopted object settings and desired HCL rather than prevent two Terraform resources or states from claiming one remote object.

C:

Resource addresses can include paths such as module.network.aws_vpc.main; correct addresses preserve the intended module ownership; this behavior should be assessed against the concrete need to detect discrepancies between adopted object settings and desired HCL. The stated requirement is to detect discrepancies between adopted object settings and desired HCL, not to adopt an object into a child module's declared resource; this alternative addresses a different control or phase.

D:

Import requires a compatible Terraform resource type; a read-only data source is not a managed-resource import target; this behavior should be assessed against the concrete need to detect discrepancies between adopted object settings and desired HCL. That can be useful when the aim is to use a provider schema that matches the remote object's API kind, but it does not directly deliver the requested ability to detect discrepancies between adopted object settings and desired HCL.

Question 675

A maintenance task requires reviewing one tracked object. A reviewer must determine how to change the address associated with a managed remote object. Which action is the appropriate choice?

  1. Use terraform show -json for structured state inspection
  2. Run terraform state mv FROM TO
  3. Run terraform state show ADDRESS
  4. Recognize state subcommands operate against remote backends

Explanation

Correct Answer

B:

Move updates state bindings without changing the remote object's actual location; verify resource type and intended address before executing; this behavior should be assessed against the concrete need to change the address associated with a managed remote object. This directly supports the task to change the address associated with a managed remote object during a staged rollout.

Incorrect Answers

A:

JSON can support controlled analysis, but it may expose sensitive values; it is different from using arbitrary text parsing of human output; this behavior should be assessed against the concrete need to change the address associated with a managed remote object. That can be useful when the aim is to obtain machine-readable saved state or plan data through a documented command, but it does not directly deliver the requested ability to change the address associated with a managed remote object.

C:

Show exposes attributes and remote IDs from state; a current refresh may be needed to learn if the real object changed; this behavior should be assessed against the concrete need to change the address associated with a managed remote object. It may support a related workflow, but the question specifically requires the mechanism for change the address associated with a managed remote object rather than inspect recorded attributes for one managed resource instance.

D:

State reads and writes may perform network requests for remote snapshots; write operations still require appropriate permissions and locking; this behavior should be assessed against the concrete need to change the address associated with a managed remote object. The stated requirement is to change the address associated with a managed remote object, not to use the configured backend rather than assuming every state operation is local; this alternative addresses a different control or phase.

Question 676

A reviewer has to approve a two-part design: record high-level operational diagnostic messages; additionally, restrict log output primarily to errors. Which option pairs the correct mechanisms?

  1. Set TF_LOG=INFO for moderate logging + Set TF_LOG=ERROR for critical diagnostics
  2. Avoid uploading full trace logs without redaction + Set TF_LOG_CORE selectively
  3. Set TF_LOG=WARN to reduce detail + Set TF_LOG=ERROR for critical diagnostics
  4. Set TF_LOG=INFO for moderate logging + Set TF_LOG=TRACE for deep diagnostics

Explanation

Correct Answer

A:

For the first criterion, info logging is less verbose than DEBUG or TRACE; it is not a substitute for an execution plan or state backup; this behavior should be assessed against the concrete need to record high-level operational diagnostic messages and restrict log output primarily to errors; this directly addresses the need to record high-level operational diagnostic messages. For the separate second criterion, the error level minimizes routine diagnostic output; it is unsuitable when the root cause only appears in earlier debug events; this behavior should be assessed against the concrete need to record high-level operational diagnostic messages and restrict log output primarily to errors; this fulfills the need to restrict log output primarily to errors. Together they cover the independent tasks of record high-level operational diagnostic messages and restrict log output primarily to errors without exchanging the responsibilities of these features.

Incorrect Answers

B:

The first measure is intended to limit disclosure of tokens, resource properties, and environment details: Verbose diagnostics can reveal credential material or identifiers; sanitization is necessary before sharing with external support; this behavior should be assessed against the concrete need to record high-level operational diagnostic messages and restrict log output primarily to errors. The second measure is intended to focus diagnostic verbosity on Terraform Core behavior: Core logging helps with evaluation, graph, and orchestration investigation; provider-specific API problems may need provider logging instead; this behavior should be assessed against the concrete need to record high-level operational diagnostic messages and restrict log output primarily to errors. Neither is the directly designated method for the separate goals of record high-level operational diagnostic messages and restrict log output primarily to errors in this review.

C:

The second measure does meet the restrict log output primarily to errors requirement, but the first is designed for another concern: Warning-level logs are useful when normal runs are noisy; they may omit the detailed plugin exchange needed for complex failures; this behavior should be assessed against the concrete need to record high-level operational diagnostic messages and restrict log output primarily to errors. That first component is designed to focus on warnings and errors rather than full execution traces, which does not accomplish the requested task to record high-level operational diagnostic messages, even though the other measure satisfies restrict log output primarily to errors.

D:

The first measure meets the requirement to record high-level operational diagnostic messages, but its partner serves a different role: Trace logging can reveal Core and provider interactions; it may include sensitive data and should be enabled only for controlled troubleshooting; this behavior should be assessed against the concrete need to record high-level operational diagnostic messages and restrict log output primarily to errors. That second component is designed to enable the most detailed general Terraform diagnostic messages, so the still-missing criterion is to restrict log output primarily to errors, while the first criterion remains record high-level operational diagnostic messages.

Question 677

An engineer is onboarding a legacy service into IaC. A reviewer must determine how to map a collection of existing IDs to multiple resource instances. Which action is the appropriate choice?

  1. Use import blocks with for_each when supported
  2. Use indexed resource addresses for repeated resources
  3. Review the first post-import plan
  4. Avoid importing the same object under unrelated addresses

Explanation

Correct Answer

A:

Configuration-driven import can iterate known instances; each generated target still must correspond to a managed resource declaration; this behavior should be assessed against the concrete need to map a collection of existing IDs to multiple resource instances. This directly supports the task to map a collection of existing IDs to multiple resource instances during a staged rollout.

Incorrect Answers

B:

An address such as resource.name[0] or ["key"] selects one instance; omitting the index can refer to the wrong declaration shape; this behavior should be assessed against the concrete need to map a collection of existing IDs to multiple resource instances. The stated requirement is to map a collection of existing IDs to multiple resource instances, not to target the appropriate count or for-each instance during import; this alternative addresses a different control or phase.

C:

The first plan can expose fields that require deliberate configuration; importing does not promise a no-op next plan; this behavior should be assessed against the concrete need to map a collection of existing IDs to multiple resource instances. That can be useful when the aim is to detect discrepancies between adopted object settings and desired HCL, but it does not directly deliver the requested ability to map a collection of existing IDs to multiple resource instances.

D:

Terraform assumes one managed binding for a remote object; duplicate ownership can lead to conflicting updates and deletions; this behavior should be assessed against the concrete need to map a collection of existing IDs to multiple resource instances. The distinction matters here: using that mechanism to prevent two Terraform resources or states from claiming one remote object would still leave the objective to map a collection of existing IDs to multiple resource instances unmet.

Question 678

The immediate Terraform task is to inspect recorded attributes for one managed resource instance. Which method handles that task most directly?

  1. Run terraform state show ADDRESS
  2. Use terraform show -json for structured state inspection
  3. Use terraform state list ADDRESS_PREFIX filtering
  4. Run terraform state mv FROM TO

Explanation

Correct Answer

A:

Show exposes attributes and remote IDs from state; a current refresh may be needed to learn if the real object changed; this behavior should be assessed against the concrete need to inspect recorded attributes for one managed resource instance. This directly supports the task to inspect recorded attributes for one managed resource instance during a configuration change.

Incorrect Answers

B:

JSON can support controlled analysis, but it may expose sensitive values; it is different from using arbitrary text parsing of human output; this behavior should be assessed against the concrete need to inspect recorded attributes for one managed resource instance. It may support a related workflow, but the question specifically requires the mechanism for inspect recorded attributes for one managed resource instance rather than obtain machine-readable saved state or plan data through a documented command.

C:

State list accepts address filters for focused inspection; the result remains a listing of tracked bindings, not an operation on their remote objects; this behavior should be assessed against the concrete need to inspect recorded attributes for one managed resource instance. The stated requirement is to inspect recorded attributes for one managed resource instance, not to narrow displayed bindings to a resource or module subset; this alternative addresses a different control or phase.

D:

Move updates state bindings without changing the remote object's actual location; verify resource type and intended address before executing; this behavior should be assessed against the concrete need to inspect recorded attributes for one managed resource instance. That can be useful when the aim is to change the address associated with a managed remote object, but it does not directly deliver the requested ability to inspect recorded attributes for one managed resource instance.

Question 679

A Terraform rollout has separate acceptance criteria: focus on warnings and errors rather than full execution traces and write diagnostic log output to a controlled file. Which combined approach directly satisfies the two criteria?

  1. Set TF_LOG=DEBUG for debugging + Set TF_LOG=ERROR for critical diagnostics
  2. Set TF_LOG=WARN to reduce detail + Set TF_LOG_PATH=terraform.log with logging enabled
  3. Unset TF_LOG after diagnosing the issue + Set TF_LOG_PATH=terraform.log with logging enabled
  4. Set TF_LOG=WARN to reduce detail + Set TF_LOG_PROVIDER selectively

Explanation

Correct Answer

B:

For the first criterion, warning-level logs are useful when normal runs are noisy; they may omit the detailed plugin exchange needed for complex failures; this behavior should be assessed against the concrete need to focus on warnings and errors rather than full execution traces and write diagnostic log output to a controlled file; this directly addresses the need to focus on warnings and errors rather than full execution traces. For the separate second criterion, a log path directs Terraform logs to a file when logging is active; the path alone does not necessarily enable diagnostic verbosity; this behavior should be assessed against the concrete need to focus on warnings and errors rather than full execution traces and write diagnostic log output to a controlled file; this fulfills the need to write diagnostic log output to a controlled file. Together they cover the independent tasks of focus on warnings and errors rather than full execution traces and write diagnostic log output to a controlled file without exchanging the responsibilities of these features.

Incorrect Answers

A:

The first measure is intended to collect detailed execution information without the highest trace verbosity: Debug messages help investigate evaluation and plugin issues; they still require safe retention and redaction; this behavior should be assessed against the concrete need to focus on warnings and errors rather than full execution traces and write diagnostic log output to a controlled file. The second measure is intended to restrict log output primarily to errors: The error level minimizes routine diagnostic output; it is unsuitable when the root cause only appears in earlier debug events; this behavior should be assessed against the concrete need to focus on warnings and errors rather than full execution traces and write diagnostic log output to a controlled file. Neither is the directly designated method for the separate goals of focus on warnings and errors rather than full execution traces and write diagnostic log output to a controlled file in this review.

C:

The second measure does meet the write diagnostic log output to a controlled file requirement, but the first is designed for another concern: Leaving TRACE or DEBUG enabled increases noise and secret-exposure risk; temporary troubleshooting settings should not remain in all pipeline runs; this behavior should be assessed against the concrete need to focus on warnings and errors rather than full execution traces and write diagnostic log output to a controlled file. That first component is designed to return routine automation to normal logging behavior, which does not accomplish the requested task to focus on warnings and errors rather than full execution traces, even though the other measure satisfies write diagnostic log output to a controlled file.

D:

The first measure meets the requirement to focus on warnings and errors rather than full execution traces, but its partner serves a different role: Provider logs help diagnose plugin and remote API behavior; they should be protected because request details may expose sensitive fields; this behavior should be assessed against the concrete need to focus on warnings and errors rather than full execution traces and write diagnostic log output to a controlled file. That second component is designed to focus logging on provider/plugin interactions, so the still-missing criterion is to write diagnostic log output to a controlled file, while the first criterion remains focus on warnings and errors rather than full execution traces.

Question 680

The immediate Terraform task is to prevent two Terraform resources or states from claiming one remote object. Which method handles that task most directly?

  1. Use terraform plan -generate-config-out=FILE for supported imports
  2. Review the first post-import plan
  3. Use a declarative import { to = ..., id = ... } block
  4. Avoid importing the same object under unrelated addresses

Explanation

Correct Answer

D:

Terraform assumes one managed binding for a remote object; duplicate ownership can lead to conflicting updates and deletions; this behavior should be assessed against the concrete need to prevent two Terraform resources or states from claiming one remote object. This directly supports the task to prevent two Terraform resources or states from claiming one remote object during a configuration change.

Incorrect Answers

A:

Configuration generation assists authoring but needs review for defaults, computed fields, and organization policy; generated text is not guaranteed production-ready; this behavior should be assessed against the concrete need to prevent two Terraform resources or states from claiming one remote object. The stated requirement is to prevent two Terraform resources or states from claiming one remote object, not to help draft resource configuration from import intent; this alternative addresses a different control or phase.

B:

The first plan can expose fields that require deliberate configuration; importing does not promise a no-op next plan; this behavior should be assessed against the concrete need to prevent two Terraform resources or states from claiming one remote object. That can be useful when the aim is to detect discrepancies between adopted object settings and desired HCL, but it does not directly deliver the requested ability to prevent two Terraform resources or states from claiming one remote object.

C:

An import block tells Terraform to associate a remote object with a resource address during planning and applying; it improves auditability over an undocumented one-off CLI command; this behavior should be assessed against the concrete need to prevent two Terraform resources or states from claiming one remote object. The distinction matters here: using that mechanism to record an import intent as version-controlled configuration would still leave the objective to prevent two Terraform resources or states from claiming one remote object unmet.

HashiCorp Certified: Terraform Associate (Terraform Associate) Practice Tests