HashiCorp Terraform Associate 004 Practice Test 21
Question 200
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. What targeted engineering response should the team implement?
- Add the intended child output declaration and access it through module.network.<output_name> in the caller.
- Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values.
- Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs.
- Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref.
Explanation
Correct Answer
A: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.
Incorrect Answers
B:Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values. This could address module outputs coordinate dependencies instead of duplicate data, but it does not correct the indicated child output exposure to calling module mechanism. The relevant fix is: Add the intended child output declaration and access it through module.network.<output_name> in the caller.
C:Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs. This could address sensitive input forwarding between nested modules, but it does not correct the indicated child output exposure to calling module mechanism. The relevant fix is: Add the intended child output declaration and access it through module.network.<output_name> in the caller.
D:Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. This could address git module source with explicit subdirectory, but it does not correct the indicated child output exposure to calling module mechanism. The relevant fix is: Add the intended child output declaration and access it through module.network.<output_name> in the caller.
Question 201
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: A team publicly commits terraform.tfstate because it believes sensitive-marked variables guarantee that all secret material has been scrubbed from state. The configuration should behave consistently without broadening access. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Two clean checkouts select the reviewed compatible provider binaries rather than silently upgrading independently.
- The next plan recognizes existing managed object bindings and avoids duplicate creates for unchanged infrastructure.
- Routine initialization stays within the intended major version while explicit change review governs the next major update.
- Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure.
Explanation
Correct Answer
D:Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure. The sensitive marking mainly controls presentation; state can still contain secret values unless configured to avoid persistence. It tests the correction: Move state to an access-controlled encrypted backend, restrict readers, and avoid storing secret inputs where ephemeral paths are supported.
Incorrect Answers
A:Two clean checkouts select the reviewed compatible provider binaries rather than silently upgrading independently. This might validate dependency lock file reproducible selection, but it does not prove that state as sensitive operational metadata was resolved. Confirm instead: Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure.
B:The next plan recognizes existing managed object bindings and avoids duplicate creates for unchanged infrastructure. This might validate state binding between resource address and remote object, but it does not prove that state as sensitive operational metadata was resolved. Confirm instead: Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure.
C: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 state as sensitive operational metadata was resolved. Confirm instead: Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure.
Question 202
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: Two engineers initialize the same project at different times and unexpectedly use different provider binaries after compatible new releases appear. The configuration should behave consistently without broadening access. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Check which resource attributes are computed by the provider and how state records them after successful operations.
- Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly.
- Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
- Compare .terraform.lock.hcl checksums and selected versions against required_providers constraints and provider init logs.
- Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
Explanation
Correct Answers
D:Compare.terraform.lock.hcl checksums and selected versions against required_providers constraints and provider init logs. Version constraints define acceptable releases; the dependency lock file records concrete chosen provider selections and checksums. A justified correction is: Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions. This forms one element of the required two-step diagnosis and correction.
E:Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions. Version constraints define acceptable releases; the dependency lock file records concrete chosen provider selections and checksums. Confirm the cause with: Compare.terraform.lock.hcl checksums and selected versions against required_providers constraints and provider init logs. A concrete acceptance test is: Two clean checkouts select the reviewed compatible provider binaries rather than silently upgrading independently. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Check which resource attributes are computed by the provider and how state records them after successful operations. This relates to resource attribute outputs supplied by state rather than the matching diagnosis-and-remediation pair required here. Check: Compare.terraform.lock.hcl checksums and selected versions against required_providers constraints and provider init logs. Then change: Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
B:Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly. This relates to multiple provider instances requiring separate authentication rather than the matching diagnosis-and-remediation pair required here. Check: Compare.terraform.lock.hcl checksums and selected versions against required_providers constraints and provider init logs. Then change: Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
C:Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation. This relates to controlled provider upgrade using init upgrade rather than the matching diagnosis-and-remediation pair required here. Check: Compare.terraform.lock.hcl checksums and selected versions against required_providers constraints and provider init logs. Then change: Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
Question 203
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. Select TWO: the decisive first check and the change that directly addresses the problem.
- Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
- Identify the exact resource instance address from terraform state list and inspect it with terraform state show.
- Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping.
- Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan.
- Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
Explanation
Correct Answers
A:Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state. Configuration-driven import blocks can make existing-resource adoption repeatable and part of a reviewed execution plan. Confirm the cause with: Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. A concrete acceptance test is: The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source. This forms one element of the required two-step diagnosis and correction.
C:Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. Configuration-driven import blocks can make existing-resource adoption repeatable and part of a reviewed execution plan. A justified correction is: Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
B:Identify the exact resource instance address from terraform state list and inspect it with terraform state show. This relates to state show inspects one stored resource instance rather than the matching diagnosis-and-remediation pair required here. Check: Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. Then change: Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
D:Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan. This relates to terraform import binds preexisting remote object rather than the matching diagnosis-and-remediation pair required here. Check: Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. Then change: Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
E:Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command. This relates to tf_log for troubleshooting provider and cli diagnostics rather than the matching diagnosis-and-remediation pair required here. Check: Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. Then change: Declare reviewed import blocks for known objects, plan the adoption, and reconcile configuration with the resulting resource state.
Question 204
As an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A platform administrator copies the same nonsecret provider region and organization policy values into 20 workspaces, and copies drift apart after an update. The workflow must apply least privilege and preserve workspace isolation. Which Terraform configuration or workflow change most directly corrects the described issue?
- Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values.
- Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently.
- 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.
Explanation
Correct Answer
A:Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values. HCP variable sets centralize common workspace variables; explicit assignment scope prevents accidental cross-project changes. Confirm the cause with: Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope. A concrete acceptance test is: A shared setting update reaches exactly the approved workspaces while unrelated projects retain independent configuration. This matters here because as an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A….
Incorrect Answers
B:Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently. This could address hcp terraform cli login and execution credentials, but it does not correct the indicated hcp workspace variable sets share scoped configuration mechanism. The relevant fix is: Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values.
C: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 workspace variable sets share scoped configuration mechanism. The relevant fix is: Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values.
D: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 workspace variable sets share scoped configuration mechanism. The relevant fix is: Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values. This matters here because as an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A….
Question 205
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A database argument changes and Terraform shows a replacement action, but the change reviewer reads only the new attribute value and overlooks deletion risk. The operator must obtain auditable evidence before touching production resources. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect refresh findings and compare remote attributes with the declared tag values before accepting a proposed remediation.
- Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply.
- Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
- Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply.
Explanation
Correct Answer
B:Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply. Provider schemas can require replacement for some attribute changes; plan review exposes this before an apply. A justified correction is: Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
Incorrect Answers
A:Inspect refresh findings and compare remote attributes with the declared tag values before accepting a proposed remediation. This inspects plan versus real infrastructure drift rather than the reported plan distinguishes replacement from in-place update issue. The decisive investigation is: Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply.
C: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 distinguishes replacement from in-place update issue. The decisive investigation is: Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply.
D:Differentiate static schema/reference checks in validation from provider API checks and actual permissions during plan and apply. This inspects terraform validate versus cloud permission testing rather than the reported plan distinguishes replacement from in-place update issue. The decisive investigation is: Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply.
Question 206
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. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files.
- Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
- A plan in staging reads staging bindings while a default workspace plan remains independent.
- Concurrent runs against the same state are serialized according to the backend's supported locking contract.
Explanation
Correct Answer
C:A plan in staging reads staging bindings while a default workspace plan remains independent. Local backend workspaces have separate state snapshots, though they share the same configuration and local backend mechanism. It tests the correction: Select the intended workspace before planning and check the corresponding workspace-specific state directory.
Incorrect Answers
A:Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files. This might validate local backend path and exposure, but it does not prove that local workspace state separation was resolved. Confirm instead: A plan in staging reads staging bindings while a default workspace plan remains independent.
B: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 local workspace state separation was resolved. Confirm instead: A plan in staging reads staging bindings while a default workspace plan remains independent.
D:Concurrent runs against the same state are serialized according to the backend's supported locking contract. This might validate backend-specific state locking support, but it does not prove that local workspace state separation was resolved. Confirm instead: A plan in staging reads staging bindings while a default workspace plan remains independent.
Question 207
When maintaining Terraform modules used by several application teams, the following condition occurs: A network module is upgraded and renames a child output, but dependent modules still read the old output and planning fails. The module interface must remain stable and reviewable. Which diagnostic check provides the strongest evidence for the underlying problem?
- Inspect the child module's output blocks and root expressions that refer to module.network values.
- Compare the upgraded module's documented input/output contract to root references before approving the module version change.
- Inspect the parent composition and whether the network child provides an output representing the created subnet.
- Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch.
Explanation
Correct Answer
B:Compare the upgraded module's documented input/output contract to root references before approving the module version change. Module version changes can alter interfaces; compatibility is assessed across callers, not by module installation success alone. A justified correction is: Update the module version together with dependent output references and validate the full root configuration before applying.
Incorrect Answers
A: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 upgrade plan review with changed outputs issue. The decisive investigation is: Compare the upgraded module's documented input/output contract to root references before approving the module version change.
C: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 upgrade plan review with changed outputs issue. The decisive investigation is: Compare the upgraded module's documented input/output contract to root references before approving the module version change.
D:Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. This inspects git module ref pin rather than floating main branch rather than the reported module upgrade plan review with changed outputs issue. The decisive investigation is: Compare the upgraded module's documented input/output contract to root references before approving the module version change.
Question 208
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An external record lookup runs during planning even though the underlying managed resource is not ready and the data source returns no matching object. The engineer must respect declared resource contracts and data security boundaries. Which proposed remediation solves this failure without masking its cause?
- Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration.
- Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
- Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists.
- Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.
Explanation
Correct Answer
C:Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists. Data reads may happen during planning unless their prerequisites require deferral; dependency structure matters for lookup timing. Confirm the cause with: Inspect the graph references and whether the data source must wait for a managed resource's creation. A concrete acceptance test is: The plan defers the lookup when needed and avoids failing on a remote object that is not yet created.
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 data source read ordering versus creation mechanism. The relevant fix is: Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists.
B:Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource. This could address resource precondition for unsafe configuration, but it does not correct the indicated data source read ordering versus creation mechanism. The relevant fix is: Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists.
D:Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring. This could address resource addressing with repeated instances, but it does not correct the indicated data source read ordering versus creation mechanism. The relevant fix is: Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists.
Question 209
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: A project intended to stay on a provider's version 5 releases but a broad >= 5.0 constraint unexpectedly selected a breaking 6.x release. The configuration should behave consistently without broadening access. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
- Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
- Inspect provider alias identities, authentication scopes, and which modules or resources select each instance.
- Examine required_providers version constraints and the selected version recorded in the dependency lock file.
- Define explicitly aliased provider configurations and assign the production resource to the intended alias.
Explanation
Correct Answers
B:Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. A lower-bound-only version constraint does not prevent future major releases; compatible-release constraints bound allowed versions. Confirm the cause with: Examine required_providers version constraints and the selected version recorded in the dependency lock file. A concrete acceptance test is: Routine initialization stays within the intended major version while explicit change review governs the next major update. This forms one element of the required two-step diagnosis and correction.
D:Examine required_providers version constraints and the selected version recorded in the dependency lock file. A lower-bound-only version constraint does not prevent future major releases; compatible-release constraints bound allowed versions. A justified correction is: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions. This relates to dependency lock file reproducible selection rather than the matching diagnosis-and-remediation pair required here. Check: Examine required_providers version constraints and the selected version recorded in the dependency lock file. Then change: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
C:Inspect provider alias identities, authentication scopes, and which modules or resources select each instance. This relates to multiple provider instances requiring separate authentication rather than the matching diagnosis-and-remediation pair required here. Check: Examine required_providers version constraints and the selected version recorded in the dependency lock file. Then change: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
E:Define explicitly aliased provider configurations and assign the production resource to the intended alias. This relates to provider alias for multiple accounts rather than the matching diagnosis-and-remediation pair required here. Check: Examine required_providers version constraints and the selected version recorded in the dependency lock file. Then change: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
Question 210
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 investigation would most directly establish the reported Terraform failure?
- Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
- Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
- Identify the exact resource instance address from terraform state list and inspect it with terraform state show.
- Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping.
Explanation
Correct Answer
B:Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. terraform state list inspects state bindings, which can differ from textual declarations after drift or refactoring. A justified correction is: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
Incorrect Answers
A:Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data. This inspects tf_log for troubleshooting provider and cli diagnostics rather than the reported state list for tracking managed addresses issue. The decisive investigation is: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
C:Identify the exact resource instance address from terraform state list and inspect it with terraform state show. This inspects state show inspects one stored resource instance rather than the reported state list for tracking managed addresses issue. The decisive investigation is: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
D:Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. This inspects import blocks for reproducible adoption workflow rather than the reported state list for tracking managed addresses issue. The decisive investigation is: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.