HashiCorp Terraform Associate 004 Practice Test 16
Question 150
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A project stores a state file in a developer's home directory even though multiple engineers need consistent shared planning and state history. The operation must not delete or duplicate existing production objects. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Use one supported state integration for the root; choose the cloud block when adopting HCP Terraform's integrated workflow.
- Inspect the current terraform backend declaration and permissions for the selected shared backend service.
- Inspect the backend configuration and state file location on each workstation to identify local state behavior.
- Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled.
- Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.
Explanation
Correct Answers
B:Inspect the current terraform backend declaration and permissions for the selected shared backend service. Terraform backend configuration selects where state snapshots are stored; migrating them requires careful initialization and authorization. A justified correction is: Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions. This forms one element of the required two-step diagnosis and correction.
E:Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions. Terraform backend configuration selects where state snapshots are stored; migrating them requires careful initialization and authorization. Confirm the cause with: Inspect the current terraform backend declaration and permissions for the selected shared backend service. A concrete acceptance test is: Team plans use the same access-controlled state backend after migration without duplicating existing managed objects. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Use one supported state integration for the root; choose the cloud block when adopting HCP Terraform's integrated workflow. This relates to hcp cloud integration versus remote backend rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the current terraform backend declaration and permissions for the selected shared backend service. Then change: Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.
C:Inspect the backend configuration and state file location on each workstation to identify local state behavior. This relates to local backend path and exposure rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the current terraform backend declaration and permissions for the selected shared backend service. Then change: Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.
D:Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled. This relates to state locking prevents concurrent writes rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the current terraform backend declaration and permissions for the selected shared backend service. Then change: Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.
Question 151
When maintaining Terraform modules used by several application teams, the following condition occurs: A Git-sourced security module pulls the latest default branch on every clean initialization, producing inconsistent firewall rules across deployment dates. The module interface must remain stable and reviewable. Select TWO: the decisive first check and the change that directly addresses the problem.
- Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch.
- Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests.
- Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
- Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL.
- Trace the token through module input/output declarations and identify any output that exposes secret data.
Explanation
Correct Answers
A:Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. VCS module source versions are controlled by source refs rather than by Terraform registry module version constraints. A justified correction is: Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review. This forms one element of the required two-step diagnosis and correction. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A Git-sourced….
C:Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review. VCS module source versions are controlled by source refs rather than by Terraform registry module version constraints. Confirm the cause with: Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. A concrete acceptance test is: Two clean deployments retrieve the same module code revision and avoid unnoticed drift from default-branch updates. This forms one element of the required two-step diagnosis and correction. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A Git-sourced….
Incorrect Answers
B:Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests. This relates to registry module version pin to avoid breaking releases rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. Then change: Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
D:Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL. This relates to registry module source naming contract rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. Then change: Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
E:Trace the token through module input/output declarations and identify any output that exposes secret data. This relates to sensitive input forwarding between nested modules rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. Then change: Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
Question 152
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A resource should be deployed only when its selected storage class meets a business constraint, but the configuration proceeds with unsupported combinations. The engineer must respect declared resource contracts and data security boundaries. What measurable postchange observation would confirm that the correction worked?
- A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
- The plan resolves the intended instance and avoids accidental replacement caused solely by a configuration address rename.
- Routine Terraform output suppresses the marked secret while protected state access remains restricted.
- The resource change is blocked when the prerequisite property fails and permitted combinations pass the condition.
Explanation
Correct Answer
D:The resource change is blocked when the prerequisite property fails and permitted combinations pass the condition. Preconditions assert requirements that must hold before a resource operation can proceed, rather than silently applying risky inputs. It tests the correction: Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
Incorrect Answers
A: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 resource precondition for unsafe configuration was resolved. Confirm instead: The resource change is blocked when the prerequisite property fails and permitted combinations pass the condition.
B:The plan resolves the intended instance and avoids accidental replacement caused solely by a configuration address rename. This might validate resource addressing with repeated instances, but it does not prove that resource precondition for unsafe configuration was resolved. Confirm instead: The resource change is blocked when the prerequisite property fails and permitted combinations pass the condition.
C: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 resource precondition for unsafe configuration was resolved. Confirm instead: The resource change is blocked when the prerequisite property fails and permitted combinations pass the condition.
Question 153
During a controlled Terraform CLI recovery exercise, the following condition occurs: Terraform init fails sporadically with a provider connectivity error, but its normal CLI output lacks sufficient context for investigating the failed request. The same infrastructure must remain managed without unintended replacements. Which proposed remediation solves this failure without masking its cause?
- 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.
- Use terraform state show on the selected address to review tracked attributes without changing resources.
- Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
Explanation
Correct Answer
B:Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command. Terraform logging through TF_LOG adds CLI/provider diagnostics; verbose traces may include sensitive operational information. Confirm the cause with: Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data. A concrete acceptance test is: The logs identify the failing initialization or provider interaction and can be disabled after troubleshooting.
Incorrect Answers
A: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 tf_log for troubleshooting provider and cli diagnostics mechanism. The relevant fix is: Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
C:Use terraform state show on the selected address to review tracked attributes without changing resources. This could address state show inspects one stored resource instance, but it does not correct the indicated tf_log for troubleshooting provider and cli diagnostics mechanism. The relevant fix is: Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
D:Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command. This could address tf_log_path requires enabled logging, but it does not correct the indicated tf_log for troubleshooting provider and cli diagnostics mechanism. The relevant fix is: Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
Question 154
During a controlled module integration test for a production Terraform stack, the following condition occurs: A compliance controller adds a standard cost tag after provisioning and each Terraform plan tries to revert the independently managed tag. The desired fix must avoid unrelated resource changes. Which diagnostic check provides the strongest evidence for the underlying problem?
- Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
- Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration.
- Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value.
- Inspect the provider's replacement behavior, uniqueness constraints, and whether old and new instances can coexist.
Explanation
Correct Answer
A:Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift. ignore_changes omits configured attribute differences from update decisions and should not be a blanket excuse to hide drift. A justified correction is: Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.
Incorrect Answers
B:Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. This inspects resource addressing with repeated instances rather than the reported ignore_changes ownership of externally managed tag issue. The decisive investigation is: Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
C:Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value. This inspects variable default versus required input rather than the reported ignore_changes ownership of externally managed tag issue. The decisive investigation is: Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
D:Inspect the provider's replacement behavior, uniqueness constraints, and whether old and new instances can coexist. This inspects create_before_destroy lifecycle for availability rather than the reported ignore_changes ownership of externally managed tag issue. The decisive investigation is: Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
Question 155
During an operational review of a Terraform state backend, the following condition occurs: A network rule is modified directly in a cloud console and a subsequent Terraform plan proposes reverting it although the Terraform files are unchanged. The team must preserve managed-object identity and safe collaboration. What acceptance evidence best establishes that the Terraform issue has been resolved?
- The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement.
- Team plans use the same access-controlled state backend after migration without duplicating existing managed objects.
- A plan in staging reads staging bindings while a default workspace plan remains independent.
- The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit.
Explanation
Correct Answer
D:The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit. Terraform can detect remote drift during refresh and propose changes back to declared configuration rather than treating console edits as code. It tests the correction: Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change.
Incorrect Answers
A:The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement. This might validate moved block preserves state during address refactor, but it does not prove that out-of-band drift detection in managed resource was resolved. Confirm instead: The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit.
B:Team plans use the same access-controlled state backend after migration without duplicating existing managed objects. This might validate remote backend block configuration, but it does not prove that out-of-band drift detection in managed resource was resolved. Confirm instead: The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit.
C:A plan in staging reads staging bindings while a default workspace plan remains independent. This might validate local workspace state separation, but it does not prove that out-of-band drift detection in managed resource was resolved. Confirm instead: The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit.
Question 156
When maintaining Terraform modules used by several application teams, the following condition occurs: A root module marks its token variable sensitive but an intermediate child module hardcodes the token into a non-sensitive output for an application module. The module interface must remain stable and reviewable. Which diagnostic check provides the strongest evidence for the underlying problem?
- Trace the token through module input/output declarations and identify any output that exposes secret data.
- Inspect the child module's output blocks and root expressions that refer to module.network values.
- Inspect the parent composition and whether the network child provides an output representing the created subnet.
- Compare the upgraded module's documented input/output contract to root references before approving the module version change.
Explanation
Correct Answer
A:Trace the token through module input/output declarations and identify any output that exposes secret data. Module boundaries isolate inputs and outputs, but careless output design can still leak confidential values across those boundaries. A justified correction is: Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs.
Incorrect Answers
B:Inspect the child module's output blocks and root expressions that refer to module.network values. This inspects child output exposure to calling module rather than the reported sensitive input forwarding between nested modules issue. The decisive investigation is: Trace the token through module input/output declarations and identify any output that exposes secret data.
C:Inspect the parent composition and whether the network child provides an output representing the created subnet. This inspects module outputs coordinate dependencies instead of duplicate data rather than the reported sensitive input forwarding between nested modules issue. The decisive investigation is: Trace the token through module input/output declarations and identify any output that exposes secret data.
D:Compare the upgraded module's documented input/output contract to root references before approving the module version change. This inspects module upgrade plan review with changed outputs rather than the reported sensitive input forwarding between nested modules issue. The decisive investigation is: Trace the token through module input/output declarations and identify any output that exposes secret data.
Question 157
During a governed HCP Terraform workspace rollout, the following condition occurs: A team runs Terraform independently on laptops while its shared HCP Terraform workspace is intended to control remote plan and apply runs. The organization must retain auditable authorization for runs and state. Which investigation would most directly establish the reported Terraform failure?
- Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
- Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers.
- Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope.
- Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured.
Explanation
Correct Answer
D:Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured. HCP Terraform workspaces can coordinate Terraform runs and state, but a local directory is not automatically connected to one. A justified correction is: Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow.
Incorrect Answers
A:Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. This inspects terraform cloud block hcp workspace integration rather than the reported hcp terraform remote execution and state hosting issue. The decisive investigation is: Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured.
B:Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers. This inspects vcs-driven hcp terraform run on approved changes rather than the reported hcp terraform remote execution and state hosting issue. The decisive investigation is: Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured.
C:Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope. This inspects hcp workspace variable sets share scoped configuration rather than the reported hcp terraform remote execution and state hosting issue. The decisive investigation is: Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured.
Question 158
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A database argument changes and Terraform shows a replacement action, but the change reviewer reads only the new attribute value and overlooks deletion risk. The change must preserve the distinction between previewing and modifying infrastructure. What measurable postchange observation would confirm that the correction worked?
- A reviewed apply changes only the intended managed attribute and the subsequent plan shows no unexpected pending action.
- Validation passes with the declared variable name and no longer reports the nonexistent symbol reference.
- The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs.
- The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed.
Explanation
Correct Answer
D:The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed. Provider schemas can require replacement for some attribute changes; plan review exposes this before an apply. It tests the correction: Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
Incorrect Answers
A:A reviewed apply changes only the intended managed attribute and the subsequent plan shows no unexpected pending action. This might validate workflow repeatability after configuration change, but it does not prove that plan distinguishes replacement from in-place update was resolved. Confirm instead: The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed.
B:Validation passes with the declared variable name and no longer reports the nonexistent symbol reference. This might validate terraform validate catches undeclared reference, but it does not prove that plan distinguishes replacement from in-place update was resolved. Confirm instead: The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed.
C:The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs. This might validate saved execution plan for controlled deployment, but it does not prove that plan distinguishes replacement from in-place update was resolved. Confirm instead: The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed.
Question 159
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A developer modifies a network tag but uses terraform init repeatedly, expecting initialization itself to apply the desired change to running resources. The change must preserve the distinction between previewing and modifying infrastructure. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
- Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
- Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
- Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
Explanation
Correct Answer
B:Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources. Initialization configures the working directory; applying an execution plan is what reconciles managed infrastructure with configuration. Confirm the cause with: Review the last plan and apply activity to distinguish provider initialization from planning and changing the managed resource. A concrete acceptance test is: A reviewed apply changes only the intended managed attribute and the subsequent plan shows no unexpected pending action.
Incorrect Answers
A: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 workflow repeatability after configuration change mechanism. The relevant fix is: Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
C:Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs. This could address apply requires approval unless automated, but it does not correct the indicated workflow repeatability after configuration change mechanism. The relevant fix is: Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
D:Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning. This could address terraform init backend and provider preparation, but it does not correct the indicated workflow repeatability after configuration change mechanism. The relevant fix is: Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
Question 160
During a governed HCP Terraform workspace rollout, the following condition occurs: A developer adds an HCP Terraform organization but the CLI still writes local state because no cloud workspace selection is configured. The organization must retain auditable authorization for runs and state. What measurable postchange observation would confirm that the correction worked?
- The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
- Plans and applies execute in the intended HCP run environment with centralized state and auditable run outcomes.
- An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution.
- The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities.
Explanation
Correct Answer
A:The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot. The cloud block binds a root configuration to HCP Terraform workspaces; merely naming an organization elsewhere is insufficient. It tests the correction: Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate.
Incorrect Answers
B:Plans and applies execute in the intended HCP run environment with centralized state and auditable run outcomes. This might validate hcp terraform remote execution and state hosting, but it does not prove that terraform cloud block hcp workspace integration was resolved. Confirm instead: The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
C:An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution. This might validate vcs-driven hcp terraform run on approved changes, but it does not prove that terraform cloud block hcp workspace integration was resolved. Confirm instead: The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
D:The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities. This might validate hcp terraform cli login and execution credentials, but it does not prove that terraform cloud block hcp workspace integration was resolved. Confirm instead: The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.