HashiCorp Terraform Associate 004 Practice Test 58
Question 570
As the deployment team prepares a reviewed Terraform CLI change, 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 change must preserve the distinction between previewing and modifying infrastructure. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
- Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
- Reformat the affected .tf files using terraform fmt and rerun both style checking and validation independently.
- Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
- Inspect the module source declaration and initialization logs for the missing module download.
Explanation
Correct Answers
A:Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. A normal interactive Terraform apply requires an approval decision; automating approval changes governance, not Terraform's reconciliation rules. A justified correction is: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs. This forms one element of the required two-step diagnosis and correction. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An interactive….
D: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. This forms one element of the required two-step diagnosis and correction. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An interactive….
Incorrect Answers
B:Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment. This relates to targeted apply limitations for normal changes rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. Then change: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An interactive….
C:Reformat the affected.tf files using terraform fmt and rerun both style checking and validation independently. This relates to ci terraform fmt check distinguishes style from validity rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. Then change: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
E:Inspect the module source declaration and initialization logs for the missing module download. This relates to module installation during initial setup rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. Then change: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An interactive….
Question 571
During a governed HCP Terraform workspace rollout, the following condition occurs: A company creates production and staging workspaces for dozens of product teams in one flat list, and support staff cannot manage their permissions cleanly. The organization must retain auditable authorization for runs and state. What targeted engineering response should the team implement?
- Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values.
- Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group.
- Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently.
- Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level.
Explanation
Correct Answer
B:Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group. HCP projects organize related workspaces and can simplify team governance without merging their independent state snapshots. Confirm the cause with: Inspect current HCP project assignments, workspace ownership patterns, and project/team permission boundaries. A concrete acceptance test is: Teams locate and administer their approved workspaces without accidentally gaining access to unrelated project state.
Incorrect Answers
A:Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values. This could address hcp workspace variable sets share scoped configuration, but it does not correct the indicated hcp projects group workspaces by ownership mechanism. The relevant fix is: Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group.
C:Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently. This could address hcp terraform cli login and execution credentials, but it does not correct the indicated hcp projects group workspaces by ownership mechanism. The relevant fix is: Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group.
D:Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level. This could address hcp terraform policy enforcement governance, but it does not correct the indicated hcp projects group workspaces by ownership mechanism. The relevant fix is: Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group.
Question 572
When maintaining Terraform modules used by several application teams, 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 module interface must remain stable and reviewable. Which proposed remediation solves this failure without masking its cause?
- Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values.
- Set the source to an accurate local relative module path and initialize or validate from the correct root directory.
- Declare an input variable in the child module and pass the parent's value explicitly as a module argument.
- Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref.
Explanation
Correct Answer
D:Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. Terraform module source addresses can include a package subdirectory; the path after double slash identifies the module inside it. Confirm the cause with: Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. A concrete acceptance test is: Initialization selects the network module code from the intended repository path and revision rather than unrelated root files. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A monorepo….
Incorrect Answers
A:Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values. This could address module outputs coordinate dependencies instead of duplicate data, but it does not correct the indicated git module source with explicit subdirectory mechanism. The relevant fix is: Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref.
B:Set the source to an accurate local relative module path and initialize or validate from the correct root directory. This could address local child module source path resolution, but it does not correct the indicated git module source with explicit subdirectory mechanism. The relevant fix is: Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A monorepo….
C:Declare an input variable in the child module and pass the parent's value explicitly as a module argument. This could address root and child variable scope isolation, but it does not correct the indicated git module source with explicit subdirectory mechanism. The relevant fix is: Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. This matters here because when maintaining Terraform modules used by several application teams, the following condition occurs: A monorepo….
Question 573
While migrating a manually maintained development environment into reviewed Terraform configuration, the following condition occurs: A team needs to coordinate a local virtualization cluster with hosted cloud DNS and attempts to reuse a cloud API token for both providers. The team must establish a reproducible and auditable infrastructure change. What acceptance evidence best establishes that the Terraform issue has been resolved?
- A plan can cover both managed targets while each provider operates only within its authorized platform and permissions.
- One reviewed workflow coordinates both cloud resources without pretending Terraform replaces the different underlying provider APIs.
- An auditor can identify the approved commit and plan that caused a deliberate infrastructure capacity change.
- A clean environment can be reconstructed from the same reviewed configuration with repeatable managed resource attributes.
Explanation
Correct Answer
A:A plan can cover both managed targets while each provider operates only within its authorized platform and permissions. Hybrid Terraform management uses different provider plugins and credentials; one universal cloud credential is neither expected nor safe. It tests the correction: Configure separate authorized providers and identities for the hybrid environments while retaining a shared desired-state workflow.
Incorrect Answers
B:One reviewed workflow coordinates both cloud resources without pretending Terraform replaces the different underlying provider APIs. This might validate multi-cloud providers under one terraform workflow, but it does not prove that hybrid cloud workflow with distinct provider credentials was resolved. Confirm instead: A plan can cover both managed targets while each provider operates only within its authorized platform and permissions.
C:An auditor can identify the approved commit and plan that caused a deliberate infrastructure capacity change. This might validate version-controlled iac change auditing, but it does not prove that hybrid cloud workflow with distinct provider credentials was resolved. Confirm instead: A plan can cover both managed targets while each provider operates only within its authorized platform and permissions.
D:A clean environment can be reconstructed from the same reviewed configuration with repeatable managed resource attributes. This might validate declarative desired state versus imperative console runbook, but it does not prove that hybrid cloud workflow with distinct provider credentials was resolved. Confirm instead: A plan can cover both managed targets while each provider operates only within its authorized platform and permissions.
Question 574
During an operational review of a Terraform state backend, the following condition occurs: An engineer passes a remote state storage key through plaintext -backend-config arguments in a shared build log and assumes Terraform will never retain that key. The team must preserve managed-object identity and safe collaboration. 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.
- Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
- Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values.
- Check the selected backend's documentation for locking support and the actual concurrent-apply behavior.
- Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.
Explanation
Correct Answers
B:Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration. Backend configuration can be captured in Terraform working-directory metadata and plan files; secret-bearing arguments require extra care. Confirm the cause with: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. A concrete acceptance test is: Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs. This forms one element of the required two-step diagnosis and correction. This matters here because an engineer passes a remote state storage key through plaintext -backend-config arguments in a shared build log and….
C:Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. Backend configuration can be captured in Terraform working-directory metadata and plan files; secret-bearing arguments require extra care. A justified correction is: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration. This forms one element of the required two-step diagnosis and correction. This matters here because an engineer passes a remote state storage key through plaintext -backend-config arguments in a shared build log and….
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 backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. Then change: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration. This matters here because an engineer passes a remote state storage key through plaintext -backend-config arguments in a shared build log and….
D:Check the selected backend's documentation for locking support and the actual concurrent-apply behavior. This relates to backend-specific state locking support rather than the matching diagnosis-and-remediation pair required here. Check: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. Then change: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
E:Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. This relates to local backend path and exposure rather than the matching diagnosis-and-remediation pair required here. Check: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. Then change: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
Question 575
During a controlled module integration test for a production Terraform stack, the following condition occurs: A reusable module expects a region input but has no default, and a new caller assumes Terraform will infer a region from the module source. The desired fix must avoid unrelated resource changes. Select TWO: the decisive first check and the change that directly addresses the problem.
- Provide the required region input through the module call or a supported root variable assignment mechanism.
- Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
- Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early.
- Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value.
- Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
Explanation
Correct Answers
A:Provide the required region input through the module call or a supported root variable assignment mechanism. Input variables lacking defaults are required at the module boundary; module source addresses do not implicitly supply their values. Confirm the cause with: Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value. A concrete acceptance test is: The module plans with a deliberate region value rather than failing for a missing required input. This forms one element of the required two-step diagnosis and correction. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A….
D:Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value. Input variables lacking defaults are required at the module boundary; module source addresses do not implicitly supply their values. A justified correction is: Provide the required region input through the module call or a supported root variable assignment mechanism. This forms one element of the required two-step diagnosis and correction. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A….
Incorrect Answers
B:Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values. This relates to sensitive output display behavior rather than the matching diagnosis-and-remediation pair required here. Check: Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value. Then change: Provide the required region input through the module call or a supported root variable assignment mechanism.
C:Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early. This relates to input variable custom validation rule rather than the matching diagnosis-and-remediation pair required here. Check: Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value. Then change: Provide the required region input through the module call or a supported root variable assignment mechanism.
E:Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. This relates to for_each stable identity instead of count index rather than the matching diagnosis-and-remediation pair required here. Check: Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value. Then change: Provide the required region input through the module call or a supported root variable assignment mechanism.
Question 576
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. Which outcome most directly validates the intended fix?
- The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement.
- A plan in staging reads staging bindings while a default workspace plan remains independent.
- Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
- The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
Explanation
Correct Answer
A:The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement. Configuration address refactoring requires a state mapping; moved blocks declare that logical migration without recreating infrastructure. It tests the correction: 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: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 moved block preserves state during address refactor was resolved. Confirm instead: The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement.
C:Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs. This might validate backend credentials kept out of plan artifacts, but it does not prove that moved block preserves state during address refactor was resolved. Confirm instead: The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement. 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….
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 moved block preserves state during address refactor was resolved. Confirm instead: The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement.
Question 577
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. What targeted engineering response should the team implement?
- Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.
- Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled.
- Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change.
- 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.
Incorrect Answers
A:Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions. This could address remote backend block configuration, 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: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.
C:Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change. This could address refresh-only state update without infrastructure mutation, 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.
Question 578
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A repository is cloned into a new runner, and terraform plan fails before generating changes because the workspace has not initialized provider plugins or its backend. The change must preserve the distinction between previewing and modifying infrastructure. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- 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 module source declaration and initialization logs for the missing module download.
- Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply.
Explanation
Correct Answer
A:Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. The init command prepares backend configuration and downloads needed providers/modules; it does not create managed resources by itself. A justified correction is: Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
Incorrect Answers
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 terraform init backend and provider preparation issue. The decisive investigation is: Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup.
C:Inspect the module source declaration and initialization logs for the missing module download. This inspects module installation during initial setup rather than the reported terraform init backend and provider preparation issue. The decisive investigation is: Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup.
D:Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply. This inspects terraform validate versus cloud permission testing rather than the reported terraform init backend and provider preparation issue. The decisive investigation is: Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup.
Question 579
While diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: An existing managed network is defined in Terraform but has never been imported, so the next plan attempts to create a duplicate resource with an already-used name. The investigator must avoid unreviewed state writes. Which diagnostic check provides the strongest evidence for the underlying problem?
- Compare the declared resource address and remote identifier against the selected state snapshot.
- Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
- Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
- Inspect the resource's provider selection, active credentials and which account owns the remote object.
Explanation
Correct Answer
A:Compare the declared resource address and remote identifier against the selected state snapshot. Import establishes a state binding for a real object; it does not automatically infer or validate the complete HCL desired configuration. A justified correction is: Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan.
Incorrect Answers
B:Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. This inspects state list for tracking managed addresses rather than the reported terraform import binds preexisting remote object issue. The decisive investigation is: Compare the declared resource address and remote identifier against the selected state snapshot.
C: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 terraform import binds preexisting remote object issue. The decisive investigation is: Compare the declared resource address and remote identifier against the selected state snapshot.
D:Inspect the resource's provider selection, active credentials and which account owns the remote object. This inspects import source account and provider selection rather than the reported terraform import binds preexisting remote object issue. The decisive investigation is: Compare the declared resource address and remote identifier against the selected state snapshot.
Question 580
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: Two contributors produce equivalent Terraform expressions using inconsistent spacing and indentation, causing noisy reviews despite no actual infrastructure differences. The change must preserve the distinction between previewing and modifying infrastructure. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect Terraform diagnostic output for undeclared input references and compare declared variable names to expressions.
- Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics.
- Review the last plan and apply activity to distinguish provider initialization from planning and changing the managed resource.
- Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences.
Explanation
Correct Answer
D:Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences. terraform fmt standardizes syntax layout; it is not a validation of cloud permissions or a deployment action. A justified correction is: Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
Incorrect Answers
A:Inspect Terraform diagnostic output for undeclared input references and compare declared variable names to expressions. This inspects terraform validate catches undeclared reference rather than the reported terraform fmt normalizes hcl style issue. The decisive investigation is: Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences.
B:Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics. This inspects ci terraform fmt check distinguishes style from validity rather than the reported terraform fmt normalizes hcl style issue. The decisive investigation is: Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences.
C:Review the last plan and apply activity to distinguish provider initialization from planning and changing the managed resource. This inspects workflow repeatability after configuration change rather than the reported terraform fmt normalizes hcl style issue. The decisive investigation is: Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences.