HashiCorp Terraform Associate 004 Practice Test 8
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.
Question 71
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A root module marks its token variable sensitive but an intermediate child module hardcodes the token into a non-sensitive output for an application module. The team must preserve reproducibility across callers. What measurable postchange observation would confirm that the correction worked?
- Dependent modules receive only necessary authorized values and terminal output does not reveal secret material.
- The child module files are located consistently by local and CI runs without copying the same definitions into the root.
- Initialization selects the network module code from the intended repository path and revision rather than unrelated root files.
- The child module receives the intended environment value without accessing variables declared only in its caller.
Explanation
Correct Answer
A:Dependent modules receive only necessary authorized values and terminal output does not reveal secret material. Module boundaries isolate inputs and outputs, but careless output design can still leak confidential values across those boundaries. It tests the correction: Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs.
Incorrect Answers
B:The child module files are located consistently by local and CI runs without copying the same definitions into the root. This might validate local child module source path resolution, but it does not prove that sensitive input forwarding between nested modules was resolved. Confirm instead: Dependent modules receive only necessary authorized values and terminal output does not reveal secret material.
C: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 sensitive input forwarding between nested modules was resolved. Confirm instead: Dependent modules receive only necessary authorized values and terminal output does not reveal secret material.
D:The child module receives the intended environment value without accessing variables declared only in its caller. This might validate root and child variable scope isolation, but it does not prove that sensitive input forwarding between nested modules was resolved. Confirm instead: Dependent modules receive only necessary authorized values and terminal output does not reveal secret material.
Question 72
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. What measurable postchange observation would confirm that the correction worked?
- All six consumers obtain the reviewed shared security behavior while preserving intentional per-application parameters.
- New applications gain consistent module behavior and removing one key does not renumber unrelated module instances.
- The caller can reference the exact authorized network ID without using private child implementation resource addresses.
- Terraform fetches the intended module revision without mixing registry-only and Git source selection semantics.
Explanation
Correct Answer
A:All six consumers obtain the reviewed shared security behavior while preserving intentional per-application parameters. Terraform modules package related resource definitions into reusable components without requiring one shared state for every consumer. It tests the correction: Create a reusable child module with a documented input/output contract and call it from each application's root module.
Incorrect Answers
B:New applications gain consistent module behavior and removing one key does not renumber unrelated module instances. This might validate for_each at module call for multiple environments, but it does not prove that module blocks reuse standard infrastructure patterns was resolved. Confirm instead: All six consumers obtain the reviewed shared security behavior while preserving intentional per-application parameters.
C:The caller can reference the exact authorized network ID without using private child implementation resource addresses. This might validate child output exposure to calling module, but it does not prove that module blocks reuse standard infrastructure patterns was resolved. Confirm instead: All six consumers obtain the reviewed shared security behavior while preserving intentional per-application parameters.
D:Terraform fetches the intended module revision without mixing registry-only and Git source selection semantics. This might validate registry module source naming contract, but it does not prove that module blocks reuse standard infrastructure patterns was resolved. Confirm instead: All six consumers obtain the reviewed shared security behavior while preserving intentional per-application parameters.
Question 73
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual machine they recently created. The change must preserve the distinction between previewing and modifying infrastructure. Which proposed remediation solves this failure without masking its cause?
- Run terraform init to install and configure referenced child modules before attempting configuration validation.
- Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
- Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
- Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
Explanation
Correct Answer
B:Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. Terraform destroy targets the managed resources recorded in the selected state, not only the objects recently added by one operator. Confirm the cause with: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. A concrete acceptance test is: Only the intended disposable environment's managed objects are removed and shared production resources remain in separate state.
Incorrect Answers
A:Run terraform init to install and configure referenced child modules before attempting configuration validation. This could address module installation during initial setup, but it does not correct the indicated terraform destroy is managed-scope deletion mechanism. The relevant fix is: Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
C:Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources. This could address workflow repeatability after configuration change, but it does not correct the indicated terraform destroy is managed-scope deletion mechanism. The relevant fix is: Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
D:Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. This could address selective cleanup without destroying retained object, but it does not correct the indicated terraform destroy is managed-scope deletion mechanism. The relevant fix is: Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
Question 74
During an isolated staging rehearsal of the Terraform workflow, 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 operator must obtain auditable evidence before touching production resources. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect remaining pending actions with a full plan and identify why targeted operations were introduced.
- Inspect the module source declaration and initialization logs for the missing module download.
- Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure.
- Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
Explanation
Correct Answer
D:Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. A normal interactive Terraform apply requires an approval decision; automating approval changes governance, not Terraform's reconciliation rules. A justified correction is: Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
Incorrect Answers
A:Inspect remaining pending actions with a full plan and identify why targeted operations were introduced. This inspects targeted apply limitations for normal changes rather than the reported apply requires approval unless automated issue. The decisive investigation is: Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
B:Inspect the module source declaration and initialization logs for the missing module download. This inspects module installation during initial setup rather than the reported apply requires approval unless automated issue. The decisive investigation is: Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
C:Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. This inspects selective cleanup without destroying retained object rather than the reported apply requires approval unless automated issue. The decisive investigation is: Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
Question 75
During a controlled Terraform CLI recovery exercise, the following condition occurs: An engineer wants to know which indexed resources are managed before a refactor but greps the Terraform source and misses instances tracked in the active state. The same infrastructure must remain managed without unintended replacements. What measurable postchange observation would confirm that the correction worked?
- The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract.
- 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 existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation.
Explanation
Correct Answer
A:The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract. terraform state list inspects state bindings, which can differ from textual declarations after drift or refactoring. It tests the correction: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
Incorrect Answers
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 state list for tracking managed addresses was resolved. Confirm instead: The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract.
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 state list for tracking managed addresses was resolved. Confirm instead: The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract.
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 state list for tracking managed addresses was resolved. Confirm instead: The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract.
Question 76
During a controlled Terraform CLI recovery exercise, the following condition occurs: An engineer wants to know which indexed resources are managed before a refactor but greps the Terraform source and misses instances tracked in the active state. The same infrastructure must remain managed without unintended replacements. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
- Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
- Use terraform state show on the selected address to review tracked attributes without changing resources.
- Select the appropriate aliased provider configuration and import using the real identifier in its owning account.
Explanation
Correct Answer
A:Use terraform state list to enumerate the actual addresses tracked in the selected workspace state. terraform state list inspects state bindings, which can differ from textual declarations after drift or refactoring. Confirm the cause with: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. A concrete acceptance test is: The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract.
Incorrect Answers
B:Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command. This could address tf_log for troubleshooting provider and cli diagnostics, but it does not correct the indicated state list for tracking managed addresses mechanism. The relevant fix is: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
C:Use terraform state show on the selected address to review tracked attributes without changing resources. This could address state show inspects one stored resource instance, but it does not correct the indicated state list for tracking managed addresses mechanism. The relevant fix is: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
D:Select the appropriate aliased provider configuration and import using the real identifier in its owning account. This could address import source account and provider selection, but it does not correct the indicated state list for tracking managed addresses mechanism. The relevant fix is: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
Question 77
During a controlled module integration test for a production Terraform stack, the following condition occurs: A team wants additional backup retention only in production but duplicates the entire Terraform module for each environment and the copies diverge. The desired fix must avoid unrelated resource changes. What targeted engineering response should the team implement?
- Provide the required region input through the module call or a supported root variable assignment mechanism.
- Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
- Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.
- Use suitable Terraform string functions such as lower, trimspace, and format to normalize the intended names consistently.
Explanation
Correct Answer
B:Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module. Terraform expressions can choose values based on explicit conditions without duplicating full resource definitions. Confirm the cause with: Inspect the shared attributes and whether one expression can derive a value from the environment input. A concrete acceptance test is: Development and production plan different approved retention settings with otherwise shared definitions and no copied modules.
Incorrect Answers
A:Provide the required region input through the module call or a supported root variable assignment mechanism. This could address variable default versus required input, but it does not correct the indicated conditional expressions for environment configuration mechanism. The relevant fix is: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
C:Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated. This could address ignore_changes ownership of externally managed tag, but it does not correct the indicated conditional expressions for environment configuration mechanism. The relevant fix is: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
D:Use suitable Terraform string functions such as lower, trimspace, and format to normalize the intended names consistently. This could address built-in functions for deterministic naming, but it does not correct the indicated conditional expressions for environment configuration mechanism. The relevant fix is: Use an appropriate conditional expression to set the backup retention while keeping common configuration in one reviewed module.
Question 78
When reviewing a reusable Terraform HCL configuration before deployment, 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 engineer must respect declared resource contracts and data security boundaries. What acceptance evidence best establishes that the Terraform issue has been resolved?
- The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
- A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
- The root plan resolves the supported module output without attempting to address private child resource internals.
- An invalid subnet input fails with a clear Terraform validation error while authorized values continue to plan.
Explanation
Correct Answer
D:An invalid subnet input fails with a clear Terraform validation error while authorized values continue to plan. Custom variable validation enforces module input contracts before incorrect values reach resource creation. It tests the correction: Add a variable validation block with an appropriate condition and useful error_message for unacceptable CIDR input.
Incorrect Answers
A:The plan records the authorized region value, and a second run produces the same selection under the same variable inputs. This might validate variable input precedence and configuration injection, but it does not prove that input variable custom validation rule was resolved. Confirm instead: An invalid subnet input fails with a clear Terraform validation error while authorized values continue to plan.
B:A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately. This might validate check block observability versus hard failure, but it does not prove that input variable custom validation rule was resolved. Confirm instead: An invalid subnet input fails with a clear Terraform validation error while authorized values continue to plan.
C:The root plan resolves the supported module output without attempting to address private child resource internals. This might validate module output references across composition, but it does not prove that input variable custom validation rule was resolved. Confirm instead: An invalid subnet input fails with a clear Terraform validation error while authorized values continue to plan.
Question 79
During an isolated staging rehearsal of the Terraform workflow, 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 operator must obtain auditable evidence before touching production resources. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use terraform validate to catch configuration errors and separately run plan or controlled provider checks to assess remote feasibility.
- Reformat the affected .tf files using terraform fmt and rerun both style checking and validation independently.
- Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
- Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
Explanation
Correct Answer
D: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.
Incorrect Answers
A:Use terraform validate to catch configuration errors and separately run plan or controlled provider checks to assess remote feasibility. This could address terraform validate versus cloud permission testing, but it does not correct the indicated reinitializing after backend configuration change mechanism. The relevant fix is: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
B: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 reinitializing after backend configuration change mechanism. The relevant fix is: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
C:Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning. This could address terraform init backend and provider preparation, but it does not correct the indicated reinitializing after backend configuration change mechanism. The relevant fix is: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
Question 80
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A developer switches Terraform CLI workspaces using a local backend and assumes all named workspaces write to the same terraform.tfstate file. The operation must not delete or duplicate existing production objects. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Compare the refreshed real object with its prior state and declared configuration to identify an outside change.
- Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state.
- Wait for or safely resolve the conflicting operation and keep backend-supported state locking enabled.
- 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.
Explanation
Correct Answers
B:Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. Local backend workspaces have separate state snapshots, though they share the same configuration and local backend mechanism. A justified correction is: Select the intended workspace before planning and check the corresponding workspace-specific state directory. This forms one element of the required two-step diagnosis and correction.
D:Select the intended workspace before planning and check the corresponding workspace-specific state directory. Local backend workspaces have separate state snapshots, though they share the same configuration and local backend mechanism. Confirm the cause with: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. A concrete acceptance test is: A plan in staging reads staging bindings while a default workspace plan remains independent. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Compare the refreshed real object with its prior state and declared configuration to identify an outside change. This relates to out-of-band drift detection in managed resource rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. Then change: Select the intended workspace before planning and check the corresponding workspace-specific state directory.
C: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 selected terraform workspace and the backend's paths used for nondefault workspace state. Then change: Select the intended workspace before planning and check the corresponding workspace-specific state directory.
E:Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. This relates to local backend path and exposure rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. Then change: Select the intended workspace before planning and check the corresponding workspace-specific state directory.