HashiCorp Terraform Associate 004 Practice Test 27
Question 260
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. Select TWO: the decisive first check and the change that directly addresses the problem.
- Use terraform validate to identify the invalid reference, correct the spelling, and rerun validation before planning.
- Reformat the affected .tf files using terraform fmt and rerun both style checking and validation independently.
- Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
- Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply.
- Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences.
Explanation
Correct Answers
C:Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes. terraform fmt standardizes syntax layout; it is not a validation of cloud permissions or a deployment action. Confirm the cause with: Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences. A concrete acceptance test is: Equivalent configuration is presented in consistent canonical formatting while the resource plan remains semantically unchanged. This forms one element of the required two-step diagnosis and correction.
E: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. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Use terraform validate to identify the invalid reference, correct the spelling, and rerun validation before planning. This relates to terraform validate catches undeclared reference rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences. Then change: Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
B: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 current HCL formatting and whether a standard terraform fmt check flags style-only differences. Then change: Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
D:Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply. This relates to terraform validate versus cloud permission testing rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the current HCL formatting and whether a standard terraform fmt check flags style-only differences. Then change: Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
Question 261
During an isolated staging rehearsal of the Terraform workflow, 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 operator must obtain auditable evidence before touching production resources. Which outcome most directly validates the intended fix?
- The working directory uses the approved remote backend and the existing managed resource bindings remain available without duplicate provisioning.
- The module source resolves and validation can analyze the combined configuration without manually copying code into the root directory.
- The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed.
- The next reviewed plan reflects a deliberate drift decision rather than automatically treating an outside change as approved.
Explanation
Correct Answer
C: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. This matters here because a database argument changes and Terraform shows a replacement action, but the change reviewer reads only the new….
Incorrect Answers
A: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 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:The module source resolves and validation can analyze the combined configuration without manually copying code into the root directory. This might validate module installation during initial setup, 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.
D:The next reviewed plan reflects a deliberate drift decision rather than automatically treating an outside change as approved. This might validate plan versus real infrastructure drift, 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 262
During an operational review of a Terraform state backend, the following condition occurs: Two engineers start applying changes to the same backend and one receives a state lock error; the second engineer proposes disabling locking to save time. The team must preserve managed-object identity and safe collaboration. Which proposed remediation solves this failure without masking its cause?
- Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID.
- 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.
- Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.
Explanation
Correct Answer
C:Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled. State locking serializes state-mutating operations and helps prevent lost updates from concurrent Terraform runs. Confirm the cause with: Inspect active runs and lock metadata to determine whether another legitimate operation owns the state lock. A concrete acceptance test is: Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot. This matters here because two engineers start applying changes to the same backend and one receives a state lock error; the second engineer….
Incorrect Answers
A:Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID. This could address force unlock requires stale-lock verification, but it does not correct the indicated state locking prevents concurrent writes mechanism. The relevant fix is: Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled. This matters here because two engineers start applying changes to the same backend and one receives a state lock error; the second engineer….
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 state locking prevents concurrent writes mechanism. The relevant fix is: Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled.
D:Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. This could address local backend path and exposure, but it does not correct the indicated state locking prevents concurrent writes mechanism. The relevant fix is: Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled.
Question 263
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An organization switches from local state to a remote backend, but its existing Terraform work directory still points to the former backend settings. The change must preserve the distinction between previewing and modifying infrastructure. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
- Inspect whether the approved artifact was produced by terraform plan -out and whether apply consumes exactly that plan artifact.
- Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed.
- Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
- Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
Explanation
Correct Answers
A:Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups. Changing backend configuration requires a deliberate reinitialization decision; a text edit alone does not migrate state safely. Confirm the cause with: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed. A concrete acceptance test is: The working directory uses the approved remote backend and the existing managed resource bindings remain available without duplicate provisioning. 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 organization….
C:Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed. Changing backend configuration requires a deliberate reinitialization decision; a text edit alone does not migrate state safely. A justified correction is: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups. This 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 organization….
Incorrect Answers
B:Inspect whether the approved artifact was produced by terraform plan -out and whether apply consumes exactly that plan artifact. This relates to saved execution plan for controlled deployment rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed. Then change: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
D:Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment. This relates to core write plan apply workflow order rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed. Then change: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
E:Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning. This relates to terraform init backend and provider preparation rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed. Then change: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An organization….
Question 264
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A CI pipeline generates a plan for review but later runs terraform apply without supplying the saved plan, allowing freshly computed changes that were not approved. The change must preserve the distinction between previewing and modifying infrastructure. Which outcome most directly validates the intended fix?
- The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs.
- The runner completes initialization and can calculate a plan using the intended backend and installed dependencies.
- The next reviewed plan reflects a deliberate drift decision rather than automatically treating an outside change as approved.
- The module source resolves and validation can analyze the combined configuration without manually copying code into the root directory.
Explanation
Correct Answer
A:The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs. An applied saved plan preserves the planned decisions at creation time; plan artifacts can hold secrets and require restricted storage. It tests the correction: Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content.
Incorrect Answers
B:The runner completes initialization and can calculate a plan using the intended backend and installed dependencies. This might validate terraform init backend and provider preparation, but it does not prove that saved execution plan for controlled deployment was resolved. Confirm instead: The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs.
C:The next reviewed plan reflects a deliberate drift decision rather than automatically treating an outside change as approved. This might validate plan versus real infrastructure drift, but it does not prove that saved execution plan for controlled deployment was resolved. Confirm instead: The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs.
D:The module source resolves and validation can analyze the combined configuration without manually copying code into the root directory. This might validate module installation during initial setup, but it does not prove that saved execution plan for controlled deployment was resolved. Confirm instead: The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs.
Question 265
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A Terraform project passes terraform validate, and a team assumes production create permissions and resource quotas are therefore confirmed. The operator must obtain auditable evidence before touching production resources. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Syntax mistakes fail validation while missing remote permission surfaces through its appropriate API interaction rather than being falsely certified.
- The working directory uses the approved remote backend and the existing managed resource bindings remain available without duplicate provisioning.
- Validation passes with the declared variable name and no longer reports the nonexistent symbol reference.
- A reviewed apply changes only the intended managed attribute and the subsequent plan shows no unexpected pending action.
Explanation
Correct Answer
A:Syntax mistakes fail validation while missing remote permission surfaces through its appropriate API interaction rather than being falsely certified. Terraform validate checks internal configuration validity, not complete remote authorization, quota availability, or deployment success. It tests the correction: Use terraform validate to catch configuration errors and separately run plan or controlled provider checks to assess remote feasibility. This matters here because a Terraform project passes terraform validate, and a team assumes production create permissions and resource quotas….
Incorrect Answers
B: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 terraform validate versus cloud permission testing was resolved. Confirm instead: Syntax mistakes fail validation while missing remote permission surfaces through its appropriate API interaction rather than being falsely certified.
C: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 terraform validate versus cloud permission testing was resolved. Confirm instead: Syntax mistakes fail validation while missing remote permission surfaces through its appropriate API interaction rather than being falsely certified. This matters here because a Terraform project passes terraform validate, and a team assumes production create permissions and resource quotas….
D: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 terraform validate versus cloud permission testing was resolved. Confirm instead: Syntax mistakes fail validation while missing remote permission surfaces through its appropriate API interaction rather than being falsely certified.
Question 266
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. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings.
- Review organization and workspace team roles, run permissions and audit records for sensitive environments.
- Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate.
- Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
- Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently.
Explanation
Correct Answers
C:Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate. The cloud block binds a root configuration to HCP Terraform workspaces; merely naming an organization elsewhere is insufficient. Confirm the cause with: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. A concrete acceptance test is: The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot. This forms one element of the required two-step diagnosis and correction.
D:Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. The cloud block binds a root configuration to HCP Terraform workspaces; merely naming an organization elsewhere is insufficient. A justified correction is: Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings. This relates to vcs-driven hcp terraform run on approved changes rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. Then change: Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate.
B:Review organization and workspace team roles, run permissions and audit records for sensitive environments. This relates to hcp terraform team permissions and audit trail rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. Then change: Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate.
E:Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently. This relates to hcp terraform cli login and execution credentials rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. Then change: Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate.
Question 267
As an infrastructure team integrates an existing repository with HCP Terraform, 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 workflow must apply least privilege and preserve workspace isolation. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
- Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources.
- Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope.
- Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers.
Explanation
Correct Answer
A:Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. The cloud block binds a root configuration to HCP Terraform workspaces; merely naming an organization elsewhere is insufficient. A justified correction is: Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate.
Incorrect Answers
B:Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources. This inspects hcp terraform cli login and execution credentials rather than the reported terraform cloud block hcp workspace integration issue. The decisive investigation is: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
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 terraform cloud block hcp workspace integration issue. The decisive investigation is: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
D: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 terraform cloud block hcp workspace integration issue. The decisive investigation is: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
Question 268
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A network module is upgraded and renames a child output, but dependent modules still read the old output and planning fails. The team must preserve reproducibility across callers. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Trace the token through module input/output declarations and identify any output that exposes secret data.
- Update the module version together with dependent output references and validate the full root configuration before applying.
- Add the intended child output declaration and access it through module.network.<output_name> in the caller.
- Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
- Compare the upgraded module's documented input/output contract to root references before approving the module version change.
Explanation
Correct Answers
B:Update the module version together with dependent output references and validate the full root configuration before applying. Module version changes can alter interfaces; compatibility is assessed across callers, not by module installation success alone. Confirm the cause with: Compare the upgraded module's documented input/output contract to root references before approving the module version change. A concrete acceptance test is: The root plan resolves the new module output names with no dangling references or unintended replacements. This forms one element of the required two-step diagnosis and correction.
E:Compare the upgraded module's documented input/output contract to root references before approving the module version change. Module version changes can alter interfaces; compatibility is assessed across callers, not by module installation success alone. A justified correction is: Update the module version together with dependent output references and validate the full root configuration before applying. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A: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: Compare the upgraded module's documented input/output contract to root references before approving the module version change. Then change: Update the module version together with dependent output references and validate the full root configuration before applying.
C:Add the intended child output declaration and access it through module.network.<output_name> in the caller. This relates to child output exposure to calling module rather than the matching diagnosis-and-remediation pair required here. Check: Compare the upgraded module's documented input/output contract to root references before approving the module version change. Then change: Update the module version together with dependent output references and validate the full root configuration before applying.
D:Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review. This relates to git module ref pin rather than floating main branch rather than the matching diagnosis-and-remediation pair required here. Check: Compare the upgraded module's documented input/output contract to root references before approving the module version change. Then change: Update the module version together with dependent output references and validate the full root configuration before applying.
Question 269
While diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: A legacy cloud object exists in the production account, but terraform import is executed with the default development provider and cannot locate its supplied ID. The investigator must avoid unreviewed state writes. Which outcome most directly validates the intended fix?
- The resource binds to the production object while no unexpected development object is created or modified.
- The logs identify the failing initialization or provider interaction and can be disabled after troubleshooting.
- The reviewer sees the requested resource's stored values while no import, state edit or remote mutation is performed.
- The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation.
Explanation
Correct Answer
A: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.
Incorrect Answers
B:The logs identify the failing initialization or provider interaction and can be disabled after troubleshooting. This might validate tf_log for troubleshooting provider and cli diagnostics, 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 reviewer sees the requested resource's stored values while no import, state edit or remote mutation is performed. This might validate state show inspects one stored resource instance, 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.
D: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.
Question 270
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. What acceptance evidence best establishes that the Terraform issue has been resolved?
- CLI output is appropriately redacted and the selected secret-handling path avoids unwanted persistent state exposure.
- Terraform reads the existing DNS zone information and plans no duplicate zone creation from the lookup alone.
- A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts.
- The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
Explanation
Correct Answer
A:CLI output is appropriately redacted and the selected secret-handling path avoids unwanted persistent state exposure. Sensitive marks typically hide values from normal display but do not inherently prevent their persistence in Terraform state. It tests the correction: Protect the backend and use supported ephemeral/write-only pathways when the provider exposes them rather than relying on sensitive alone.
Incorrect Answers
B:Terraform reads the existing DNS zone information and plans no duplicate zone creation from the lookup alone. This might validate data source versus managed resource definition, but it does not prove that sensitive variable does not erase state secrets was resolved. Confirm instead: CLI output is appropriately redacted and the selected secret-handling path avoids unwanted persistent state exposure.
C:A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts. This might validate ephemeral variable for short-lived token in terraform 1.12, but it does not prove that sensitive variable does not erase state secrets was resolved. Confirm instead: CLI output is appropriately redacted and the selected secret-handling path avoids unwanted persistent state exposure.
D:The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit. This might validate create_before_destroy lifecycle for availability, but it does not prove that sensitive variable does not erase state secrets was resolved. Confirm instead: CLI output is appropriately redacted and the selected secret-handling path avoids unwanted persistent state exposure.