HashiCorp Terraform Associate 004 Practice Test 14
Question 130
During an isolated staging rehearsal of the Terraform workflow, 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 operator must obtain auditable evidence before touching production resources. What measurable postchange observation would confirm that the correction worked?
- A planned change is inspected before approval, then the resulting infrastructure matches the reviewed configuration where supported.
- A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions.
- A reviewed apply changes only the intended managed attribute and the subsequent plan shows no unexpected pending action.
- The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs.
Explanation
Correct Answer
A:A planned change is inspected before approval, then the resulting infrastructure matches the reviewed configuration where supported. Terraform's normal lifecycle separates desired-state authoring and plan evaluation from the operation that changes managed infrastructure. It tests the correction: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
Incorrect Answers
B:A full plan becomes clean after approved changes and does not conceal unrelated pending resource actions. This might validate targeted apply limitations for normal changes, but it does not prove that core write plan apply workflow order was resolved. Confirm instead: A planned change is inspected before approval, then the resulting infrastructure matches the reviewed configuration where supported.
C:A reviewed apply changes only the intended managed attribute and the subsequent plan shows no unexpected pending action. This might validate workflow repeatability after configuration change, but it does not prove that core write plan apply workflow order was resolved. Confirm instead: A planned change is inspected before approval, then the resulting infrastructure matches the reviewed configuration where supported.
D:The apply executes the selected reviewed plan instead of silently producing a new unreviewed plan from changed inputs. This might validate saved execution plan for controlled deployment, but it does not prove that core write plan apply workflow order was resolved. Confirm instead: A planned change is inspected before approval, then the resulting infrastructure matches the reviewed configuration where supported.
Question 131
During an operational review of a Terraform state backend, the following condition occurs: A network rule is modified directly in a cloud console and a subsequent Terraform plan proposes reverting it although the Terraform files are unchanged. The team must preserve managed-object identity and safe collaboration. Which proposed remediation solves this failure without masking its cause?
- Select a backend with supported state-locking capabilities and configure its required access controls appropriately.
- Select the intended workspace before planning and check the corresponding workspace-specific state directory.
- Add a moved block mapping the old address to the new address before running a reviewed plan.
- Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change.
Explanation
Correct Answer
D:Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change. Terraform can detect remote drift during refresh and propose changes back to declared configuration rather than treating console edits as code. Confirm the cause with: Compare the refreshed real object with its prior state and declared configuration to identify an outside change. A concrete acceptance test is: The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit.
Incorrect Answers
A:Select a backend with supported state-locking capabilities and configure its required access controls appropriately. This could address backend-specific state locking support, but it does not correct the indicated out-of-band drift detection in managed resource mechanism. The relevant fix is: Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change.
B:Select the intended workspace before planning and check the corresponding workspace-specific state directory. This could address local workspace state separation, but it does not correct the indicated out-of-band drift detection in managed resource mechanism. The relevant fix is: Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change.
C:Add a moved block mapping the old address to the new address before running a reviewed plan. This could address moved block preserves state during address refactor, but it does not correct the indicated out-of-band drift detection in managed resource mechanism. The relevant fix is: Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change.
Question 132
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A root configuration defines an alias for a secondary region, but its child module provisions resources in the primary region because the provider mapping is omitted. The engineers must keep provider choices and identities reproducible. Which Terraform configuration or workflow change most directly corrects the described issue?
- Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them.
- Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly.
- Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
- Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
Explanation
Correct Answer
C:Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required. Provider configurations are supplied by module callers; module source files do not automatically inherit arbitrary aliases by matching their names. Confirm the cause with: Review the child module provider requirements and root module providers mapping for the child call. A concrete acceptance test is: The child module's resources are planned under the intended alternate region rather than silently using the default provider.
Incorrect Answers
A:Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. This could address provider version range semantics, but it does not correct the indicated module provider mapping for aliased configurations mechanism. The relevant fix is: Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
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 module provider mapping for aliased configurations mechanism. The relevant fix is: Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
D:Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions. This could address dependency lock file reproducible selection, but it does not correct the indicated module provider mapping for aliased configurations mechanism. The relevant fix is: Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
Question 133
During an isolated staging rehearsal of the Terraform workflow, 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 operator must obtain auditable evidence before touching production resources. Select TWO: the decisive first check and the change that directly addresses the problem.
- Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order.
- Run terraform init to install and configure referenced child modules before attempting configuration validation.
- Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
- Inspect the module source declaration and initialization logs for the missing module download.
- Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy.
Explanation
Correct Answers
B: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.
D: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.
Incorrect Answers
A:Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. This relates to core write plan apply workflow order 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.
E: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: 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.
Question 134
During a cross-platform infrastructure standardization exercise, the following condition occurs: Two automation systems both change the same cloud storage policy, and repeated Terraform applies continuously undo the other controller's modifications. The decision must preserve ownership and minimize undocumented changes. What targeted engineering response should the team implement?
- Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
- Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms.
- Express the intended resources in Terraform configuration and review its generated plan before applying a consistent desired state.
- Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values.
Explanation
Correct Answer
A:Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices. Declarative reconciliation requires a clear ownership contract; competing controllers can create perpetual drift. Confirm the cause with: Identify which attributes Terraform declares and which external system writes to the same managed object between runs. A concrete acceptance test is: A series of Terraform plans remains stable after independent automation without oscillating policy settings between tools.
Incorrect Answers
B:Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms. This could address provider-neutral infrastructure pattern without identical resource types, but it does not correct the indicated terraform resource ownership boundary mechanism. The relevant fix is: Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
C:Express the intended resources in Terraform configuration and review its generated plan before applying a consistent desired state. This could address declarative desired state versus imperative console runbook, but it does not correct the indicated terraform resource ownership boundary mechanism. The relevant fix is: Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
D:Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values. This could address multi-cloud providers under one terraform workflow, but it does not correct the indicated terraform resource ownership boundary mechanism. The relevant fix is: Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
Question 135
During a controlled module integration test for a production Terraform stack, the following condition occurs: A pipeline needs a temporary provider API token but its input variable is ordinary and the security reviewer wants to avoid persisting the token in plan or state artifacts. The desired fix must avoid unrelated resource changes. Which outcome most directly validates the intended fix?
- The module applies under least privilege without retaining the secret in source control or ordinary state output.
- A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts.
- The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.
- The root plan resolves the supported module output without attempting to address private child resource internals.
Explanation
Correct Answer
B:A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts. This is acceptance evidence for ephemeral variable for short-lived token in terraform 1.12. Ephemeral values are available during an operation but cannot be referenced in arbitrary normal persisted expressions. It tests the correction: Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration.
Incorrect Answers
A:The module applies under least privilege without retaining the secret in source control or ordinary state output. This might validate vault credential lookup without hardcoding secret values, but it does not prove that ephemeral variable for short-lived token in terraform 1.12 was resolved. Confirm instead: A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts.
C:The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit. This might validate create_before_destroy lifecycle for availability, but it does not prove that ephemeral variable for short-lived token in terraform 1.12 was resolved. Confirm instead: A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts.
D:The root plan resolves the supported module output without attempting to address private child resource internals. This might validate module output references across composition, but it does not prove that ephemeral variable for short-lived token in terraform 1.12 was resolved. Confirm instead: A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts.
Question 136
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: An organization switches from local state to a remote backend, but its existing Terraform work directory still points to the former backend settings. The change must preserve the distinction between previewing and modifying infrastructure. Which diagnostic check provides the strongest evidence for the underlying problem?
- Inspect the module source declaration and initialization logs for the missing module download.
- Review the last plan and apply activity to distinguish provider initialization from planning and changing the managed resource.
- Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure.
- Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed.
Explanation
Correct Answer
D:Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed. Changing backend configuration requires a deliberate reinitialization decision; a text edit alone does not migrate state safely. A justified correction is: Run terraform init with an appropriate migration or reconfiguration option after ensuring correct target state and backups.
Incorrect Answers
A:Inspect the module source declaration and initialization logs for the missing module download. This inspects module installation during initial setup rather than the reported reinitializing after backend configuration change issue. The decisive investigation is: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed.
B:Review the last plan and apply activity to distinguish provider initialization from planning and changing the managed resource. This inspects workflow repeatability after configuration change rather than the reported reinitializing after backend configuration change issue. The decisive investigation is: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed.
C:Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. This inspects selective cleanup without destroying retained object rather than the reported reinitializing after backend configuration change issue. The decisive investigation is: Inspect the old backend metadata, new backend block, and whether a state migration has been explicitly reviewed.
Question 137
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A reusable module expects a region input but has no default, and a new caller assumes Terraform will infer a region from the module source. The engineer must respect declared resource contracts and data security boundaries. Which investigation would most directly establish the reported Terraform failure?
- Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value.
- Review input and output sensitivity declarations and inspect what the plan or output commands will display.
- Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings.
- Inspect the variable declaration, resource schema, and stored state behavior for that password input.
Explanation
Correct Answer
A:Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value. Input variables lacking defaults are required at the module boundary; module source addresses do not implicitly supply their values. A justified correction is: Provide the required region input through the module call or a supported root variable assignment mechanism.
Incorrect Answers
B:Review input and output sensitivity declarations and inspect what the plan or output commands will display. This inspects sensitive output display behavior rather than the reported variable default versus required input issue. The decisive investigation is: Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value.
C:Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings. This inspects implicit dependency through resource attribute reference rather than the reported variable default versus required input issue. The decisive investigation is: Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value.
D:Inspect the variable declaration, resource schema, and stored state behavior for that password input. This inspects sensitive variable does not erase state secrets rather than the reported variable default versus required input issue. The decisive investigation is: Inspect variable blocks for type/default arguments and the module call for an explicitly supplied input value.
Question 138
During a cross-platform infrastructure standardization exercise, the following condition occurs: A risky network change is applied immediately through a console even though a routine maintenance window requires estimating resource replacements first. The decision must preserve ownership and minimize undocumented changes. Which outcome most directly validates the intended fix?
- A plan can cover both managed targets while each provider operates only within its authorized platform and permissions.
- An auditor can identify the approved commit and plan that caused a deliberate infrastructure capacity change.
- 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
D:An unanticipated deletion or replacement is identified and blocked before a privileged apply can execute it. Plan review helps forecast proposed infrastructure changes, though unknown provider values and external drift can still affect final outcomes. It tests the correction: Run a reviewed Terraform plan before application, investigate unexpected replacements, and require appropriate authorization.
Incorrect Answers
A:A plan can cover both managed targets while each provider operates only within its authorized platform and permissions. This might validate hybrid cloud workflow with distinct provider credentials, but it does not prove that terraform plan review as change safety barrier was resolved. Confirm instead: An unanticipated deletion or replacement is identified and blocked before a privileged apply can execute it.
B:An auditor can identify the approved commit and plan that caused a deliberate infrastructure capacity change. This might validate version-controlled iac change auditing, but it does not prove that terraform plan review as change safety barrier was resolved. Confirm instead: An unanticipated deletion or replacement is identified and blocked before a privileged apply can execute it.
C:Both platform implementations satisfy agreed application outputs using their own valid resource schemas and API constraints. This might validate provider-neutral infrastructure pattern without identical resource types, but it does not prove that terraform plan review as change safety barrier was resolved. Confirm instead: An unanticipated deletion or replacement is identified and blocked before a privileged apply can execute it.
Question 139
During a governed HCP Terraform workspace rollout, the following condition occurs: An organization wants to block infrastructure plans that violate approved tagging and region controls but relies solely on reviewers noticing violations manually. The organization must retain auditable authorization for runs and state. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Contributors can collaborate on plans while unauthorized accounts cannot approve or apply production infrastructure changes.
- The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities.
- An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution.
- A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals.
Explanation
Correct Answer
D:A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals. HCP Terraform policy as code can evaluate planned infrastructure against centralized governance rules before execution. It tests the correction: Attach supported Sentinel or OPA policies to the appropriate HCP Terraform workspaces with a suitable mandatory enforcement level.
Incorrect Answers
A:Contributors can collaborate on plans while unauthorized accounts cannot approve or apply production infrastructure changes. This might validate hcp terraform team permissions and audit trail, but it does not prove that hcp terraform policy enforcement governance was resolved. Confirm instead: A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals.
B:The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities. This might validate hcp terraform cli login and execution credentials, but it does not prove that hcp terraform policy enforcement governance was resolved. Confirm instead: A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals.
C:An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution. This might validate vcs-driven hcp terraform run on approved changes, but it does not prove that hcp terraform policy enforcement governance was resolved. Confirm instead: A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals.
Question 140
During an operational review of a Terraform state backend, the following condition occurs: An administrator intentionally changes a provider-computed tag outside Terraform and wants the tracked state to reflect reality without reverting any remote resource. The team must preserve managed-object identity and safe collaboration. What measurable postchange observation would confirm that the correction worked?
- The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
- A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination.
- The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit.
- Remote state access succeeds without exposing persistent access keys in the repository, saved plan, or shared logs.
Explanation
Correct Answer
A:The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation. Refresh-only mode reconciles tracked state with observed infrastructure; normal apply may instead modify infrastructure to match configuration. It tests the correction: Apply a reviewed refresh-only plan when appropriate to synchronize state with current remote objects without an infrastructure change.
Incorrect Answers
B:A stale lock is removed without interrupting an active state-writing operation or corrupting run coordination. This might validate force unlock requires stale-lock verification, but it does not prove that refresh-only state update without infrastructure mutation was resolved. Confirm instead: The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
C:The approved reconciliation returns to a stable plan and makes the handling of the external modification explicit. This might validate out-of-band drift detection in managed resource, but it does not prove that refresh-only state update without infrastructure mutation was resolved. Confirm instead: The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.
D: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 refresh-only state update without infrastructure mutation was resolved. Confirm instead: The state snapshot reflects the latest remote observation and no Terraform-driven remote object mutation occurs during that operation.