HashiCorp Terraform Associate 004 Practice Test 17
Question 160
During a governed HCP Terraform workspace rollout, the following condition occurs: A developer adds an HCP Terraform organization but the CLI still writes local state because no cloud workspace selection is configured. The organization must retain auditable authorization for runs and state. What measurable postchange observation would confirm that the correction worked?
- The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
- Plans and applies execute in the intended HCP run environment with centralized state and auditable run outcomes.
- An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution.
- The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities.
Explanation
Correct Answer
A:The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot. The cloud block binds a root configuration to HCP Terraform workspaces; merely naming an organization elsewhere is insufficient. It tests the correction: Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate.
Incorrect Answers
B:Plans and applies execute in the intended HCP run environment with centralized state and auditable run outcomes. This might validate hcp terraform remote execution and state hosting, but it does not prove that terraform cloud block hcp workspace integration was resolved. Confirm instead: The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
C:An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution. This might validate vcs-driven hcp terraform run on approved changes, but it does not prove that terraform cloud block hcp workspace integration was resolved. Confirm instead: The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
D:The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities. This might validate hcp terraform cli login and execution credentials, but it does not prove that terraform cloud block hcp workspace integration was resolved. Confirm instead: The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
Question 161
During a controlled module integration test for a production Terraform stack, the following condition occurs: A server requires a network subnet that Terraform creates in the same plan, but the author hardcodes the expected subnet name and gets an ordering error. The desired fix must avoid unrelated resource changes. What targeted engineering response should the team implement?
- Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration.
- Use the managed subnet resource's appropriate output attribute directly in the server configuration.
- Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
- Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values.
Explanation
Correct Answer
B:Use the managed subnet resource's appropriate output attribute directly in the server configuration. A reference to another resource attribute establishes an implicit graph dependency and avoids fragile guessed identifiers. Confirm the cause with: Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings. A concrete acceptance test is: Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays.
Incorrect Answers
A:Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration. This could address ephemeral variable for short-lived token in terraform 1.12, but it does not correct the indicated implicit dependency through resource attribute reference mechanism. The relevant fix is: Use the managed subnet resource's appropriate output attribute directly in the server configuration.
C: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 implicit dependency through resource attribute reference mechanism. The relevant fix is: Use the managed subnet resource's appropriate output attribute directly in the server configuration.
D:Mark secret-bearing outputs sensitive when appropriate, restrict state access, and avoid exposing secret material through ordinary output values. This could address sensitive output display behavior, but it does not correct the indicated implicit dependency through resource attribute reference mechanism. The relevant fix is: Use the managed subnet resource's appropriate output attribute directly in the server configuration.
Question 162
During a governed HCP Terraform workspace rollout, the following condition occurs: A platform team expects HCP Terraform to plan when its default branch changes, but the workspace is CLI-driven and no repository integration exists. The organization must retain auditable authorization for runs and state. Which outcome most directly validates the intended fix?
- Plans and applies execute in the intended HCP run environment with centralized state and auditable run outcomes.
- The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
- An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution.
- Contributors can collaborate on plans while unauthorized accounts cannot approve or apply production infrastructure changes.
Explanation
Correct Answer
C:An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution. VCS-driven HCP Terraform workflows respond to repository changes when the workspace is explicitly integrated with that source. It tests the correction: Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings.
Incorrect Answers
A:Plans and applies execute in the intended HCP run environment with centralized state and auditable run outcomes. This might validate hcp terraform remote execution and state hosting, but it does not prove that vcs-driven hcp terraform run on approved changes was resolved. Confirm instead: An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution.
B:The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot. This might validate terraform cloud block hcp workspace integration, but it does not prove that vcs-driven hcp terraform run on approved changes was resolved. Confirm instead: An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution.
D:Contributors can collaborate on plans while unauthorized accounts cannot approve or apply production infrastructure changes. This might validate hcp terraform team permissions and audit trail, but it does not prove that vcs-driven hcp terraform run on approved changes was resolved. Confirm instead: An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution.
Question 163
During a cross-platform infrastructure standardization exercise, the following condition occurs: An organization provisions one application's storage in one cloud and DNS in another by maintaining incompatible manual deployment procedures. The decision must preserve ownership and minimize undocumented changes. Which proposed remediation solves this failure without masking its cause?
- Require reviewed Terraform commits and corresponding plan evidence for production changes rather than console-only alterations.
- Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values.
- Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms.
- Encode the network and firewall resources in version-controlled Terraform and require a reviewed plan in the change process.
Explanation
Correct Answer
B:Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values. Terraform provides a common declarative language while providers translate configuration operations into target platform APIs. Confirm the cause with: Check whether each API integration has a Terraform provider and how dependencies pass resource attributes between configurations. A concrete acceptance test is: One reviewed workflow coordinates both cloud resources without pretending Terraform replaces the different underlying provider APIs.
Incorrect Answers
A:Require reviewed Terraform commits and corresponding plan evidence for production changes rather than console-only alterations. This could address version-controlled iac change auditing, but it does not correct the indicated multi-cloud providers under one terraform workflow mechanism. The relevant fix is: Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values.
C:Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms. This could address provider-neutral infrastructure pattern without identical resource types, but it does not correct the indicated multi-cloud providers under one terraform workflow mechanism. The relevant fix is: Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values.
D:Encode the network and firewall resources in version-controlled Terraform and require a reviewed plan in the change process. This could address terraform configuration as reviewable infrastructure specification, but it does not correct the indicated multi-cloud providers under one terraform workflow mechanism. The relevant fix is: Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values.
Question 164
As an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A team runs Terraform independently on laptops while its shared HCP Terraform workspace is intended to control remote plan and apply runs. The workflow must apply least privilege and preserve workspace isolation. Select TWO: the decisive first check and the change that directly addresses the problem.
- Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured.
- Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope.
- Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow.
- Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings.
- Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group.
Explanation
Correct Answers
A:Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured. HCP Terraform workspaces can coordinate Terraform runs and state, but a local directory is not automatically connected to one. A justified correction is: Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow. This forms one element of the required two-step diagnosis and correction.
C:Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow. HCP Terraform workspaces can coordinate Terraform runs and state, but a local directory is not automatically connected to one. Confirm the cause with: Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured. A concrete acceptance test is: Plans and applies execute in the intended HCP run environment with centralized state and auditable run outcomes. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope. This relates to hcp workspace variable sets share scoped configuration rather than the matching diagnosis-and-remediation pair required here. Check: Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured. Then change: Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow.
D: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 whether the root is connected to the correct HCP workspace and which execution mode is configured. Then change: Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow.
E:Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group. This relates to hcp projects group workspaces by ownership rather than the matching diagnosis-and-remediation pair required here. Check: Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured. Then change: Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow.
Question 165
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. What measurable postchange observation would confirm that the correction worked?
- The apply finishes after explicit approval and writes the updated resource bindings to the configured backend.
- A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions.
- The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed.
- Validation passes with the declared variable name and no longer reports the nonexistent symbol reference.
Explanation
Correct Answer
A:The apply finishes after explicit approval and writes the updated resource bindings to the configured backend. A normal interactive Terraform apply requires an approval decision; automating approval changes governance, not Terraform's reconciliation rules. It tests the correction: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
Incorrect Answers
B:A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions. This might validate targeted apply limitations for normal changes, but it does not prove that apply requires approval unless automated was resolved. Confirm instead: The apply finishes after explicit approval and writes the updated resource bindings to the configured backend.
C:The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed. This might validate plan distinguishes replacement from in-place update, but it does not prove that apply requires approval unless automated was resolved. Confirm instead: The apply finishes after explicit approval and writes the updated resource bindings to the configured backend.
D: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 apply requires approval unless automated was resolved. Confirm instead: The apply finishes after explicit approval and writes the updated resource bindings to the configured backend.
Question 166
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 diagnostic check provides the strongest evidence for the underlying problem?
- 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.
- Inspect which module arguments vary and whether stable application keys can drive repeated module instances.
- Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout.
Explanation
Correct Answer
D: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.
Incorrect Answers
A: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.
B: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.
C:Inspect which module arguments vary and whether stable application keys can drive repeated module instances. This inspects for_each at module call for multiple environments 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.
Question 167
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A team runs terraform plan against a long-lived environment and unexpectedly sees an outside-of-Terraform network tag change in the refreshed state. The operator must obtain auditable evidence before touching production resources. Which investigation would most directly establish the reported Terraform failure?
- Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
- Inspect refresh findings and compare remote attributes with the declared tag values before accepting a proposed remediation.
- Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order.
- Inspect whether the approved artifact was produced by terraform plan -out and whether apply consumes exactly that plan artifact.
Explanation
Correct Answer
B:Inspect refresh findings and compare remote attributes with the declared tag values before accepting a proposed remediation. Normal planning refreshes remote state by default and can reveal differences between real objects and tracked configuration. A justified correction is: Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy.
Incorrect Answers
A:Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. This inspects apply requires approval unless automated rather than the reported plan versus real infrastructure drift issue. The decisive investigation is: Inspect refresh findings and compare remote attributes with the declared tag values before accepting a proposed remediation.
C:Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. This inspects core write plan apply workflow order rather than the reported plan versus real infrastructure drift issue. The decisive investigation is: Inspect refresh findings and compare remote attributes with the declared tag values before accepting a proposed remediation.
D:Inspect whether the approved artifact was produced by terraform plan -out and whether apply consumes exactly that plan artifact. This inspects saved execution plan for controlled deployment rather than the reported plan versus real infrastructure drift issue. The decisive investigation is: Inspect refresh findings and compare remote attributes with the declared tag values before accepting a proposed remediation.
Question 168
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 should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope.
- 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 current HCP project assignments, workspace ownership patterns, and project/team permission boundaries.
Explanation
Correct Answer
D:Inspect current HCP project assignments, workspace ownership patterns, and project/team permission boundaries. HCP projects organize related workspaces and can simplify team governance without merging their independent state snapshots. A justified correction is: Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group.
Incorrect Answers
A: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 projects group workspaces by ownership issue. The decisive investigation is: Inspect current HCP project assignments, workspace ownership patterns, and project/team permission boundaries.
B: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 projects group workspaces by ownership issue. The decisive investigation is: Inspect current HCP project assignments, workspace ownership patterns, and project/team permission boundaries.
C:Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results. This inspects hcp terraform policy enforcement governance rather than the reported hcp projects group workspaces by ownership issue. The decisive investigation is: Inspect current HCP project assignments, workspace ownership patterns, and project/team permission boundaries.
Question 169
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An operator adds a Terraform check asserting that an HTTP service is healthy and expects a failed check to halt the same apply as a mandatory precondition. The engineer must respect declared resource contracts and data security boundaries. What targeted engineering response should the team implement?
- Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input.
- Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required.
- Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage.
- Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
Explanation
Correct Answer
D:Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports. Check blocks generally issue warnings rather than blocking applies; lifecycle conditions enforce resource pre/post invariants. Confirm the cause with: Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version. A concrete acceptance test is: A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
Incorrect Answers
A:Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input. This could address input variable custom validation rule, but it does not correct the indicated check block observability versus hard failure mechanism. The relevant fix is: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
B:Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required. This could address create_before_destroy lifecycle for availability, but it does not correct the indicated check block observability versus hard failure mechanism. The relevant fix is: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
C:Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage. This could address data source versus managed resource definition, but it does not correct the indicated check block observability versus hard failure mechanism. The relevant fix is: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
Question 170
During a controlled module integration test for a production Terraform stack, the following condition occurs: A shared Terraform module accepts CIDR strings and a malformed network input reaches provisioning before anyone notices it violates approved addressing conventions. The desired fix must avoid unrelated resource changes. Which investigation would most directly establish the reported Terraform failure?
- Inspect the variable declaration, resource schema, and stored state behavior for that password input.
- Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early.
- Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version.
- Inspect the child module output declarations and the root's module block name and available output values.
Explanation
Correct Answer
B:Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early. Custom variable validation enforces module input contracts before incorrect values reach resource creation. A justified correction is: Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input.
Incorrect Answers
A:Inspect the variable declaration, resource schema, and stored state behavior for that password input. This inspects sensitive variable does not erase state secrets rather than the reported input variable custom validation rule issue. The decisive investigation is: Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early.
C:Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version. This inspects check block observability versus hard failure rather than the reported input variable custom validation rule issue. The decisive investigation is: Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early.
D:Inspect the child module output declarations and the root's module block name and available output values. This inspects module output references across composition rather than the reported input variable custom validation rule issue. The decisive investigation is: Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early.