HashiCorp Terraform Associate 004 Practice Test 7
Question 60
When maintaining Terraform modules used by several application teams, the following condition occurs: A platform team copies the same network resource blocks into six application roots, and changes to security requirements require editing all six independently. The module interface must remain stable and reviewable. Which investigation would most directly establish the reported Terraform failure?
- Inspect the parent composition and whether the network child provides an output representing the created subnet.
- Identify common resource groups and the controlled parameters that vary by application team.
- Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout.
- Inspect the child module's output blocks and root expressions that refer to module.network values.
Explanation
Correct Answer
B:Identify common resource groups and the controlled parameters that vary by application team. Terraform modules package related resource definitions into reusable components without requiring one shared state for every consumer. A justified correction is: Create a reusable child module with a documented input/output contract and call it from each application's root module.
Incorrect Answers
A:Inspect the parent composition and whether the network child provides an output representing the created subnet. This inspects module outputs coordinate dependencies instead of duplicate data rather than the reported module blocks reuse standard infrastructure patterns issue. The decisive investigation is: Identify common resource groups and the controlled parameters that vary by application team.
C:Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. This inspects git module source with explicit subdirectory rather than the reported module blocks reuse standard infrastructure patterns issue. The decisive investigation is: Identify common resource groups and the controlled parameters that vary by application team.
D:Inspect the child module's output blocks and root expressions that refer to module.network values. This inspects child output exposure to calling module rather than the reported module blocks reuse standard infrastructure patterns issue. The decisive investigation is: Identify common resource groups and the controlled parameters that vary by application team.
Question 61
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. What measurable postchange observation would confirm that the correction worked?
- Routine Terraform output suppresses the marked secret while protected state access remains restricted.
- Development and production plan different approved retention settings with otherwise shared definitions and no copied modules.
- Terraform reads the existing DNS zone information and plans no duplicate zone creation from the lookup alone.
- Removing one application plans its own deletion without shifting unrelated resource instances to new indexes.
Explanation
Correct Answer
D:Removing one application plans its own deletion without shifting unrelated resource instances to new indexes. Count identifies instances by numeric position, while for_each keys can preserve stable identity across list ordering changes. It tests the correction: Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
Incorrect Answers
A:Routine Terraform output suppresses the marked secret while protected state access remains restricted. This might validate sensitive output display behavior, but it does not prove that for_each stable identity instead of count index was resolved. Confirm instead: Removing one application plans its own deletion without shifting unrelated resource instances to new indexes.
B:Development and production plan different approved retention settings with otherwise shared definitions and no copied modules. This might validate conditional expressions for environment configuration, but it does not prove that for_each stable identity instead of count index was resolved. Confirm instead: Removing one application plans its own deletion without shifting unrelated resource instances to new indexes.
C: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 for_each stable identity instead of count index was resolved. Confirm instead: Removing one application plans its own deletion without shifting unrelated resource instances to new indexes.
Question 62
When maintaining Terraform modules used by several application teams, the following condition occurs: A root Terraform stack tries to consume a network ID that the child module computes but does not publish as an output. The module interface must remain stable and reviewable. Select TWO: the decisive first check and the change that directly addresses the problem.
- Inspect the child module's output blocks and root expressions that refer to module.network values.
- Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs.
- Check the module source address, allowed version range and current module selections from initialization.
- Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values.
- Add the intended child output declaration and access it through module.network.<output_name> in the caller.
Explanation
Correct Answers
A:Inspect the child module's output blocks and root expressions that refer to module.network values. Output values are the supported way for a module to expose results to its parent; ordinary child locals are not exported. A justified correction is: Add the intended child output declaration and access it through module.network.<output_name> in the caller. This forms one element of the required two-step diagnosis and correction.
E:Add the intended child output declaration and access it through module.network.<output_name> in the caller. Output values are the supported way for a module to expose results to its parent; ordinary child locals are not exported. Confirm the cause with: Inspect the child module's output blocks and root expressions that refer to module.network values. A concrete acceptance test is: The caller can reference the exact authorized network ID without using private child implementation resource addresses. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs. This relates to sensitive input forwarding between nested modules rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the child module's output blocks and root expressions that refer to module.network values. Then change: Add the intended child output declaration and access it through module.network.<output_name> in the caller.
C:Check the module source address, allowed version range and current module selections from initialization. This relates to registry module version pin to avoid breaking releases rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the child module's output blocks and root expressions that refer to module.network values. Then change: Add the intended child output declaration and access it through module.network.<output_name> in the caller.
D:Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values. This relates to module outputs coordinate dependencies instead of duplicate data rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the child module's output blocks and root expressions that refer to module.network values. Then change: Add the intended child output declaration and access it through module.network.<output_name> in the caller.
Question 63
During an operational review of a Terraform state backend, the following condition occurs: A team assumes a default Terraform directory automatically stores state in a centralized shared service, but every engineer sees their own terraform.tfstate file. The team must preserve managed-object identity and safe collaboration. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Select the intended workspace before planning and check the corresponding workspace-specific state directory.
- Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.
- Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change.
- Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace.
- Inspect the backend configuration and state file location on each workstation to identify local state behavior.
Explanation
Correct Answers
B:Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. The local backend persists state on the executing filesystem; it does not provide shared remote coordination by default. Confirm the cause with: Inspect the backend configuration and state file location on each workstation to identify local state behavior. A concrete acceptance test is: Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files. This forms one element of the required two-step diagnosis and correction.
E:Inspect the backend configuration and state file location on each workstation to identify local state behavior. The local backend persists state on the executing filesystem; it does not provide shared remote coordination by default. A justified correction is: Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Select the intended workspace before planning and check the corresponding workspace-specific state directory. This relates to local workspace state separation rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the backend configuration and state file location on each workstation to identify local state behavior. Then change: Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.
C:Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change. This relates to refresh-only state update without infrastructure mutation rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the backend configuration and state file location on each workstation to identify local state behavior. Then change: Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.
D:Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace. This relates to hcp cloud integration versus remote backend rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the backend configuration and state file location on each workstation to identify local state behavior. Then change: Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.
Question 64
During a controlled Terraform CLI recovery exercise, the following condition occurs: An operator sets TF_LOG_PATH to an output file but receives no detailed diagnostics because Terraform logging was never enabled. The same infrastructure must remain managed without unintended replacements. What measurable postchange observation would confirm that the correction worked?
- The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds.
- The logs identify the failing initialization or provider interaction and can be disabled after troubleshooting.
- The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source.
- The resource binds to the production object while no unexpected development object is created or modified.
Explanation
Correct Answer
A:The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds. TF_LOG_PATH selects a log destination but must be paired with an enabled TF_LOG level to produce verbose logs. It tests the correction: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
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 tf_log_path requires enabled logging was resolved. Confirm instead: The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds.
C:The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source. This might validate import blocks for reproducible adoption workflow, but it does not prove that tf_log_path requires enabled logging was resolved. Confirm instead: The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds.
D: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 tf_log_path requires enabled logging was resolved. Confirm instead: The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds.
Question 65
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A Terraform project uses the same cloud provider in development and production accounts but a resource unexpectedly lands in the default development account. The engineers must keep provider choices and identities reproducible. Which proposed remediation solves this failure without masking its cause?
- Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly.
- Recover the correct protected state snapshot or deliberately import existing objects before applying destructive duplicate provisioning.
- Define explicitly aliased provider configurations and assign the production resource to the intended alias.
- Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
Explanation
Correct Answer
C:Define explicitly aliased provider configurations and assign the production resource to the intended alias. A provider alias selects an alternate configured provider instance; resource blocks must reference it to avoid a default-account fallback. Confirm the cause with: Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration. A concrete acceptance test is: The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
Incorrect Answers
A:Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly. This could address multiple provider instances requiring separate authentication, but it does not correct the indicated provider alias for multiple accounts mechanism. The relevant fix is: Define explicitly aliased provider configurations and assign the production resource to the intended alias.
B:Recover the correct protected state snapshot or deliberately import existing objects before applying destructive duplicate provisioning. This could address state binding between resource address and remote object, but it does not correct the indicated provider alias for multiple accounts mechanism. The relevant fix is: Define explicitly aliased provider configurations and assign the production resource to the intended alias.
D:Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. This could address provider version range semantics, but it does not correct the indicated provider alias for multiple accounts mechanism. The relevant fix is: Define explicitly aliased provider configurations and assign the production resource to the intended alias.
Question 66
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team wants Terraform to stop managing a legacy storage bucket but must retain the real bucket and its contents for a migration. The change must preserve the distinction between previewing and modifying infrastructure. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
- Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
- Reformat the affected .tf files using terraform fmt and rerun both style checking and validation independently.
- Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
Explanation
Correct Answer
A:Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. Destroying a resource and removing a state binding are different operations with different effects on physical infrastructure. Confirm the cause with: Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. A concrete acceptance test is: The state no longer tracks the bucket and verification confirms the remote bucket and data still exist.
Incorrect Answers
B:Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. This could address terraform destroy is managed-scope deletion, but it does not correct the indicated selective cleanup without destroying retained object mechanism. The relevant fix is: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
C:Reformat the affected.tf files using terraform fmt and rerun both style checking and validation independently. This could address ci terraform fmt check distinguishes style from validity, but it does not correct the indicated selective cleanup without destroying retained object mechanism. The relevant fix is: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
D:Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment. This could address targeted apply limitations for normal changes, but it does not correct the indicated selective cleanup without destroying retained object mechanism. The relevant fix is: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
Question 67
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 Terraform configuration or workflow change most directly corrects the described issue?
- Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow.
- Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group.
- Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level.
- Grant scoped team access with read or plan permissions as appropriate, reserving apply and administration for authorized groups.
Explanation
Correct Answer
C:Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level. HCP Terraform policy as code can evaluate planned infrastructure against centralized governance rules before execution. Confirm the cause with: Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results. A concrete acceptance test is: A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals.
Incorrect Answers
A:Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow. This could address hcp terraform remote execution and state hosting, but it does not correct the indicated hcp terraform policy enforcement governance mechanism. The relevant fix is: Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level.
B:Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group. This could address hcp projects group workspaces by ownership, but it does not correct the indicated hcp terraform policy enforcement governance mechanism. The relevant fix is: Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level.
D:Grant scoped team access with read or plan permissions as appropriate, reserving apply and administration for authorized groups. This could address hcp terraform team permissions and audit trail, but it does not correct the indicated hcp terraform policy enforcement governance mechanism. The relevant fix is: Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level.
Question 68
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A team uses terraform apply -target on one module for every release, leaving graph-related infrastructure changes unnoticed in the rest of the root configuration. The operator must obtain auditable evidence before touching production resources. Which diagnostic check provides the strongest evidence for the underlying problem?
- Inspect remaining pending actions with a full plan and identify why targeted operations were introduced.
- Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics.
- Inspect Terraform diagnostic output for undeclared input references and compare declared variable names to expressions.
- Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
Explanation
Correct Answer
A:Inspect remaining pending actions with a full plan and identify why targeted operations were introduced. Targeting can bypass part of the configuration graph and should not be a standard substitute for comprehensive reconciliation. A justified correction is: Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
Incorrect Answers
B:Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics. This inspects ci terraform fmt check distinguishes style from validity rather than the reported targeted apply limitations for normal changes issue. The decisive investigation is: Inspect remaining pending actions with a full plan and identify why targeted operations were introduced.
C:Inspect Terraform diagnostic output for undeclared input references and compare declared variable names to expressions. This inspects terraform validate catches undeclared reference rather than the reported targeted apply limitations for normal changes issue. The decisive investigation is: Inspect remaining pending actions with a full plan and identify why targeted operations were introduced.
D: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 targeted apply limitations for normal changes issue. The decisive investigation is: Inspect remaining pending actions with a full plan and identify why targeted operations were introduced.
Question 69
When maintaining Terraform modules used by several application teams, the following condition occurs: A root Terraform configuration calls a child module with a relative source path that points to a nonexistent sibling directory on the CI runner. The module interface must remain stable and reviewable. What measurable postchange observation would confirm that the correction worked?
- The child module files are located consistently by local and CI runs without copying the same definitions into the root.
- The root plan resolves the new module output names with no dangling references or unintended replacements.
- Normal CI initialization selects the reviewed compatible module version and unsupported major releases are not adopted silently.
- Initialization selects the network module code from the intended repository path and revision rather than unrelated root files.
Explanation
Correct Answer
A:The child module files are located consistently by local and CI runs without copying the same definitions into the root. Local module sources are paths resolved relative to the calling module; incorrect layout cannot be repaired by provider credentials. It tests the correction: Set the source to an accurate local relative module path and initialize or validate from the correct root directory.
Incorrect Answers
B:The root plan resolves the new module output names with no dangling references or unintended replacements. This might validate module upgrade plan review with changed outputs, but it does not prove that local child module source path resolution was resolved. Confirm instead: The child module files are located consistently by local and CI runs without copying the same definitions into the root.
C:Normal CI initialization selects the reviewed compatible module version and unsupported major releases are not adopted silently. This might validate registry module version pin to avoid breaking releases, but it does not prove that local child module source path resolution was resolved. Confirm instead: The child module files are located consistently by local and CI runs without copying the same definitions into the root.
D:Initialization selects the network module code from the intended repository path and revision rather than unrelated root files. This might validate git module source with explicit subdirectory, but it does not prove that local child module source path resolution was resolved. Confirm instead: The child module files are located consistently by local and CI runs without copying the same definitions into the root.
Question 70
During a cross-platform infrastructure standardization exercise, the following condition occurs: Three product teams rebuild nearly identical staging networks by copying browser instructions, but naming and access rules diverge by team. The decision must preserve ownership and minimize undocumented changes. What measurable postchange observation would confirm that the correction worked?
- An unanticipated deletion or replacement is identified and blocked before a privileged apply can execute it.
- A plan can cover both managed targets while each provider operates only within its authorized platform and permissions.
- A series of Terraform plans remains stable after independent automation without oscillating policy settings between tools.
- New staging environments satisfy common access requirements while explicit input values account for documented environment differences.
Explanation
Correct Answer
D:New staging environments satisfy common access requirements while explicit input values account for documented environment differences. Shared IaC patterns reduce accidental divergence without requiring every environment to have identical parameters. It tests the correction: Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences.
Incorrect Answers
A:An unanticipated deletion or replacement is identified and blocked before a privileged apply can execute it. This might validate terraform plan review as change safety barrier, but it does not prove that reusable environment definitions and reduced configuration drift was resolved. Confirm instead: New staging environments satisfy common access requirements while explicit input values account for documented environment differences.
B: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 reusable environment definitions and reduced configuration drift was resolved. Confirm instead: New staging environments satisfy common access requirements while explicit input values account for documented environment differences.
C:A series of Terraform plans remains stable after independent automation without oscillating policy settings between tools. This might validate terraform resource ownership boundary, but it does not prove that reusable environment definitions and reduced configuration drift was resolved. Confirm instead: New staging environments satisfy common access requirements while explicit input values account for documented environment differences.