HashiCorp Terraform Associate 004 Practice Test 2
Question 10
As an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A developer has valid cloud-provider credentials but terraform plan cannot access a private HCP Terraform workspace because the Terraform CLI is unauthenticated to the HCP organization. The workflow must apply least privilege and preserve workspace isolation. Which diagnostic check provides the strongest evidence for the underlying problem?
- Inspect existing HCP policy sets, enforcement levels, workspace assignments and prior policy evaluation results.
- Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources.
- Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration.
- Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers.
Explanation
Correct Answer
B:Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources. HCP workspace authentication and cloud provider authentication protect different services and cannot substitute for each other. A justified correction is: Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently.
Incorrect Answers
A: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 hcp terraform cli login and execution credentials issue. The decisive investigation is: Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources.
C:Inspect the terraform cloud block, organization name, workspace selector, and current initialization integration. This inspects terraform cloud block hcp workspace integration rather than the reported hcp terraform cli login and execution credentials issue. The decisive investigation is: Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources.
D:Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers. This inspects vcs-driven hcp terraform run on approved changes rather than the reported hcp terraform cli login and execution credentials issue. The decisive investigation is: Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources.
Question 11
As a second engineer rehearses an infrastructure state migration, the following condition occurs: A team configures remote object storage for state and assumes every backend automatically provides the same distributed locking guarantees. The operation must not delete or duplicate existing production objects. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Concurrent runs against the same state are serialized according to the backend's supported locking contract.
- Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot.
- A plan in staging reads staging bindings while a default workspace plan remains independent.
- Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files.
Explanation
Correct Answer
A:Concurrent runs against the same state are serialized according to the backend's supported locking contract. Remote storage and robust state locking are related but distinct backend capabilities; locking depends on backend implementation. It tests the correction: Select a backend with supported state-locking capabilities and configure its required access controls appropriately.
Incorrect Answers
B:Only one writer changes the shared state at a time and a later plan uses its up-to-date snapshot. This might validate state locking prevents concurrent writes, but it does not prove that backend-specific state locking support was resolved. Confirm instead: Concurrent runs against the same state are serialized according to the backend's supported locking contract.
C:A plan in staging reads staging bindings while a default workspace plan remains independent. This might validate local workspace state separation, but it does not prove that backend-specific state locking support was resolved. Confirm instead: Concurrent runs against the same state are serialized according to the backend's supported locking contract.
D:Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files. This might validate local backend path and exposure, but it does not prove that backend-specific state locking support was resolved. Confirm instead: Concurrent runs against the same state are serialized according to the backend's supported locking contract.
Question 12
When maintaining Terraform modules used by several application teams, the following condition occurs: A web module hardcodes the subnet ID produced by a separate network module and fails when an environment provisions a different subnet. The module interface must remain stable and reviewable. Which outcome most directly validates the intended fix?
- Web resources use the subnet created in the same reviewed configuration and maintain a graph dependency on it.
- Normal CI initialization selects the reviewed compatible module version and unsupported major releases are not adopted silently.
- The child module receives the intended environment value without accessing variables declared only in its caller.
- New applications gain consistent module behavior and removing one key does not renumber unrelated module instances.
Explanation
Correct Answer
A:Web resources use the subnet created in the same reviewed configuration and maintain a graph dependency on it. Composed modules communicate through explicit outputs and inputs, permitting dependency-aware infrastructure assembly. It tests the correction: Pass module.network.subnet_id as an input into the web module rather than duplicating resource creation or guessed values.
Incorrect Answers
B:Normal CI initialization selects the reviewed compatible module version and unsupported major releases are not adopted silently. This might validate registry module version pin to avoid breaking releases, but it does not prove that module outputs coordinate dependencies instead of duplicate data was resolved. Confirm instead: Web resources use the subnet created in the same reviewed configuration and maintain a graph dependency on it.
C:The child module receives the intended environment value without accessing variables declared only in its caller. This might validate root and child variable scope isolation, but it does not prove that module outputs coordinate dependencies instead of duplicate data was resolved. Confirm instead: Web resources use the subnet created in the same reviewed configuration and maintain a graph dependency on it.
D:New applications gain consistent module behavior and removing one key does not renumber unrelated module instances. This might validate for_each at module call for multiple environments, but it does not prove that module outputs coordinate dependencies instead of duplicate data was resolved. Confirm instead: Web resources use the subnet created in the same reviewed configuration and maintain a graph dependency on it.
Question 13
During a cross-platform infrastructure standardization exercise, the following condition occurs: An operations group records a sequence of manual console clicks to provision identical test environments, but the resulting infrastructure differs between operators. The decision must preserve ownership and minimize undocumented changes. Which proposed remediation solves this failure without masking its cause?
- Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences.
- Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
- Configure separate authorized providers and identities for the hybrid environments while retaining a shared desired-state workflow.
- Express the intended resources in Terraform configuration and review its generated plan before applying a consistent desired state.
Explanation
Correct Answer
D:Express the intended resources in Terraform configuration and review its generated plan before applying a consistent desired state. Infrastructure as code declares a desired resource graph; repeated manual commands are not a reliable description of end state. Confirm the cause with: Compare the runbook's procedural steps with a version-controlled declarative inventory of desired resources and their attributes. A concrete acceptance test is: A clean environment can be reconstructed from the same reviewed configuration with repeatable managed resource attributes.
Incorrect Answers
A:Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences. This could address reusable environment definitions and reduced configuration drift, but it does not correct the indicated declarative desired state versus imperative console runbook mechanism. The relevant fix is: Express the intended resources in Terraform configuration and review its generated plan before applying a consistent desired state.
B:Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices. This could address terraform resource ownership boundary, but it does not correct the indicated declarative desired state versus imperative console runbook mechanism. The relevant fix is: Express the intended resources in Terraform configuration and review its generated plan before applying a consistent desired state.
C:Configure separate authorized providers and identities for the hybrid environments while retaining a shared desired-state workflow. This could address hybrid cloud workflow with distinct provider credentials, but it does not correct the indicated declarative desired state versus imperative console runbook mechanism. The relevant fix is: Express the intended resources in Terraform configuration and review its generated plan before applying a consistent desired state.
Question 14
When maintaining Terraform modules used by several application teams, the following condition occurs: A root Terraform stack tries to consume a network ID that the child module computes but does not publish as an output. The module interface must remain stable and reviewable. Which outcome most directly validates the intended fix?
- The caller can reference the exact authorized network ID without using private child implementation resource addresses.
- Initialization selects the network module code from the intended repository path and revision rather than unrelated root files.
- Normal CI initialization selects the reviewed compatible module version and unsupported major releases are not adopted silently.
- The child module receives the intended environment value without accessing variables declared only in its caller.
Explanation
Correct Answer
A:The caller can reference the exact authorized network ID without using private child implementation resource addresses. Output values are the supported way for a module to expose results to its parent; ordinary child locals are not exported. It tests the correction: Add the intended child output declaration and access it through module.network.<output_name> in the caller.
Incorrect Answers
B:Initialization selects the network module code from the intended repository path and revision rather than unrelated root files. This might validate git module source with explicit subdirectory, but it does not prove that child output exposure to calling module was resolved. Confirm instead: The caller can reference the exact authorized network ID without using private child implementation resource addresses.
C:Normal CI initialization selects the reviewed compatible module version and unsupported major releases are not adopted silently. This might validate registry module version pin to avoid breaking releases, but it does not prove that child output exposure to calling module was resolved. Confirm instead: The caller can reference the exact authorized network ID without using private child implementation resource addresses.
D:The child module receives the intended environment value without accessing variables declared only in its caller. This might validate root and child variable scope isolation, but it does not prove that child output exposure to calling module was resolved. Confirm instead: The caller can reference the exact authorized network ID without using private child implementation resource addresses.
Question 15
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 diagnostic check provides the strongest evidence for the underlying problem?
- Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
- Check the TF_LOG environment variable and filesystem permissions for the requested log path.
- Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
- Compare the declared resource address and remote identifier against the selected state snapshot.
Explanation
Correct Answer
B:Check the TF_LOG environment variable and filesystem permissions for the requested log path. TF_LOG_PATH selects a log destination but must be paired with an enabled TF_LOG level to produce verbose logs. A justified correction is: Set TF_LOG to the intended log level together with TF_LOG_PATH and rerun the failing Terraform command.
Incorrect Answers
A:Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. This inspects state list for tracking managed addresses rather than the reported tf_log_path requires enabled logging issue. The decisive investigation is: Check the TF_LOG environment variable and filesystem permissions for the requested log path.
C:Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data. This inspects tf_log for troubleshooting provider and cli diagnostics rather than the reported tf_log_path requires enabled logging issue. The decisive investigation is: Check the TF_LOG environment variable and filesystem permissions for the requested log path.
D:Compare the declared resource address and remote identifier against the selected state snapshot. This inspects terraform import binds preexisting remote object rather than the reported tf_log_path requires enabled logging issue. The decisive investigation is: Check the TF_LOG environment variable and filesystem permissions for the requested log path.
Question 16
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. What targeted engineering response should the team implement?
- Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content.
- Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
- Execute terraform init in the root configuration directory and resolve backend or provider setup failures before planning.
- Run terraform init to install and configure referenced child modules before attempting configuration validation.
Explanation
Correct Answer
D: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.
Incorrect Answers
A:Generate a versioned saved plan and apply the reviewed binary plan file within the approved run context, protecting its sensitive content. This could address saved execution plan for controlled deployment, but it does not correct the indicated module installation during initial setup mechanism. The relevant fix is: Run terraform init to install and configure referenced child modules before attempting configuration validation.
B: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 module installation during initial setup mechanism. The relevant fix is: 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 could address terraform init backend and provider preparation, but it does not correct the indicated module installation during initial setup mechanism. The relevant fix is: Run terraform init to install and configure referenced child modules before attempting configuration validation.
Question 17
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. Which Terraform configuration or workflow change most directly corrects the described issue?
- Require reviewed Terraform commits and corresponding plan evidence for production changes rather than console-only alterations.
- Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms.
- Configure separate authorized providers and identities for the hybrid environments while retaining a shared desired-state workflow.
- Run a reviewed Terraform plan before application, investigate unexpected replacements, and require appropriate authorization.
Explanation
Correct Answer
B:Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms. Terraform's common workflow does not make different cloud vendor APIs or resource type attributes interchangeable. Confirm the cause with: Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces. A concrete acceptance test is: Both platform implementations satisfy agreed application outputs using their own valid resource schemas and API constraints.
Incorrect Answers
A:Require reviewed Terraform commits and corresponding plan evidence for production changes rather than console-only alterations. This could address version-controlled iac change auditing, but it does not correct the indicated provider-neutral infrastructure pattern without identical resource types mechanism. The relevant fix is: Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms.
C:Configure separate authorized providers and identities for the hybrid environments while retaining a shared desired-state workflow. This could address hybrid cloud workflow with distinct provider credentials, but it does not correct the indicated provider-neutral infrastructure pattern without identical resource types mechanism. The relevant fix is: Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms.
D:Run a reviewed Terraform plan before application, investigate unexpected replacements, and require appropriate authorization. This could address terraform plan review as change safety barrier, but it does not correct the indicated provider-neutral infrastructure pattern without identical resource types mechanism. The relevant fix is: Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms.
Question 18
While diagnosing a Terraform state or import issue in a staging workspace, the following condition occurs: Terraform init fails sporadically with a provider connectivity error, but its normal CLI output lacks sufficient context for investigating the failed request. The investigator must avoid unreviewed state writes. Which outcome most directly validates the intended fix?
- The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract.
- The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds.
- The logs identify the failing initialization or provider interaction and can be disabled after troubleshooting.
- The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation.
Explanation
Correct Answer
C:The logs identify the failing initialization or provider interaction and can be disabled after troubleshooting. Terraform logging through TF_LOG adds CLI/provider diagnostics; verbose traces may include sensitive operational information. It tests the correction: Temporarily set TF_LOG to a useful level such as DEBUG or TRACE and capture restricted diagnostic output for the failing command.
Incorrect Answers
A:The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract. This might validate state list for tracking managed addresses, but it does not prove that tf_log for troubleshooting provider and cli diagnostics was resolved. Confirm instead: The logs identify the failing initialization or provider interaction and can be disabled after troubleshooting.
B:The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds. This might validate tf_log_path requires enabled logging, but it does not prove that tf_log for troubleshooting provider and cli diagnostics was resolved. Confirm instead: The logs identify the failing initialization or provider interaction and can be disabled after troubleshooting.
D:The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation. This might validate terraform import binds preexisting remote object, but it does not prove that tf_log for troubleshooting provider and cli diagnostics was resolved. Confirm instead: The logs identify the failing initialization or provider interaction and can be disabled after troubleshooting.
Question 19
As an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A platform team expects HCP Terraform to plan when its default branch changes, but the workspace is CLI-driven and no repository integration exists. The workflow must apply least privilege and preserve workspace isolation. Which diagnostic check provides the strongest evidence for the underlying problem?
- Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured.
- Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope.
- Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers.
- Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources.
Explanation
Correct Answer
C:Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers. VCS-driven HCP Terraform workflows respond to repository changes when the workspace is explicitly integrated with that source. A justified correction is: Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings.
Incorrect Answers
A:Inspect whether the root is connected to the correct HCP workspace and which execution mode is configured. This inspects hcp terraform remote execution and state hosting rather than the reported vcs-driven hcp terraform run on approved changes issue. The decisive investigation is: Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers.
B:Inspect which settings are truly shared and whether variable sets are already assigned at the correct project or workspace scope. This inspects hcp workspace variable sets share scoped configuration rather than the reported vcs-driven hcp terraform run on approved changes issue. The decisive investigation is: Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers.
D: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 vcs-driven hcp terraform run on approved changes issue. The decisive investigation is: Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers.
Question 20
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A Git-sourced security module pulls the latest default branch on every clean initialization, producing inconsistent firewall rules across deployment dates. The team must preserve reproducibility across callers. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Add the intended child output declaration and access it through module.network.<output_name> in the caller.
- Inspect the parent composition and whether the network child provides an output representing the created subnet.
- Update the module version together with dependent output references and validate the full root configuration before applying.
- Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
- Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch.
Explanation
Correct Answers
D:Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review. VCS module source versions are controlled by source refs rather than by Terraform registry module version constraints. Confirm the cause with: Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. A concrete acceptance test is: Two clean deployments retrieve the same module code revision and avoid unnoticed drift from default-branch updates. This forms one element of the required two-step diagnosis and correction.
E:Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. VCS module source versions are controlled by source refs rather than by Terraform registry module version constraints. A justified correction is: Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Add the intended child output declaration and access it through module.network.<output_name> in the caller. This relates to child output exposure to calling module rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. Then change: Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
B:Inspect the parent composition and whether the network child provides an output representing the created subnet. This relates to module outputs coordinate dependencies instead of duplicate data rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. Then change: Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.
C:Update the module version together with dependent output references and validate the full root configuration before applying. This relates to module upgrade plan review with changed outputs rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. Then change: Pin the Git module source to a reviewed immutable commit or controlled tag and update it through an explicit change review.