HashiCorp Terraform Associate 004 Practice Test 80
Question 790
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A module declares a database password with sensitive = true but then stores it in a normal provider resource argument and claims the state snapshot contains no plaintext. 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.
- Protect the backend and use supported ephemeral/write-only pathways when the provider exposes them rather than relying on sensitive alone.
- Review input and output sensitivity declarations and inspect what the plan or output commands will display.
- Inspect the variable declaration, resource schema, and stored state behavior for that password input.
- Remove or update the overriding variable source and make the intended region input explicit for the controlled run.
- Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required.
Explanation
Correct Answers
A:Protect the backend and use supported ephemeral/write-only pathways when the provider exposes them rather than relying on sensitive alone. Sensitive marks typically hide values from normal display but do not inherently prevent their persistence in Terraform state. Confirm the cause with: Inspect the variable declaration, resource schema, and stored state behavior for that password input. A concrete acceptance test is: CLI output is appropriately redacted and the selected secret-handling path avoids unwanted persistent state exposure. 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 module….
C:Inspect the variable declaration, resource schema, and stored state behavior for that password input. Sensitive marks typically hide values from normal display but do not inherently prevent their persistence in Terraform state. A justified correction is: Protect the backend and use supported ephemeral/write-only pathways when the provider exposes them rather than relying on sensitive alone. 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 module….
Incorrect Answers
B:Review input and output sensitivity declarations and inspect what the plan or output commands will display. This relates to sensitive output display behavior rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the variable declaration, resource schema, and stored state behavior for that password input. Then change: Protect the backend and use supported ephemeral/write-only pathways when the provider exposes them rather than relying on sensitive alone.
D:Remove or update the overriding variable source and make the intended region input explicit for the controlled run. This relates to variable input precedence and configuration injection rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the variable declaration, resource schema, and stored state behavior for that password input. Then change: Protect the backend and use supported ephemeral/write-only pathways when the provider exposes them rather than relying on sensitive alone.
E:Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required. This relates to write-only provider argument for managed secret rotation rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the variable declaration, resource schema, and stored state behavior for that password input. Then change: Protect the backend and use supported ephemeral/write-only pathways when the provider exposes them rather than relying on sensitive alone. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A module….
Question 791
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A project intended to stay on a provider's version 5 releases but a broad >= 5.0 constraint unexpectedly selected a breaking 6.x release. The engineers must keep provider choices and identities reproducible. Which outcome most directly validates the intended fix?
- Routine initialization stays within the intended major version while explicit change review governs the next major update.
- Two clean checkouts select the reviewed compatible provider binaries rather than silently upgrading independently.
- The next plan recognizes existing managed object bindings and avoids duplicate creates for unchanged infrastructure.
- The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
Explanation
Correct Answer
A:Routine initialization stays within the intended major version while explicit change review governs the next major update. A lower-bound-only version constraint does not prevent future major releases; compatible-release constraints bound allowed versions. It tests the correction: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A project intended….
Incorrect Answers
B:Two clean checkouts select the reviewed compatible provider binaries rather than silently upgrading independently. This might validate dependency lock file reproducible selection, but it does not prove that provider version range semantics was resolved. Confirm instead: Routine initialization stays within the intended major version while explicit change review governs the next major update.
C:The next plan recognizes existing managed object bindings and avoids duplicate creates for unchanged infrastructure. This might validate state binding between resource address and remote object, but it does not prove that provider version range semantics was resolved. Confirm instead: Routine initialization stays within the intended major version while explicit change review governs the next major update.
D:The plan identifies production-account resources under the intended provider configuration while development objects remain separate. This might validate provider alias for multiple accounts, but it does not prove that provider version range semantics was resolved. Confirm instead: Routine initialization stays within the intended major version while explicit change review governs the next major update.
Question 792
During a controlled Terraform CLI recovery exercise, 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 same infrastructure must remain managed without unintended replacements. What acceptance evidence best establishes that the Terraform issue has been resolved?
- The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds.
- The resource binds to the production object while no unexpected development object is created or modified.
- The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation.
- The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract.
Explanation
Correct Answer
B:The resource binds to the production object while no unexpected development object is created or modified. Terraform import relies on a compatible provider configuration and correct remote identifier; IDs are interpreted in provider context. It tests the correction: Select the appropriate aliased provider configuration and import using the real identifier in its owning account. This matters here because a legacy cloud object exists in the production account, but terraform import is executed with the default….
Incorrect Answers
A:The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds. This might validate tf_log_path requires enabled logging, but it does not prove that import source account and provider selection was resolved. Confirm instead: The resource binds to the production object while no unexpected development object is created or modified.
C:The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation. This might validate terraform import binds preexisting remote object, but it does not prove that import source account and provider selection was resolved. Confirm instead: The resource binds to the production object while no unexpected development object is created or modified. This matters here because a legacy cloud object exists in the production account, but terraform import is executed with the default….
D:The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract. This might validate state list for tracking managed addresses, but it does not prove that import source account and provider selection was resolved. Confirm instead: The resource binds to the production object while no unexpected development object is created or modified.
Question 793
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team wants Terraform to stop managing a legacy storage bucket but must retain the real bucket and its contents for a migration. The change must preserve the distinction between previewing and modifying infrastructure. What measurable postchange observation would confirm that the correction worked?
- Validation passes with the declared variable name and no longer reports the nonexistent symbol reference.
- Only the intended disposable environment's managed objects are removed and shared production resources remain in separate state.
- The working directory uses the approved remote backend and the existing managed resource bindings remain available without duplicate provisioning.
- The state no longer tracks the bucket and verification confirms the remote bucket and data still exist.
Explanation
Correct Answer
D:The state no longer tracks the bucket and verification confirms the remote bucket and data still exist. Destroying a resource and removing a state binding are different operations with different effects on physical infrastructure. It tests the correction: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team wants….
Incorrect Answers
A: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 selective cleanup without destroying retained object was resolved. Confirm instead: The state no longer tracks the bucket and verification confirms the remote bucket and data still exist.
B: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 selective cleanup without destroying retained object was resolved. Confirm instead: The state no longer tracks the bucket and verification confirms the remote bucket and data still exist. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team wants….
C:The working directory uses the approved remote backend and the existing managed resource bindings remain available without duplicate provisioning. This might validate reinitializing after backend configuration change, but it does not prove that selective cleanup without destroying retained object was resolved. Confirm instead: The state no longer tracks the bucket and verification confirms the remote bucket and data still exist.
Question 794
During an operational review of a Terraform state backend, the following condition occurs: A Terraform engineer moves a resource from root to a child module and the next plan offers to destroy the old address and create the same remote object at a new address. The team must preserve managed-object identity and safe collaboration. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Compare old and new resource addresses and verify the provider object is the same logical managed resource.
- Inspect the backend configuration and state file location on each workstation to identify local state behavior.
- Inspect terraform plan -refresh-only and distinguish state/output updates from normal planned infrastructure modifications.
- Check the selected backend's documentation for locking support and the actual concurrent-apply behavior.
Explanation
Correct Answer
A:Compare old and new resource addresses and verify the provider object is the same logical managed resource. Configuration address refactoring requires a state mapping; moved blocks declare that logical migration without recreating infrastructure. A justified correction is: Add a moved block mapping the old address to the new address before running a reviewed plan. This matters here because a Terraform engineer moves a resource from root to a child module and the next plan offers to destroy the old….
Incorrect Answers
B:Inspect the backend configuration and state file location on each workstation to identify local state behavior. This inspects local backend path and exposure rather than the reported moved block preserves state during address refactor issue. The decisive investigation is: Compare old and new resource addresses and verify the provider object is the same logical managed resource. This matters here because a Terraform engineer moves a resource from root to a child module and the next plan offers to destroy the old….
C:Inspect terraform plan -refresh-only and distinguish state/output updates from normal planned infrastructure modifications. This inspects refresh-only state update without infrastructure mutation rather than the reported moved block preserves state during address refactor issue. The decisive investigation is: Compare old and new resource addresses and verify the provider object is the same logical managed resource.
D:Check the selected backend's documentation for locking support and the actual concurrent-apply behavior. This inspects backend-specific state locking support rather than the reported moved block preserves state during address refactor issue. The decisive investigation is: Compare old and new resource addresses and verify the provider object is the same logical managed resource.
Question 795
During a governed HCP Terraform workspace rollout, the following condition occurs: An organization wants to block infrastructure plans that violate approved tagging and region controls but relies solely on reviewers noticing violations manually. The organization must retain auditable authorization for runs and state. Which diagnostic check provides the strongest evidence for the underlying problem?
- Review organization and workspace team roles, run permissions and audit records for sensitive environments.
- Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
- Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope.
- Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
Explanation
Correct Answer
B:Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results. HCP Terraform policy as code can evaluate planned infrastructure against centralized governance rules before execution. A justified correction is: Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level. This matters here because an organization wants to block infrastructure plans that violate approved tagging and region controls but relies….
Incorrect Answers
A:Review organization and workspace team roles, run permissions and audit records for sensitive environments. This inspects hcp terraform team permissions and audit trail rather than the reported hcp terraform policy enforcement governance issue. The decisive investigation is: Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results. This matters here because an organization wants to block infrastructure plans that violate approved tagging and region controls but relies….
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 policy enforcement governance issue. The decisive investigation is: Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
D: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 policy enforcement governance issue. The decisive investigation is: Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
Question 796
During an operational review of a Terraform state backend, the following condition occurs: A Terraform apply exits unexpectedly and leaves a lock ID; an operator wants to run terraform force-unlock immediately without checking whether another run is active. The team must preserve managed-object identity and safe collaboration. Which Terraform configuration or workflow change most directly corrects the described issue?
- Select the intended workspace before planning and check the corresponding workspace-specific state directory.
- Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
- Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled.
- Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID.
Explanation
Correct Answer
D:Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID. Force-unlocking an active run can allow concurrent writers and damage state integrity; lock ownership must be verified. Confirm the cause with: Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking. A concrete acceptance test is: A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination. This matters here because a Terraform apply exits unexpectedly and leaves a lock ID; an operator wants to run terraform force-unlock….
Incorrect Answers
A:Select the intended workspace before planning and check the corresponding workspace-specific state directory. This could address local workspace state separation, but it does not correct the indicated force unlock requires stale-lock verification mechanism. The relevant fix is: Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID.
B: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 force unlock requires stale-lock verification mechanism. The relevant fix is: Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID.
C:Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled. This could address state locking prevents concurrent writes, but it does not correct the indicated force unlock requires stale-lock verification mechanism. The relevant fix is: Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID. This matters here because a Terraform apply exits unexpectedly and leaves a lock ID; an operator wants to run terraform force-unlock….
Question 797
During an operational review of a Terraform state backend, the following condition occurs: A team assumes a default Terraform directory automatically stores state in a centralized shared service, but every engineer sees their own terraform.tfstate file. The team must preserve managed-object identity and safe collaboration. What measurable postchange observation would confirm that the correction worked?
- Initialization connects to the intended workspace without conflicting backend configurations or unintended state copies.
- Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files.
- Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot.
- A plan in staging reads staging bindings while a default workspace plan remains independent.
Explanation
Correct Answer
B:Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files. The local backend persists state on the executing filesystem; it does not provide shared remote coordination by default. It tests the correction: Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. This matters here because a team assumes a default Terraform directory automatically stores state in a centralized shared service, but every….
Incorrect Answers
A:Initialization connects to the intended workspace without conflicting backend configurations or unintended state copies. This might validate hcp cloud integration versus remote backend, but it does not prove that local backend path and exposure was resolved. Confirm instead: Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files.
C:Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot. This might validate state locking prevents concurrent writes, but it does not prove that local backend path and exposure was resolved. Confirm instead: Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files.
D: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 local backend path and exposure was resolved. Confirm instead: Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files. This matters here because a team assumes a default Terraform directory automatically stores state in a centralized shared service, but every….
Question 798
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A monorepo contains many Terraform modules, but a root module downloads the entire Git repository as though its desired network child module lives at repository root. The team must preserve reproducibility across callers. Which investigation would most directly establish the reported Terraform failure?
- Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout.
- Inspect the parent composition and whether the network child provides an output representing the created subnet.
- Inspect the child module's variable declarations and the arguments passed by its calling module block.
- Inspect the module source value and the repository layout relative to the directory containing the calling module.
Explanation
Correct Answer
A:Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. Terraform module source addresses can include a package subdirectory; the path after double slash identifies the module inside it. A justified correction is: Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
Incorrect Answers
B: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 git module source with explicit subdirectory issue. The decisive investigation is: Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout.
C:Inspect the child module's variable declarations and the arguments passed by its calling module block. This inspects root and child variable scope isolation rather than the reported git module source with explicit subdirectory issue. The decisive investigation is: Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
D:Inspect the module source value and the repository layout relative to the directory containing the calling module. This inspects local child module source path resolution rather than the reported git module source with explicit subdirectory issue. The decisive investigation is: Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
Question 799
During a controlled module integration test for a production Terraform stack, the following condition occurs: A root configuration needs a child module's generated network ID but accesses an internal child resource name directly and fails to resolve it. The desired fix must avoid unrelated resource changes. Which proposed remediation solves this failure without masking its cause?
- Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
- Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
- Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
- Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
Explanation
Correct Answer
C:Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root. Modules expose values to callers through output declarations, creating an explicit interface between implementation and consumers. Confirm the cause with: Inspect the child module output declarations and the root's module block name and available output values. A concrete acceptance test is: The root plan resolves the supported module output without attempting to address private child resource internals. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A root….
Incorrect Answers
A:Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource. This could address resource precondition for unsafe configuration, but it does not correct the indicated module output references across composition mechanism. The relevant fix is: Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A root….
B:Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere. This could address collection references for for_each resources, but it does not correct the indicated module output references across composition mechanism. The relevant fix is: Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
D:Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. This could address map versus list addressing for environment inputs, but it does not correct the indicated module output references across composition mechanism. The relevant fix is: Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
Question 800
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A Terraform apply exits unexpectedly and leaves a lock ID; an operator wants to run terraform force-unlock immediately without checking whether another run is active. The operation must not delete or duplicate existing production objects. Which outcome most directly validates the intended fix?
- A plan in staging reads staging bindings while a default workspace plan remains independent.
- A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination.
- Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot.
- The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
Explanation
Correct Answer
B:A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination. Force-unlocking an active run can allow concurrent writers and damage state integrity; lock ownership must be verified. It tests the correction: Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A Terraform apply….
Incorrect Answers
A: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 force unlock requires stale-lock verification was resolved. Confirm instead: A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A Terraform apply….
C:Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot. This might validate state locking prevents concurrent writes, but it does not prove that force unlock requires stale-lock verification was resolved. Confirm instead: A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination.
D:The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation. This might validate refresh-only state update without infrastructure mutation, but it does not prove that force unlock requires stale-lock verification was resolved. Confirm instead: A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination.