HashiCorp Terraform Associate 004 Practice Test 15
Question 140
During an operational review of a Terraform state backend, the following condition occurs: An administrator intentionally changes a provider-computed tag outside Terraform and wants the tracked state to reflect reality without reverting any remote resource. The team must preserve managed-object identity and safe collaboration. What measurable postchange observation would confirm that the correction worked?
- The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
- A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination.
- The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit.
- Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
Explanation
Correct Answer
A:The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation. Refresh-only mode reconciles tracked state with observed infrastructure; normal apply may instead modify infrastructure to match configuration. It tests the correction: Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change.
Incorrect Answers
B:A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination. This might validate force unlock requires stale-lock verification, but it does not prove that refresh-only state update without infrastructure mutation was resolved. Confirm instead: The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
C:The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit. This might validate out-of-band drift detection in managed resource, but it does not prove that refresh-only state update without infrastructure mutation was resolved. Confirm instead: The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
D: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 refresh-only state update without infrastructure mutation was resolved. Confirm instead: The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
Question 141
During a controlled module integration test for a production Terraform stack, the following condition occurs: An engineer creates three storage resources using for_each but later reads a bare resource attribute as though the declaration has a single instance. The desired fix must avoid unrelated resource changes. Which investigation would most directly establish the reported Terraform failure?
- Inspect the repository for embedded secrets and review supported Vault provider/ephemeral integration and token access policy.
- Inspect the child module output declarations and the root's module block name and available output values.
- Identify the policy invariant and the resource lifecycle point where it should be checked before provisioning.
- Check the for_each keys and the collection shape of the declared resource instances.
Explanation
Correct Answer
D:Check the for_each keys and the collection shape of the declared resource instances. for_each produces keyed instances whose attributes must be accessed by their instance keys or collected expressions. A justified correction is: Index the intended instance by key or construct a mapped collection of instance attributes before passing them elsewhere.
Incorrect Answers
A:Inspect the repository for embedded secrets and review supported Vault provider/ephemeral integration and token access policy. This inspects vault credential lookup without hardcoding secret values rather than the reported collection references for for_each resources issue. The decisive investigation is: Check the for_each keys and the collection shape of the declared resource instances.
B: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 collection references for for_each resources issue. The decisive investigation is: Check the for_each keys and the collection shape of the declared resource instances.
C:Identify the policy invariant and the resource lifecycle point where it should be checked before provisioning. This inspects resource precondition for unsafe configuration rather than the reported collection references for for_each resources issue. The decisive investigation is: Check the for_each keys and the collection shape of the declared resource instances.
Question 142
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 should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state.
- Compare old and new resource addresses and verify the provider object is the same logical managed resource.
- Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking.
- Check the selected backend's documentation for locking support and the actual concurrent-apply behavior.
Explanation
Correct Answer
C:Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking. Force-unlocking an active run can allow concurrent writers and damage state integrity; lock ownership must be verified. A justified correction is: Use terraform force-unlock only after confirming the lock is stale and specifying its correct lock ID.
Incorrect Answers
A:Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. This inspects local workspace state separation rather than the reported force unlock requires stale-lock verification issue. The decisive investigation is: Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking.
B:Compare old and new resource addresses and verify the provider object is the same logical managed resource. This inspects moved block preserves state during address refactor rather than the reported force unlock requires stale-lock verification issue. The decisive investigation is: Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking.
D:Check the selected backend's documentation for locking support and the actual concurrent-apply behavior. This inspects backend-specific state locking support rather than the reported force unlock requires stale-lock verification issue. The decisive investigation is: Inspect backend state lock records, the lock identifier, and the status of any still-running apply before unlocking.
Question 143
During a cross-platform infrastructure standardization exercise, the following condition occurs: A team cannot explain who enlarged production compute capacity because engineers edit cloud resources without changes to an auditable repository. The decision must preserve ownership and minimize undocumented changes. What acceptance evidence best establishes that the Terraform issue has been resolved?
- New staging environments satisfy common access requirements while explicit input values account for documented environment differences.
- A clean environment can be reconstructed from the same reviewed configuration with repeatable managed resource attributes.
- An auditor can identify the approved commit and plan that caused a deliberate infrastructure capacity change.
- A plan can cover both managed targets while each provider operates only within its authorized platform and permissions.
Explanation
Correct Answer
C:An auditor can identify the approved commit and plan that caused a deliberate infrastructure capacity change. IaC enables reproducible review and history when configuration is versioned and the apply workflow is controlled. It tests the correction: Require reviewed Terraform commits and corresponding plan evidence for production changes rather than console-only alterations.
Incorrect Answers
A:New staging environments satisfy common access requirements while explicit input values account for documented environment differences. This might validate reusable environment definitions and reduced configuration drift, but it does not prove that version-controlled iac change auditing was resolved. Confirm instead: An auditor can identify the approved commit and plan that caused a deliberate infrastructure capacity change.
B: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 version-controlled iac change auditing was resolved. Confirm instead: An auditor can identify the approved commit and plan that caused a deliberate infrastructure capacity change.
D:A plan can cover both managed targets while each provider operates only within its authorized platform and permissions. This might validate hybrid cloud workflow with distinct provider credentials, but it does not prove that version-controlled iac change auditing was resolved. Confirm instead: An auditor can identify the approved commit and plan that caused a deliberate infrastructure capacity change.
Question 144
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A Terraform configuration changes a resource to for_each and a team still refers to the unkeyed address, causing an invalid reference or planned replacement. The engineer must respect declared resource contracts and data security boundaries. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first.
- Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value.
- Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration.
- Inspect the graph references and whether the data source must wait for a managed resource's creation.
Explanation
Correct Answer
C:Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. Repeated resources have instance addresses that include their keys or indexes, rather than a single unqualified instance address. A justified correction is: Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A Terraform….
Incorrect Answers
A:Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first. This inspects explicit depends_on for behavior-only dependencies rather than the reported resource addressing with repeated instances issue. The decisive investigation is: Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration.
B:Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value. This inspects variable default versus required input rather than the reported resource addressing with repeated instances issue. The decisive investigation is: Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration.
D:Inspect the graph references and whether the data source must wait for a managed resource's creation. This inspects data source read ordering versus creation rather than the reported resource addressing with repeated instances issue. The decisive investigation is: Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A Terraform….
Question 145
During a controlled module integration test for a production Terraform stack, the following condition occurs: A list of application names drives count-based resources, and removing one name shifts indices so Terraform plans to replace unrelated applications. The desired fix must avoid unrelated resource changes. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Inspect state instance addresses and compare count positions against stable business keys.
- Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
- Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
- Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema.
- Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
Explanation
Correct Answers
A:Inspect state instance addresses and compare count positions against stable business keys. Count identifies instances by numeric position, while for_each keys can preserve stable identity across list ordering changes. A justified correction is: Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. This forms one element of the required two-step diagnosis and correction.
E:Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. Count identifies instances by numeric position, while for_each keys can preserve stable identity across list ordering changes. Confirm the cause with: Inspect state instance addresses and compare count positions against stable business keys. A concrete acceptance test is: Removing one application plans its own deletion without shifting unrelated resource instances to new indexes. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root. This relates to module output references across composition rather than the matching diagnosis-and-remediation pair required here. Check: Inspect state instance addresses and compare count positions against stable business keys. Then change: Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
C:Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module. This relates to conditional expressions for environment configuration rather than the matching diagnosis-and-remediation pair required here. Check: Inspect state instance addresses and compare count positions against stable business keys. Then change: Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
D:Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema. This relates to data source versus managed resource definition rather than the matching diagnosis-and-remediation pair required here. Check: Inspect state instance addresses and compare count positions against stable business keys. Then change: Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
Question 146
As an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: An organization wants to block infrastructure plans that violate approved tagging and region controls but relies solely on reviewers noticing violations manually. The workflow must apply least privilege and preserve workspace isolation. Which investigation would most directly establish the reported Terraform failure?
- Review organization and workspace team roles, run permissions and audit records for sensitive environments.
- Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources.
- Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured.
- Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
Explanation
Correct Answer
D:Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results. HCP Terraform policy as code can evaluate planned infrastructure against centralized governance rules before execution. A justified correction is: Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level.
Incorrect Answers
A:Review organization and workspace team roles, run permissions and audit records for sensitive environments. This inspects hcp terraform team permissions and audit trail rather than the reported hcp terraform policy enforcement governance issue. The decisive investigation is: Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
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 hcp terraform policy enforcement governance issue. The decisive investigation is: Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
C:Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured. This inspects hcp terraform remote execution and state hosting rather than the reported hcp terraform policy enforcement governance issue. The decisive investigation is: Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
Question 147
During a controlled module integration test for a production Terraform stack, the following condition occurs: A root configuration needs a child module's generated network ID but accesses an internal child resource name directly and fails to resolve it. The desired fix must avoid unrelated resource changes. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Identical approved inputs yield consistent resource names and tags without operator-specific manual spelling fixes.
- The plan orders the policy attachment before the application service, and the service no longer races its prerequisite.
- The root plan resolves the supported module output without attempting to address private child resource internals.
- Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays.
Explanation
Correct Answer
C:The root plan resolves the supported module output without attempting to address private child resource internals. Modules expose values to callers through output declarations, creating an explicit interface between implementation and consumers. It tests the correction: Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
Incorrect Answers
A:Identical approved inputs yield consistent resource names and tags without operator-specific manual spelling fixes. This might validate built-in functions for deterministic naming, but it does not prove that module output references across composition was resolved. Confirm instead: The root plan resolves the supported module output without attempting to address private child resource internals.
B:The plan orders the policy attachment before the application service, and the service no longer races its prerequisite. This might validate explicit depends_on for behavior-only dependencies, but it does not prove that module output references across composition was resolved. Confirm instead: The root plan resolves the supported module output without attempting to address private child resource internals.
D:Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays. This might validate implicit dependency through resource attribute reference, but it does not prove that module output references across composition was resolved. Confirm instead: The root plan resolves the supported module output without attempting to address private child resource internals.
Question 148
During a controlled Terraform CLI recovery exercise, the following condition occurs: An organization adopts hundreds of existing resources using ad hoc CLI import commands that are absent from code review and difficult to reproduce. The same infrastructure must remain managed without unintended replacements. Which outcome most directly validates the intended fix?
- The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds.
- The resource binds to the production object while no unexpected development object is created or modified.
- The reviewer sees the requested resource's stored values while no import, state edit or remote mutation is performed.
- The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source.
Explanation
Correct Answer
D:The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source. Configuration-driven import blocks can make existing-resource adoption repeatable and part of a reviewed execution plan. It tests the correction: Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
Incorrect Answers
A:The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds. This might validate tf_log_path requires enabled logging, but it does not prove that import blocks for reproducible adoption workflow was resolved. Confirm instead: The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source.
B:The resource binds to the production object while no unexpected development object is created or modified. This might validate import source account and provider selection, but it does not prove that import blocks for reproducible adoption workflow was resolved. Confirm instead: The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source.
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 blocks for reproducible adoption workflow was resolved. Confirm instead: The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source.
Question 149
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: An inherited Terraform configuration references a provider without declaring its registry source, so a team cannot reliably establish which plugin will manage resources. The engineers must keep provider choices and identities reproducible. Which outcome most directly validates the intended fix?
- Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure.
- Routine initialization stays within the intended major version while explicit change review governs the next major update.
- Terraform resolves the intended plugin source consistently instead of relying on historical default namespace guesses.
- The same initialized provider can read the required resource metadata using an approved identity and the access-denied error disappears.
Explanation
Correct Answer
C:Terraform resolves the intended plugin source consistently instead of relying on historical default namespace guesses. The required_providers mapping identifies the plugin source and compatibility constraint, separate from provider authentication settings. It tests the correction: Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: An inherited….
Incorrect Answers
A:Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure. This might validate state as sensitive operational metadata, but it does not prove that provider source requirement declaration was resolved. Confirm instead: Terraform resolves the intended plugin source consistently instead of relying on historical default namespace guesses.
B:Routine initialization stays within the intended major version while explicit change review governs the next major update. This might validate provider version range semantics, but it does not prove that provider source requirement declaration was resolved. Confirm instead: Terraform resolves the intended plugin source consistently instead of relying on historical default namespace guesses.
D:The same initialized provider can read the required resource metadata using an approved identity and the access-denied error disappears. This might validate provider authorization versus installation failure, but it does not prove that provider source requirement declaration was resolved. Confirm instead: Terraform resolves the intended plugin source consistently instead of relying on historical default namespace guesses.
Question 150
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A project stores a state file in a developer's home directory even though multiple engineers need consistent shared planning and state history. The operation must not delete or duplicate existing production objects. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Use one supported state integration for the root; choose the cloud block when adopting HCP Terraform's integrated workflow.
- Inspect the current terraform backend declaration and permissions for the selected shared backend service.
- Inspect the backend configuration and state file location on each workstation to identify local state behavior.
- Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled.
- Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.
Explanation
Correct Answers
B:Inspect the current terraform backend declaration and permissions for the selected shared backend service. Terraform backend configuration selects where state snapshots are stored; migrating them requires careful initialization and authorization. A justified correction is: Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions. This forms one element of the required two-step diagnosis and correction.
E:Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions. Terraform backend configuration selects where state snapshots are stored; migrating them requires careful initialization and authorization. Confirm the cause with: Inspect the current terraform backend declaration and permissions for the selected shared backend service. A concrete acceptance test is: Team plans use the same access-controlled state backend after migration without duplicating existing managed objects. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Use one supported state integration for the root; choose the cloud block when adopting HCP Terraform's integrated workflow. This relates to hcp cloud integration versus remote backend rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the current terraform backend declaration and permissions for the selected shared backend service. Then change: Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.
C:Inspect the backend configuration and state file location on each workstation to identify local state behavior. This relates to local backend path and exposure rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the current terraform backend declaration and permissions for the selected shared backend service. Then change: Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.
D:Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled. This relates to state locking prevents concurrent writes rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the current terraform backend declaration and permissions for the selected shared backend service. Then change: Declare a supported backend block with a reviewed storage location, then initialize and migrate state under controlled conditions.