HashiCorp Terraform Associate 004 Practice Test 46
Question 450
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A child Terraform module refers directly to var.environment declared only in its parent, causing a missing-variable diagnostic. The team must preserve reproducibility across callers. What targeted engineering response should the team implement?
- Use for_each on the module block with a stable keyed collection and pass each.key or each.value to the child input contract.
- Set the source to an accurate local relative module path and initialize or validate from the correct root directory.
- Declare an input variable in the child module and pass the parent's value explicitly as a module argument.
- Add the intended child output declaration and access it through module.network.<output_name> in the caller.
Explanation
Correct Answer
C:Declare an input variable in the child module and pass the parent's value explicitly as a module argument. Input variables are scoped to their modules and must cross a module boundary through an explicit interface. Confirm the cause with: Inspect the child module's variable declarations and the arguments passed by its calling module block. A concrete acceptance test is: The child module receives the intended environment value without accessing variables declared only in its caller. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
Incorrect Answers
A: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 could address for_each at module call for multiple environments, but it does not correct the indicated root and child variable scope isolation mechanism. The relevant fix is: Declare an input variable in the child module and pass the parent's value explicitly as a module argument.
B: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 root and child variable scope isolation mechanism. The relevant fix is: Declare an input variable in the child module and pass the parent's value explicitly as a module argument.
D:Add the intended child output declaration and access it through module.network.<output_name> in the caller. This could address child output exposure to calling module, but it does not correct the indicated root and child variable scope isolation mechanism. The relevant fix is: Declare an input variable in the child module and pass the parent's value explicitly as a module argument.
Question 451
During a governed HCP Terraform workspace rollout, the following condition occurs: A developer adds an HCP Terraform organization but the CLI still writes local state because no cloud workspace selection is configured. The organization must retain auditable authorization for runs and state. Which investigation would most directly establish the reported Terraform failure?
- Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources.
- Review organization and workspace team roles, run permissions and audit records for sensitive environments.
- Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
- Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
Explanation
Correct Answer
C:Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. The cloud block binds a root configuration to HCP Terraform workspaces; merely naming an organization elsewhere is insufficient. A justified correction is: Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate. This matters here because a developer adds an HCP Terraform organization but the CLI still writes local state because no cloud workspace….
Incorrect Answers
A:Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources. This inspects hcp terraform cli login and execution credentials rather than the reported terraform cloud block hcp workspace integration issue. The decisive investigation is: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. This matters here because a developer adds an HCP Terraform organization but the CLI still writes local state because no cloud workspace….
B:Review organization and workspace team roles, run permissions and audit records for sensitive environments. This inspects hcp terraform team permissions and audit trail rather than the reported terraform cloud block hcp workspace integration issue. The decisive investigation is: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
D:Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results. This inspects hcp terraform policy enforcement governance rather than the reported terraform cloud block hcp workspace integration issue. The decisive investigation is: Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
Question 452
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A root configuration needs a child module's generated network ID but accesses an internal child resource name directly and fails to resolve it. The engineer must respect declared resource contracts and data security boundaries. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Check the for_each keys and the collection shape of the declared resource instances.
- Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early.
- Inspect the child module output declarations and the root's module block name and available output values.
- Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
Explanation
Correct Answer
C:Inspect the child module output declarations and the root's module block name and available output values. Modules expose values to callers through output declarations, creating an explicit interface between implementation and consumers. A justified correction is: Expose the required network identifier with an output in the child module and reference module.network.<output_name> from the root.
Incorrect Answers
A:Check the for_each keys and the collection shape of the declared resource instances. This inspects collection references for for_each resources rather than the reported module output references across composition issue. The decisive investigation is: Inspect the child module output declarations and the root's module block name and available output values.
B:Inspect variable input expectations and whether an explicit validation condition can reject invalid strings early. This inspects input variable custom validation rule rather than the reported module output references across composition issue. The decisive investigation is: Inspect the child module output declarations and the root's module block name and available output values.
D:Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift. This inspects ignore_changes ownership of externally managed tag rather than the reported module output references across composition issue. The decisive investigation is: Inspect the child module output declarations and the root's module block name and available output values.
Question 453
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A root output refers to the ID of a resource just created, yet another workflow assumes the string is known before the apply finishes. The engineers must keep provider choices and identities reproducible. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
- Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly.
- Keep provider source and version in required_providers and configure authentication via supported provider settings or short-lived environment credentials.
- Recover the correct protected state snapshot or deliberately import existing objects before applying destructive duplicate provisioning.
Explanation
Correct Answer
A:Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID. State stores known provider-returned attributes and supports dependency references; some values remain unknown until apply. Confirm the cause with: Check which resource attributes are computed by the provider and how state records them after successful operations. A concrete acceptance test is: The first plan marks unknown values appropriately and a subsequent apply publishes the actual ID through the tracked state.
Incorrect Answers
B:Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly. This could address multiple provider instances requiring separate authentication, but it does not correct the indicated resource attribute outputs supplied by state mechanism. The relevant fix is: Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
C:Keep provider source and version in required_providers and configure authentication via supported provider settings or short-lived environment credentials. This could address provider block credentials versus required_providers, but it does not correct the indicated resource attribute outputs supplied by state mechanism. The relevant fix is: Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
D:Recover the correct protected state snapshot or deliberately import existing objects before applying destructive duplicate provisioning. This could address state binding between resource address and remote object, but it does not correct the indicated resource attribute outputs supplied by state mechanism. The relevant fix is: Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
Question 454
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A novice team runs terraform apply in a directory containing unreviewed edits and cannot explain the difference between proposed and actual resource changes. The change must preserve the distinction between previewing and modifying infrastructure. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order.
- Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
- Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy.
- Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
- Inspect remaining pending actions with a full plan and identify why targeted operations were introduced.
Explanation
Correct Answers
A:Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. Terraform's normal lifecycle separates desired-state authoring and plan evaluation from the operation that changes managed infrastructure. A justified correction is: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment. 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 novice team runs….
D:Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment. Terraform's normal lifecycle separates desired-state authoring and plan evaluation from the operation that changes managed infrastructure. Confirm the cause with: Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. A concrete acceptance test is: A planned change is inspected before approval, then the resulting infrastructure matches the reviewed configuration where supported. 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 novice team runs….
Incorrect Answers
B:Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources. This relates to workflow repeatability after configuration change rather than the matching diagnosis-and-remediation pair required here. Check: Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. Then change: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A novice team runs….
C:Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy. This relates to plan versus real infrastructure drift rather than the matching diagnosis-and-remediation pair required here. Check: Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. Then change: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
E:Inspect remaining pending actions with a full plan and identify why targeted operations were introduced. This relates to targeted apply limitations for normal changes rather than the matching diagnosis-and-remediation pair required here. Check: Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. Then change: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
Question 455
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A team uses terraform apply -target on one module for every release, leaving graph-related infrastructure changes unnoticed in the rest of the root configuration. The operator must obtain auditable evidence before touching production resources. Which proposed remediation solves this failure without masking its cause?
- Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
- Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
- Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs.
- Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy.
Explanation
Correct Answer
B:Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment. Targeting can bypass part of the configuration graph and should not be a standard substitute for comprehensive reconciliation. Confirm the cause with: Inspect remaining pending actions with a full plan and identify why targeted operations were introduced. A concrete acceptance test is: A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions.
Incorrect Answers
A:Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes. This could address terraform fmt normalizes hcl style, but it does not correct the indicated targeted apply limitations for normal changes mechanism. The relevant fix is: Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
C:Review the proposed operations and approve interactively or use a controlled automation mechanism for noninteractive runs. This could address apply requires approval unless automated, but it does not correct the indicated targeted apply limitations for normal changes mechanism. The relevant fix is: Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
D:Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy. This could address plan versus real infrastructure drift, but it does not correct the indicated targeted apply limitations for normal changes mechanism. The relevant fix is: Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment.
Question 456
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An application service needs a policy attachment completed before creating a dependent service, but no attribute reference exists to order the two operations. The engineer must respect declared resource contracts and data security boundaries. Which diagnostic check provides the strongest evidence for the underlying problem?
- Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift.
- Inspect command-line var flags, tfvars files, Terraform variable environment entries, and workspace variable values.
- Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema.
- Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first.
Explanation
Correct Answer
D:Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first. depends_on expresses dependencies that cannot be inferred from configuration values, but unnecessary broad dependencies add conservatism. A justified correction is: Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An….
Incorrect Answers
A:Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift. This inspects ignore_changes ownership of externally managed tag rather than the reported explicit depends_on for behavior-only dependencies issue. The decisive investigation is: Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An….
B:Inspect command-line var flags, tfvars files, Terraform variable environment entries, and workspace variable values. This inspects variable input precedence and configuration injection rather than the reported explicit depends_on for behavior-only dependencies issue. The decisive investigation is: Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first.
C:Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema. This inspects data source versus managed resource definition rather than the reported explicit depends_on for behavior-only dependencies issue. The decisive investigation is: Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first.
Question 457
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A child Terraform module refers directly to var.environment declared only in its parent, causing a missing-variable diagnostic. The team must preserve reproducibility across callers. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Trace the token through module input/output declarations and identify any output that exposes secret data.
- Inspect the module source syntax and whether the source is a registry address or a generic VCS URL.
- Compare the upgraded module's documented input/output contract to root references before approving the module version change.
- Inspect the child module's variable declarations and the arguments passed by its calling module block.
Explanation
Correct Answer
D:Inspect the child module's variable declarations and the arguments passed by its calling module block. Input variables are scoped to their modules and must cross a module boundary through an explicit interface. A justified correction is: Declare an input variable in the child module and pass the parent's value explicitly as a module argument. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
Incorrect Answers
A:Trace the token through module input/output declarations and identify any output that exposes secret data. This inspects sensitive input forwarding between nested modules rather than the reported root and child variable scope isolation issue. The decisive investigation is: Inspect the child module's variable declarations and the arguments passed by its calling module block.
B:Inspect the module source syntax and whether the source is a registry address or a generic VCS URL. This inspects registry module source naming contract rather than the reported root and child variable scope isolation issue. The decisive investigation is: Inspect the child module's variable declarations and the arguments passed by its calling module block. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
C: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 root and child variable scope isolation issue. The decisive investigation is: Inspect the child module's variable declarations and the arguments passed by its calling module block.
Question 458
During an isolated staging rehearsal of the Terraform workflow, 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 operator must obtain auditable evidence before touching production resources. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
- Reformat the affected .tf files using terraform fmt and rerun both style checking and validation independently.
- 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.
Explanation
Correct Answer
C: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. This matters here because a test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual….
Incorrect Answers
A: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. This matters here because a test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual….
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 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: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 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 459
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A module source from the public registry resolves to an unexpected major version after a new release and changes its input contract. The team must preserve reproducibility across callers. Select TWO: the decisive first check and the change that directly addresses the problem.
- Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
- Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values.
- Inspect the module source syntax and whether the source is a registry address or a generic VCS URL.
- Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests.
- Check the module source address, allowed version range and current module selections from initialization.
Explanation
Correct Answers
D:Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests. Registry module versions follow explicit constraints; leaving compatibility open can cause unreviewed module interface changes. Confirm the cause with: Check the module source address, allowed version range and current module selections from initialization. A concrete acceptance test is: Normal CI initialization selects the reviewed compatible module version and unsupported major releases are not adopted silently. This forms one element of the required two-step diagnosis and correction. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
E:Check the module source address, allowed version range and current module selections from initialization. Registry module versions follow explicit constraints; leaving compatibility open can cause unreviewed module interface changes. A justified correction is: Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests. This forms one element of the required two-step diagnosis and correction. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….
Incorrect Answers
A:Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review. This relates to git module ref pin rather than floating main branch rather than the matching diagnosis-and-remediation pair required here. Check: Check the module source address, allowed version range and current module selections from initialization. Then change: Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests.
B:Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values. This relates to module outputs coordinate dependencies instead of duplicate data rather than the matching diagnosis-and-remediation pair required here. Check: Check the module source address, allowed version range and current module selections from initialization. Then change: Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests.
C:Inspect the module source syntax and whether the source is a registry address or a generic VCS URL. This relates to registry module source naming contract rather than the matching diagnosis-and-remediation pair required here. Check: Check the module source address, allowed version range and current module selections from initialization. Then change: Add an appropriate version constraint for a registry module and review upgrades with plans and compatibility tests.
Question 460
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: A maintenance engineer changes a provider constraint but an existing workspace continues using an older locked plugin even though a newer permitted version is needed. The configuration should behave consistently without broadening access. What targeted engineering response should the team implement?
- Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly.
- Correct the provider's supported credentials or least-privilege permissions without changing a successfully installed plugin.
- Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
- Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again.
Explanation
Correct Answer
C:Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation. Terraform init normally honors locked versions; -upgrade allows choosing newer compatible selections under the declared constraints. Confirm the cause with: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. A concrete acceptance test is: The plan uses the reviewed new compatible provider version and the updated lock file captures it for teammates.
Incorrect Answers
A:Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly. This could address multiple provider instances requiring separate authentication, but it does not correct the indicated controlled provider upgrade using init upgrade mechanism. The relevant fix is: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
B:Correct the provider's supported credentials or least-privilege permissions without changing a successfully installed plugin. This could address provider authorization versus installation failure, but it does not correct the indicated controlled provider upgrade using init upgrade mechanism. The relevant fix is: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
D:Declare the provider's correct registry source and compatible version constraint in required_providers, then initialize again. This could address provider source requirement declaration, but it does not correct the indicated controlled provider upgrade using init upgrade mechanism. The relevant fix is: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.