HashiCorp Terraform Associate 004 Practice Test 32
Question 310
During a controlled Terraform CLI recovery exercise, the following condition occurs: A debugging session needs the stored attributes of module.network.resource_name for one key, but the engineer runs terraform output and finds no corresponding root output. The same infrastructure must remain managed without unintended replacements. Select TWO: the decisive first check and the change that directly addresses the problem.
- Identify the exact resource instance address from terraform state list and inspect it with terraform state show.
- Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan.
- Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
- Use terraform state show on the selected address to review tracked attributes without changing resources.
- Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
Explanation
Correct Answers
A:Identify the exact resource instance address from terraform state list and inspect it with terraform state show. State inspection commands read tracked resource details; root outputs expose only values explicitly declared for outputs. A justified correction is: Use terraform state show on the selected address to review tracked attributes without changing resources. This forms one element of the required two-step diagnosis and correction.
D:Use terraform state show on the selected address to review tracked attributes without changing resources. State inspection commands read tracked resource details; root outputs expose only values explicitly declared for outputs. Confirm the cause with: Identify the exact resource instance address from terraform state list and inspect it with terraform state show. A concrete acceptance test is: The reviewer sees the requested resource's stored values while no import, state edit or remote mutation is performed. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan. This relates to terraform import binds preexisting remote object rather than the matching diagnosis-and-remediation pair required here. Check: Identify the exact resource instance address from terraform state list and inspect it with terraform state show. Then change: Use terraform state show on the selected address to review tracked attributes without changing resources.
C:Use terraform state list to enumerate the actual addresses tracked in the selected workspace state. This relates to state list for tracking managed addresses rather than the matching diagnosis-and-remediation pair required here. Check: Identify the exact resource instance address from terraform state list and inspect it with terraform state show. Then change: Use terraform state show on the selected address to review tracked attributes without changing resources.
E:Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data. This relates to tf_log for troubleshooting provider and cli diagnostics rather than the matching diagnosis-and-remediation pair required here. Check: Identify the exact resource instance address from terraform state list and inspect it with terraform state show. Then change: Use terraform state show on the selected address to review tracked attributes without changing resources.
Question 311
As a second engineer rehearses an infrastructure state migration, the following condition occurs: An administrator intentionally changes a provider-computed tag outside Terraform and wants the tracked state to reflect reality without reverting any remote resource. The operation must not delete or duplicate existing production objects. What targeted engineering response should the team implement?
- Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change.
- Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change.
- Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.
- Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
Explanation
Correct Answer
A:Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change. Refresh-only mode reconciles tracked state with observed infrastructure; normal apply may instead modify infrastructure to match configuration. Confirm the cause with: Inspect terraform plan -refresh-only and distinguish state/output updates from normal planned infrastructure modifications. A concrete acceptance test is: The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
Incorrect Answers
B:Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change. This could address out-of-band drift detection in managed resource, but it does not correct the indicated refresh-only state update without infrastructure mutation mechanism. The relevant fix is: Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change.
C:Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. This could address local backend path and exposure, but it does not correct the indicated refresh-only state update without infrastructure mutation mechanism. The relevant fix is: Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change.
D:Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration. This could address backend credentials kept out of plan artifacts, but it does not correct the indicated refresh-only state update without infrastructure mutation mechanism. The relevant fix is: Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change.
Question 312
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: An organization switches from local state to a remote backend, but its existing Terraform work directory still points to the former backend settings. The operator must obtain auditable evidence before touching production resources. Which investigation would most directly establish the reported Terraform failure?
- Inspect the .terraform working directory and initialization output for missing backend, module, and provider setup.
- Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope.
- Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
- Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed.
Explanation
Correct Answer
D:Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed. Changing backend configuration requires a deliberate reinitialization decision; a text edit alone does not migrate state safely. A justified correction is: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups. This matters here because an organization switches from local state to a remote backend, but its existing Terraform work directory still….
Incorrect Answers
A:Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. This inspects terraform init backend and provider preparation rather than the reported reinitializing after backend configuration change issue. The decisive investigation is: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed.
B:Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. This inspects terraform destroy is managed-scope deletion rather than the reported reinitializing after backend configuration change issue. The decisive investigation is: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed.
C:Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. This inspects apply requires approval unless automated rather than the reported reinitializing after backend configuration change issue. The decisive investigation is: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed.
Question 313
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An operator adds a Terraform check asserting that an HTTP service is healthy and expects a failed check to halt the same apply as a mandatory precondition. The engineer must respect declared resource contracts and data security boundaries. Which outcome most directly validates the intended fix?
- Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays.
- The resource change is blocked when the prerequisite property fails and permitted combinations pass the condition.
- The module applies under least privilege without retaining the secret in source control or ordinary state output.
- A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
Explanation
Correct Answer
D:A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately. Check blocks generally issue warnings rather than blocking applies; lifecycle conditions enforce resource pre/post invariants. It tests the correction: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
Incorrect Answers
A:Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays. This might validate implicit dependency through resource attribute reference, but it does not prove that check block observability versus hard failure was resolved. Confirm instead: A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
B:The resource change is blocked when the prerequisite property fails and permitted combinations pass the condition. This might validate resource precondition for unsafe configuration, but it does not prove that check block observability versus hard failure was resolved. Confirm instead: A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
C:The module applies under least privilege without retaining the secret in source control or ordinary state output. This might validate vault credential lookup without hardcoding secret values, but it does not prove that check block observability versus hard failure was resolved. Confirm instead: A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
Question 314
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team uses terraform apply -target on one module for every release, leaving graph-related infrastructure changes unnoticed in the rest of the root configuration. The change must preserve the distinction between previewing and modifying infrastructure. Which outcome most directly validates the intended fix?
- A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions.
- Syntax mistakes fail validation while missing remote permission surfaces through its appropriate API interaction rather than being falsely certified.
- Only the intended disposable environment's managed objects are removed and shared production resources remain in separate state.
- The apply finishes after explicit approval and writes the updated resource bindings to the configured backend.
Explanation
Correct Answer
A:A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions. Targeting can bypass part of the configuration graph and should not be a standard substitute for comprehensive reconciliation. It tests the correction: Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
Incorrect Answers
B:Syntax mistakes fail validation while missing remote permission surfaces through its appropriate API interaction rather than being falsely certified. This might validate terraform validate versus cloud permission testing, but it does not prove that targeted apply limitations for normal changes was resolved. Confirm instead: A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions.
C:Only the intended disposable environment's managed objects are removed and shared production resources remain in separate state. This might validate terraform destroy is managed-scope deletion, but it does not prove that targeted apply limitations for normal changes was resolved. Confirm instead: A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions.
D:The apply finishes after explicit approval and writes the updated resource bindings to the configured backend. This might validate apply requires approval unless automated, but it does not prove that targeted apply limitations for normal changes was resolved. Confirm instead: A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions.
Question 315
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: An interactive terraform apply prompts for confirmation, but an engineer assumes it is a failed deployment because no resources changed immediately. The operator must obtain auditable evidence before touching production resources. What targeted engineering response should the team implement?
- Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
- Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy.
- Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
- Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
Explanation
Correct Answer
C:Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs. A normal interactive Terraform apply requires an approval decision; automating approval changes governance, not Terraform's reconciliation rules. Confirm the cause with: Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. A concrete acceptance test is: The apply finishes after explicit approval and writes the updated resource bindings to the configured backend.
Incorrect Answers
A:Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment. This could address targeted apply limitations for normal changes, but it does not correct the indicated apply requires approval unless automated mechanism. The relevant fix is: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
B:Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy. This could address plan versus real infrastructure drift, but it does not correct the indicated apply requires approval unless automated mechanism. The relevant fix is: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
D:Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment. This could address core write plan apply workflow order, but it does not correct the indicated apply requires approval unless automated mechanism. The relevant fix is: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
Question 316
While diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: A legacy cloud object exists in the production account, but terraform import is executed with the default development provider and cannot locate its supplied ID. The investigator must avoid unreviewed state writes. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Compare the declared resource address and remote identifier against the selected state snapshot.
- Identify the exact resource instance address from terraform state list and inspect it with terraform state show.
- Inspect the resource's provider selection, active credentials and which account owns the remote object.
- Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
Explanation
Correct Answer
C:Inspect the resource's provider selection, active credentials and which account owns the remote object. Terraform import relies on a compatible provider configuration and correct remote identifier; IDs are interpreted in provider context. A justified correction is: Select the appropriate aliased provider configuration and import using the real identifier in its owning account.
Incorrect Answers
A:Compare the declared resource address and remote identifier against the selected state snapshot. This inspects terraform import binds preexisting remote object rather than the reported import source account and provider selection issue. The decisive investigation is: Inspect the resource's provider selection, active credentials and which account owns the remote object.
B:Identify the exact resource instance address from terraform state list and inspect it with terraform state show. This inspects state show inspects one stored resource instance rather than the reported import source account and provider selection issue. The decisive investigation is: Inspect the resource's provider selection, active credentials and which account owns the remote object.
D:Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data. This inspects tf_log for troubleshooting provider and cli diagnostics rather than the reported import source account and provider selection issue. The decisive investigation is: Inspect the resource's provider selection, active credentials and which account owns the remote object.
Question 317
During a controlled Terraform CLI recovery exercise, the following condition occurs: An organization adopts hundreds of existing resources using ad hoc CLI import commands that are absent from code review and difficult to reproduce. The same infrastructure must remain managed without unintended replacements. What targeted engineering response should the team implement?
- Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
- Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
- Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
- Select the appropriate aliased provider configuration and import using the real identifier in its owning account.
Explanation
Correct Answer
A:Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state. Configuration-driven import blocks can make existing-resource adoption repeatable and part of a reviewed execution plan. Confirm the cause with: Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. A concrete acceptance test is: The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source. This matters here because an organization adopts hundreds of existing resources using ad hoc CLI import commands that are absent from code….
Incorrect Answers
B:Use terraform state list to enumerate the actual addresses tracked in the selected workspace state. This could address state list for tracking managed addresses, but it does not correct the indicated import blocks for reproducible adoption workflow mechanism. The relevant fix is: Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
C:Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command. This could address tf_log for troubleshooting provider and cli diagnostics, but it does not correct the indicated import blocks for reproducible adoption workflow mechanism. The relevant fix is: Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
D:Select the appropriate aliased provider configuration and import using the real identifier in its owning account. This could address import source account and provider selection, but it does not correct the indicated import blocks for reproducible adoption workflow mechanism. The relevant fix is: Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
Question 318
During a controlled Terraform CLI recovery exercise, the following condition occurs: An operator sets TF_LOG_PATH to an output file but receives no detailed diagnostics because Terraform logging was never enabled. The same infrastructure must remain managed without unintended replacements. Which Terraform configuration or workflow change most directly corrects the described issue?
- Select the appropriate aliased provider configuration and import using the real identifier in its owning account.
- Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
- Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
- Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan.
Explanation
Correct Answer
B:Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command. TF_LOG_PATH selects a log destination but must be paired with an enabled TF_LOG level to produce verbose logs. Confirm the cause with: Check the TF_LOG environment variable and filesystem permissions for the requested log path. A concrete acceptance test is: The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds. This matters here because an operator sets TF_LOG_PATH to an output file but receives no detailed diagnostics because Terraform logging was….
Incorrect Answers
A:Select the appropriate aliased provider configuration and import using the real identifier in its owning account. This could address import source account and provider selection, but it does not correct the indicated tf_log_path requires enabled logging mechanism. The relevant fix is: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command. This matters here because an operator sets TF_LOG_PATH to an output file but receives no detailed diagnostics because Terraform logging was….
C:Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command. This could address tf_log for troubleshooting provider and cli diagnostics, but it does not correct the indicated tf_log_path requires enabled logging mechanism. The relevant fix is: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command. This matters here because an operator sets TF_LOG_PATH to an output file but receives no detailed diagnostics because Terraform logging was….
D:Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan. This could address terraform import binds preexisting remote object, but it does not correct the indicated tf_log_path requires enabled logging mechanism. The relevant fix is: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
Question 319
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A list of application names drives count-based resources, and removing one name shifts indices so Terraform plans to replace unrelated applications. The engineer must respect declared resource contracts and data security boundaries. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
- Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow.
- Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
- Inspect state instance addresses and compare count positions against stable business keys.
- Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first.
Explanation
Correct Answers
A:Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. Count identifies instances by numeric position, while for_each keys can preserve stable identity across list ordering changes. Confirm the cause with: Inspect state instance addresses and compare count positions against stable business keys. A concrete acceptance test is: Removing one application plans its own deletion without shifting unrelated resource instances to new indexes. This forms one element of the required two-step diagnosis and correction. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A list of….
D:Inspect state instance addresses and compare count positions against stable business keys. Count identifies instances by numeric position, while for_each keys can preserve stable identity across list ordering changes. A justified correction is: Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. This forms one element of the required two-step diagnosis and correction. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A list of….
Incorrect Answers
B:Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow. This relates to vault credential lookup without hardcoding secret values rather than the matching diagnosis-and-remediation pair required here. Check: Inspect state instance addresses and compare count positions against stable business keys. Then change: Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
C:Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module. This relates to conditional expressions for environment configuration rather than the matching diagnosis-and-remediation pair required here. Check: Inspect state instance addresses and compare count positions against stable business keys. Then change: Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A list of….
E:Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first. This relates to explicit depends_on for behavior-only dependencies rather than the matching diagnosis-and-remediation pair required here. Check: Inspect state instance addresses and compare count positions against stable business keys. Then change: Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
Question 320
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An automated Terraform run uses an obsolete deployment region even though an operator changed the default region in variables.tf, because another source supplies an overriding value. The engineer must respect declared resource contracts and data security boundaries. What acceptance evidence best establishes that the Terraform issue has been resolved?
- The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
- Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions.
- A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
- Routine Terraform output suppresses the marked secret while protected state access remains restricted.
Explanation
Correct Answer
A:The plan records the authorized region value, and a second run produces the same selection under the same variable inputs. Terraform variable defaults apply only when no higher-precedence assignment supplies a different value. It tests the correction: Remove or update the overriding variable source and make the intended region input explicit for the controlled run. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An….
Incorrect Answers
B:Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions. This might validate object type contract with nested attributes, but it does not prove that variable input precedence and configuration injection was resolved. Confirm instead: The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
C:A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately. This might validate check block observability versus hard failure, but it does not prove that variable input precedence and configuration injection was resolved. Confirm instead: The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
D:Routine Terraform output suppresses the marked secret while protected state access remains restricted. This might validate sensitive output display behavior, but it does not prove that variable input precedence and configuration injection was resolved. Confirm instead: The plan records the authorized region value, and a second run produces the same selection under the same variable inputs. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An….