HashiCorp Terraform Associate 004 Practice Test 25
Question 240
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: An engineer references a public registry module using a Git URL but also supplies a registry version argument and expects Terraform to resolve it as a registry source. The team must preserve reproducibility across callers. Which diagnostic check provides the strongest evidence for the underlying problem?
- Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout.
- Inspect the module source syntax and whether the source is a registry address or a generic VCS URL.
- Check the module source address, allowed version range and current module selections from initialization.
- Compare the upgraded module's documented input/output contract to root references before approving the module version change.
Explanation
Correct Answer
B:Inspect the module source syntax and whether the source is a registry address or a generic VCS URL. Registry sources support the version argument; a Git source generally selects its revision through its source query ref. A justified correction is: Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL.
Incorrect Answers
A: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 registry module source naming contract issue. The decisive investigation is: Inspect the module source syntax and whether the source is a registry address or a generic VCS URL.
C:Check the module source address, allowed version range and current module selections from initialization. This inspects registry module version pin to avoid breaking releases rather than the reported registry module source naming contract issue. The decisive investigation is: Inspect the module source syntax and whether the source is a registry address or a generic VCS URL.
D:Compare the upgraded module's documented input/output contract to root references before approving the module version change. This inspects module upgrade plan review with changed outputs rather than the reported registry module source naming contract issue. The decisive investigation is: Inspect the module source syntax and whether the source is a registry address or a generic VCS URL.
Question 241
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A root module duplicates nearly identical module blocks for every application name, causing the staging and QA copies to diverge in their configurations. The team must preserve reproducibility across callers. Which Terraform configuration or workflow change most directly corrects the described issue?
- Create a reusable child module with a documented input/output contract and call it from each application's root module.
- Use for_each on the module block with a stable keyed collection and pass each.key or each.value to the child input contract.
- Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL.
- Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests.
Explanation
Correct Answer
B:Use for_each on the module block with a stable keyed collection and pass each.key or each.value to the child input contract. Module calls support for_each to create keyed instances of reusable infrastructure components with stable addresses. Confirm the cause with: Inspect which module arguments vary and whether stable application keys can drive repeated module instances. A concrete acceptance test is: New applications gain consistent module behavior and removing one key does not renumber unrelated module instances. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A root….
Incorrect Answers
A:Create a reusable child module with a documented input/output contract and call it from each application's root module. This could address module blocks reuse standard infrastructure patterns, but it does not correct the indicated for_each at module call for multiple environments mechanism. The relevant fix is: Use for_each on the module block with a stable keyed collection and pass each.key or each.value to the child input contract. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A root….
C:Use a valid registry module address when controlling versions with the module version argument, or pin an appropriate Git ref in a VCS source URL. This could address registry module source naming contract, but it does not correct the indicated for_each at module call for multiple environments mechanism. The relevant fix is: Use for_each on the module block with a stable keyed collection and pass each.key or each.value to the child input contract.
D:Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests. This could address registry module version pin to avoid breaking releases, but it does not correct the indicated for_each at module call for multiple environments mechanism. The relevant fix is: Use for_each on the module block with a stable keyed collection and pass each.key or each.value to the child input contract.
Question 242
When maintaining Terraform modules used by several application teams, 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 module interface must remain stable and reviewable. Which proposed remediation solves this failure without masking its cause?
- Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs.
- Declare an input variable in the child module and pass the parent's value explicitly as a module argument.
- Update the module version together with dependent output references and validate the full root configuration before applying.
- Set the source to an accurate local relative module path and initialize or validate from the correct root directory.
Explanation
Correct Answer
A:Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs. Module boundaries isolate inputs and outputs, but careless output design can still leak confidential values across those boundaries. Confirm the cause with: Trace the token through module input/output declarations and identify any output that exposes secret data. A concrete acceptance test is: Dependent modules receive only necessary authorized values and terminal output does not reveal secret material.
Incorrect Answers
B:Declare an input variable in the child module and pass the parent's value explicitly as a module argument. This could address root and child variable scope isolation, but it does not correct the indicated sensitive input forwarding between nested modules mechanism. The relevant fix is: Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs.
C:Update the module version together with dependent output references and validate the full root configuration before applying. This could address module upgrade plan review with changed outputs, but it does not correct the indicated sensitive input forwarding between nested modules mechanism. The relevant fix is: Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs.
D:Set the source to an accurate local relative module path and initialize or validate from the correct root directory. This could address local child module source path resolution, but it does not correct the indicated sensitive input forwarding between nested modules mechanism. The relevant fix is: Pass sensitive inputs through appropriately typed child variables and avoid exposing them via normal outputs or logs.
Question 243
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A database provider supports a write-only password argument, but an engineer uses a normal stored password argument and checks the plan artifact into an unsecured archive. The engineer must respect declared resource contracts and data security boundaries. What targeted engineering response should the team implement?
- Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists.
- Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required.
- Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.
- Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration.
Explanation
Correct Answer
B:Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required. Write-only resource arguments accept values during an operation without saving those values into Terraform's managed state. Confirm the cause with: Inspect the provider resource schema for supported write-only arguments and associated rotation or version requirements. A concrete acceptance test is: The provider receives the approved new secret without persisting its plaintext in Terraform's plan or state snapshots.
Incorrect Answers
A:Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists. This could address data source read ordering versus creation, but it does not correct the indicated write-only provider argument for managed secret rotation mechanism. The relevant fix is: Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required.
C: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 write-only provider argument for managed secret rotation mechanism. The relevant fix is: Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required.
D: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 write-only provider argument for managed secret rotation mechanism. The relevant fix is: Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required.
Question 244
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: An engineer embeds cloud credentials inside required_providers and expects Terraform to authenticate because the source and version were specified there. The configuration should behave consistently without broadening access. Which investigation would most directly establish the reported Terraform failure?
- Separate plugin resolution logs from runtime API authorization errors and inspect the provider's active identity and scoped permissions.
- Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms.
- Inspect provider alias identities, authentication scopes, and which modules or resources select each instance.
- Compare .terraform.lock.hcl checksums and selected versions against required_providers constraints and provider init logs.
Explanation
Correct Answer
B:Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms. Plugin installation requirements and runtime provider configuration are different parts of Terraform's execution model. A justified correction is: Keep provider source and version in required_providers and configure authentication via supported provider settings or short-lived environment credentials. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: An….
Incorrect Answers
A:Separate plugin resolution logs from runtime API authorization errors and inspect the provider's active identity and scoped permissions. This inspects provider authorization versus installation failure rather than the reported provider block credentials versus required_providers issue. The decisive investigation is: Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms.
C:Inspect provider alias identities, authentication scopes, and which modules or resources select each instance. This inspects multiple provider instances requiring separate authentication rather than the reported provider block credentials versus required_providers issue. The decisive investigation is: Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms.
D:Compare.terraform.lock.hcl checksums and selected versions against required_providers constraints and provider init logs. This inspects dependency lock file reproducible selection rather than the reported provider block credentials versus required_providers issue. The decisive investigation is: Review provider requirement declarations, provider configuration blocks, and the platform's supported authentication mechanisms.
Question 245
During a controlled module integration test for a production Terraform stack, the following condition occurs: A module receives instance sizes keyed by environment name, but the configuration tries to read them using a numeric position as if they were a list. The desired fix must avoid unrelated resource changes. What targeted engineering response should the team implement?
- Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
- Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
- Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
- Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required.
Explanation
Correct Answer
C:Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. Terraform collection types have distinct semantics: maps are addressed by keys while lists are ordered index-based sequences. Confirm the cause with: Inspect the variable type constraint and the HCL expression used to access its values. A concrete acceptance test is: The plan selects the correct per-environment instance size without relying on arbitrary key ordering. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A….
Incorrect Answers
A:Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values. This could address object type contract with nested attributes, but it does not correct the indicated map versus list addressing for environment inputs mechanism. The relevant fix is: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: A….
B:Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. This could address for_each stable identity instead of count index, but it does not correct the indicated map versus list addressing for environment inputs mechanism. The relevant fix is: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
D:Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required. This could address create_before_destroy lifecycle for availability, but it does not correct the indicated map versus list addressing for environment inputs mechanism. The relevant fix is: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
Question 246
While migrating a manually maintained development environment into reviewed Terraform configuration, the following condition occurs: Developers assume a Terraform virtual machine resource from cloud A can be copied unchanged into cloud B just because the configuration language is the same. The team must establish a reproducible and auditable infrastructure change. What measurable postchange observation would confirm that the correction worked?
- Reviewers can trace a proposed firewall change to an audited configuration diff and plan before any infrastructure changes.
- One reviewed workflow coordinates both cloud resources without pretending Terraform replaces the different underlying provider APIs.
- Both platform implementations satisfy agreed application outputs using their own valid resource schemas and API constraints.
- An unanticipated deletion or replacement is identified and blocked before a privileged apply can execute it.
Explanation
Correct Answer
C:Both platform implementations satisfy agreed application outputs using their own valid resource schemas and API constraints. Terraform's common workflow does not make different cloud vendor APIs or resource type attributes interchangeable. It tests the correction: Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms.
Incorrect Answers
A:Reviewers can trace a proposed firewall change to an audited configuration diff and plan before any infrastructure changes. This might validate terraform configuration as reviewable infrastructure specification, but it does not prove that provider-neutral infrastructure pattern without identical resource types was resolved. Confirm instead: Both platform implementations satisfy agreed application outputs using their own valid resource schemas and API constraints.
B:One reviewed workflow coordinates both cloud resources without pretending Terraform replaces the different underlying provider APIs. This might validate multi-cloud providers under one terraform workflow, but it does not prove that provider-neutral infrastructure pattern without identical resource types was resolved. Confirm instead: Both platform implementations satisfy agreed application outputs using their own valid resource schemas and API constraints.
D: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 provider-neutral infrastructure pattern without identical resource types was resolved. Confirm instead: Both platform implementations satisfy agreed application outputs using their own valid resource schemas and API constraints.
Question 247
While diagnosing a Terraform state or import issue in a staging workspace, 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 investigator must avoid unreviewed state writes. Which proposed remediation solves this failure without masking its cause?
- 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 list to enumerate the actual addresses tracked in the selected workspace state.
- Select the appropriate aliased provider configuration and import using the real identifier in its owning account.
- Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
Explanation
Correct Answer
D:Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command. TF_LOG_PATH selects a log destination but must be paired with an enabled TF_LOG level to produce verbose logs. Confirm the cause with: Check the TF_LOG environment variable and filesystem permissions for the requested log path. A concrete acceptance test is: The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds.
Incorrect Answers
A: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 tf_log_path requires enabled logging mechanism. The relevant fix is: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
B:Use terraform state list to enumerate the actual addresses tracked in the selected workspace state. This could address state list for tracking managed addresses, but it does not correct the indicated tf_log_path requires enabled logging mechanism. The relevant fix is: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
C: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 tf_log_path requires enabled logging mechanism. The relevant fix is: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
Question 248
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. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Terraform resolves the intended plugin source consistently instead of relying on historical default namespace guesses.
- The next plan recognizes existing managed object bindings and avoids duplicate creates for unchanged infrastructure.
- The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
- Read and write operations in one account do not gain unnecessary authorization to unrelated account resources.
Explanation
Correct Answer
C:The plan identifies production-account resources under the intended provider configuration while development objects remain separate. A provider alias selects an alternate configured provider instance; resource blocks must reference it to avoid a default-account fallback. It tests the correction: Define explicitly aliased provider configurations and assign the production resource to the intended alias.
Incorrect Answers
A:Terraform resolves the intended plugin source consistently instead of relying on historical default namespace guesses. This might validate provider source requirement declaration, but it does not prove that provider alias for multiple accounts was resolved. Confirm instead: The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
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 provider alias for multiple accounts was resolved. Confirm instead: The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
D:Read and write operations in one account do not gain unnecessary authorization to unrelated account resources. This might validate multiple provider instances requiring separate authentication, but it does not prove that provider alias for multiple accounts was resolved. Confirm instead: The plan identifies production-account resources under the intended provider configuration while development objects remain separate.
Question 249
While diagnosing a Terraform state or import issue in a staging workspace, 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 investigator must avoid unreviewed state writes. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Select the appropriate aliased provider configuration and import using the real identifier in its owning account.
- Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping.
- Use terraform state show on the selected address to review tracked attributes without changing resources.
- Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
- Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
Explanation
Correct Answers
D: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. This forms one element of the required two-step diagnosis and correction.
E: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. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Select the appropriate aliased provider configuration and import using the real identifier in its owning account. This relates to import source account and provider selection rather than the matching diagnosis-and-remediation pair required here. Check: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. Then change: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
B:Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. This relates to import blocks for reproducible adoption workflow rather than the matching diagnosis-and-remediation pair required here. Check: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. Then change: 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 relates to state show inspects one stored resource instance rather than the matching diagnosis-and-remediation pair required here. Check: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. Then change: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
Question 250
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A root module adds a new remote child module source, but terraform validate reports it cannot find the child module in the local working directory. The change must preserve the distinction between previewing and modifying infrastructure. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Inspect the module source declaration and initialization logs for the missing module download.
- Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
- Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
- Inspect refresh findings and compare remote attributes with the declared tag values before accepting a proposed remediation.
- Run terraform init to install and configure referenced child modules before attempting configuration validation.
Explanation
Correct Answers
A:Inspect the module source declaration and initialization logs for the missing module download. Terraform initialization installs external module dependencies while validation assumes required module code is locally available. A justified correction is: Run terraform init to install and configure referenced child modules before attempting configuration validation. This forms one element of the required two-step diagnosis and correction. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A root module adds….
E:Run terraform init to install and configure referenced child modules before attempting configuration validation. Terraform initialization installs external module dependencies while validation assumes required module code is locally available. Confirm the cause with: Inspect the module source declaration and initialization logs for the missing module download. A concrete acceptance test is: The module source resolves and validation can analyze the combined configuration without manually copying code into the root directory. This forms one element of the required two-step diagnosis and correction. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A root module adds….
Incorrect Answers
B:Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. This relates to terraform destroy is managed-scope deletion rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module source declaration and initialization logs for the missing module download. Then change: Run terraform init to install and configure referenced child modules before attempting configuration validation.
C:Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning. This relates to terraform init backend and provider preparation rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module source declaration and initialization logs for the missing module download. Then change: Run terraform init to install and configure referenced child modules before attempting configuration validation. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A root module adds….
D:Inspect refresh findings and compare remote attributes with the declared tag values before accepting a proposed remediation. This relates to plan versus real infrastructure drift rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module source declaration and initialization logs for the missing module download. Then change: Run terraform init to install and configure referenced child modules before attempting configuration validation.