HashiCorp Terraform Associate 004 Practice Test 22
Question 210
During a controlled Terraform CLI recovery exercise, the following condition occurs: An engineer wants to know which indexed resources are managed before a refactor but greps the Terraform source and misses instances tracked in the active state. The same infrastructure must remain managed without unintended replacements. Which investigation would most directly establish the reported Terraform failure?
- Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
- Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
- Identify the exact resource instance address from terraform state list and inspect it with terraform state show.
- Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping.
Explanation
Correct Answer
B:Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths. terraform state list inspects state bindings, which can differ from textual declarations after drift or refactoring. A justified correction is: Use terraform state list to enumerate the actual addresses tracked in the selected workspace state.
Incorrect Answers
A:Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data. This inspects tf_log for troubleshooting provider and cli diagnostics rather than the reported state list for tracking managed addresses issue. The decisive investigation is: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
C:Identify the exact resource instance address from terraform state list and inspect it with terraform state show. This inspects state show inspects one stored resource instance rather than the reported state list for tracking managed addresses issue. The decisive investigation is: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
D:Inspect configuration import blocks, provider object IDs and candidate resource declarations for consistent address mapping. This inspects import blocks for reproducible adoption workflow rather than the reported state list for tracking managed addresses issue. The decisive investigation is: Inspect terraform state list output for complete resource addresses including count indexes, for_each keys, and module paths.
Question 211
During a cross-platform infrastructure standardization exercise, the following condition occurs: An organization provisions one application's storage in one cloud and DNS in another by maintaining incompatible manual deployment procedures. The decision must preserve ownership and minimize undocumented changes. Which TWO complementary choices identify the cause and implement the appropriate fix? Select TWO.
- Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences.
- Check whether each API integration has a Terraform provider and how dependencies pass resource attributes between configurations.
- Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms.
- Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values.
- Compare the runbook's procedural steps with a version-controlled declarative inventory of desired resources and their attributes.
Explanation
Correct Answers
B:Check whether each API integration has a Terraform provider and how dependencies pass resource attributes between configurations. Terraform provides a common declarative language while providers translate configuration operations into target platform APIs. A justified correction is: Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values. This forms one element of the required two-step diagnosis and correction.
D:Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values. Terraform provides a common declarative language while providers translate configuration operations into target platform APIs. Confirm the cause with: Check whether each API integration has a Terraform provider and how dependencies pass resource attributes between configurations. A concrete acceptance test is: One reviewed workflow coordinates both cloud resources without pretending Terraform replaces the different underlying provider APIs. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences. This relates to reusable environment definitions and reduced configuration drift rather than the matching diagnosis-and-remediation pair required here. Check: Check whether each API integration has a Terraform provider and how dependencies pass resource attributes between configurations. Then change: Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values.
C:Create separate provider-aware modules behind a shared application interface rather than treating resource type names as portable across platforms. This relates to provider-neutral infrastructure pattern without identical resource types rather than the matching diagnosis-and-remediation pair required here. Check: Check whether each API integration has a Terraform provider and how dependencies pass resource attributes between configurations. Then change: Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values.
E:Compare the runbook's procedural steps with a version-controlled declarative inventory of desired resources and their attributes. This relates to declarative desired state versus imperative console runbook rather than the matching diagnosis-and-remediation pair required here. Check: Check whether each API integration has a Terraform provider and how dependencies pass resource attributes between configurations. Then change: Use the relevant approved providers in Terraform and define cross-service references through managed configuration outputs or values.
Question 212
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: Two engineers initialize the same project at different times and unexpectedly use different provider binaries after compatible new releases appear. The engineers must keep provider choices and identities reproducible. Which proposed remediation solves this failure without masking its cause?
- Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID.
- Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
- Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
- Install and configure the appropriate provider through terraform init so Terraform can use its resource and data source implementations.
Explanation
Correct Answer
C:Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions. Version constraints define acceptable releases; the dependency lock file records concrete chosen provider selections and checksums. Confirm the cause with: Compare.terraform.lock.hcl checksums and selected versions against required_providers constraints and provider init logs. A concrete acceptance test is: Two clean checkouts select the reviewed compatible provider binaries rather than silently upgrading independently.
Incorrect Answers
A:Use resource references and output values so computed identifiers resolve after creation rather than hardcoding an invented ID. This could address resource attribute outputs supplied by state, but it does not correct the indicated dependency lock file reproducible selection mechanism. The relevant fix is: Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
B:Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation. This could address controlled provider upgrade using init upgrade, but it does not correct the indicated dependency lock file reproducible selection mechanism. The relevant fix is: Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
D:Install and configure the appropriate provider through terraform init so Terraform can use its resource and data source implementations. This could address provider plugin manages api resources and data reads, but it does not correct the indicated dependency lock file reproducible selection mechanism. The relevant fix is: Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
Question 213
During an isolated staging rehearsal of the Terraform workflow, the following condition occurs: A team wants Terraform to stop managing a legacy storage bucket but must retain the real bucket and its contents for a migration. The operator must obtain auditable evidence before touching production resources. Select TWO: the decisive first check and the change that directly addresses the problem.
- Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
- Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure.
- Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
- Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.
- Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order.
Explanation
Correct Answers
A:Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. Destroying a resource and removing a state binding are different operations with different effects on physical infrastructure. Confirm the cause with: Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. A concrete acceptance test is: The state no longer tracks the bucket and verification confirms the remote bucket and data still exist. This forms one element of the required two-step diagnosis and correction.
B:Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. Destroying a resource and removing a state binding are different operations with different effects on physical infrastructure. A justified correction is: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
C: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: Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. Then change: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
D:Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure. This relates to terraform destroy is managed-scope deletion rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. Then change: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
E: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 bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. Then change: Use an appropriate removed block with destroy = false or a controlled state rm workflow while preserving the remote object.
Question 214
As the deployment team prepares a reviewed Terraform CLI change, 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 change must preserve the distinction between previewing and modifying infrastructure. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply.
- Inspect the generated plan and approval prompt before deciding whether the operation has proceeded.
- Inspect remaining pending actions with a full plan and identify why targeted operations were introduced.
- Inspect the module source declaration and initialization logs for the missing module download.
Explanation
Correct Answer
C:Inspect remaining pending actions with a full plan and identify why targeted operations were introduced. Targeting can bypass part of the configuration graph and should not be a standard substitute for comprehensive reconciliation. A justified correction is: Use the normal full dependency-aware plan and apply workflow; reserve targeting for exceptional recovery rather than routine deployment. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team uses….
Incorrect Answers
A:Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply. This inspects plan distinguishes replacement from in-place update rather than the reported targeted apply limitations for normal changes issue. The decisive investigation is: Inspect remaining pending actions with a full plan and identify why targeted operations were introduced.
B:Inspect the generated plan and approval prompt before deciding whether the operation has proceeded. This inspects apply requires approval unless automated rather than the reported targeted apply limitations for normal changes issue. The decisive investigation is: Inspect remaining pending actions with a full plan and identify why targeted operations were introduced. This matters here because as the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A team uses….
D:Inspect the module source declaration and initialization logs for the missing module download. This inspects module installation during initial setup rather than the reported targeted apply limitations for normal changes issue. The decisive investigation is: Inspect remaining pending actions with a full plan and identify why targeted operations were introduced.
Question 215
During a controlled module integration test for a production Terraform stack, the following condition occurs: A module receives instance sizes keyed by environment name, but the configuration tries to read them using a numeric position as if they were a list. The desired fix must avoid unrelated resource changes. Which outcome most directly validates the intended fix?
- The plan defers the lookup when needed and avoids failing on a remote object that is not yet created.
- The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
- Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions.
- The plan selects the correct per-environment instance size without relying on arbitrary key ordering.
Explanation
Correct Answer
D:The plan selects the correct per-environment instance size without relying on arbitrary key ordering. Terraform collection types have distinct semantics: maps are addressed by keys while lists are ordered index-based sequences. It tests the correction: Use an appropriate map type with key-based lookup or redesign the input as a list if order-based indexing is truly intended.
Incorrect Answers
A:The plan defers the lookup when needed and avoids failing on a remote object that is not yet created. This might validate data source read ordering versus creation, but it does not prove that map versus list addressing for environment inputs was resolved. Confirm instead: The plan selects the correct per-environment instance size without relying on arbitrary key ordering.
B:The plan records the authorized region value, and a second run produces the same selection under the same variable inputs. This might validate variable input precedence and configuration injection, but it does not prove that map versus list addressing for environment inputs was resolved. Confirm instead: The plan selects the correct per-environment instance size without relying on arbitrary key ordering.
C:Invalid caller objects fail early, while well-typed nested values reach their intended configuration expressions. This might validate object type contract with nested attributes, but it does not prove that map versus list addressing for environment inputs was resolved. Confirm instead: The plan selects the correct per-environment instance size without relying on arbitrary key ordering.
Question 216
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A Terraform engineer wants to reference an existing DNS zone owned by another team but declares a new resource block and unintentionally plans to create a second zone. The engineer must respect declared resource contracts and data security boundaries. Which investigation would most directly establish the reported Terraform failure?
- 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 references and whether the data source must wait for a managed resource's creation.
- Inspect the provider resource schema for supported write-only arguments and associated rotation or version requirements.
- Inspect the child module output declarations and the root's module block name and available output values.
Explanation
Correct Answer
A:Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema. A data block queries information from remote systems while a resource block declares an object Terraform manages across its lifecycle. A justified correction is: Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage.
Incorrect Answers
B:Inspect the graph references and whether the data source must wait for a managed resource's creation. This inspects data source read ordering versus creation rather than the reported data source versus managed resource definition issue. The decisive investigation is: Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema.
C:Inspect the provider resource schema for supported write-only arguments and associated rotation or version requirements. This inspects write-only provider argument for managed secret rotation rather than the reported data source versus managed resource definition issue. The decisive investigation is: Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema.
D:Inspect the child module output declarations and the root's module block name and available output values. This inspects module output references across composition rather than the reported data source versus managed resource definition issue. The decisive investigation is: Inspect whether the zone should be managed or merely read, and compare the resource block with the provider's data source schema.
Question 217
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: A Terraform project uses the same cloud provider in development and production accounts but a resource unexpectedly lands in the default development account. The configuration should behave consistently without broadening access. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration.
- Move state to an access-controlled encrypted backend, restrict readers, and avoid storing secret inputs where ephemeral paths are supported.
- Check which resource attributes are computed by the provider and how state records them after successful operations.
- Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required.
- Define explicitly aliased provider configurations and assign the production resource to the intended alias.
Explanation
Correct Answers
A:Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration. A provider alias selects an alternate configured provider instance; resource blocks must reference it to avoid a default-account fallback. A justified correction is: Define explicitly aliased provider configurations and assign the production resource to the intended alias. This forms one element of the required two-step diagnosis and correction. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: A….
E:Define explicitly aliased provider configurations and assign the production resource to the intended alias. A provider alias selects an alternate configured provider instance; resource blocks must reference it to avoid a default-account fallback. Confirm the cause with: Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration. A concrete acceptance test is: The plan identifies production-account resources under the intended provider configuration while development objects remain separate. This forms one element of the required two-step diagnosis and correction. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: A….
Incorrect Answers
B:Move state to an access-controlled encrypted backend, restrict readers, and avoid storing secret inputs where ephemeral paths are supported. This relates to state as sensitive operational metadata rather than the matching diagnosis-and-remediation pair required here. Check: Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration. Then change: Define explicitly aliased provider configurations and assign the production resource to the intended alias.
C:Check which resource attributes are computed by the provider and how state records them after successful operations. This relates to resource attribute outputs supplied by state rather than the matching diagnosis-and-remediation pair required here. Check: Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration. Then change: Define explicitly aliased provider configurations and assign the production resource to the intended alias.
D:Pass the correct provider configuration explicitly through the module's providers map and declare configuration_aliases when required. This relates to module provider mapping for aliased configurations rather than the matching diagnosis-and-remediation pair required here. Check: Inspect provider alias blocks and the resource's provider selection, including default identity and account-specific configuration. Then change: Define explicitly aliased provider configurations and assign the production resource to the intended alias. This matters here because during a separate-region Terraform rollout in an approved staging account, the following condition occurs: A….
Question 218
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A database argument changes and Terraform shows a replacement action, but the change reviewer reads only the new attribute value and overlooks deletion risk. The change must preserve the distinction between previewing and modifying infrastructure. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.
- Reformat the affected .tf files using terraform fmt and rerun both style checking and validation independently.
- Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
- Inspect the .terraform working directory and initialization output for missing backend, module, and provider setup.
- Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply.
- Decide whether to restore declared configuration or intentionally adopt the outside value, then plan under the chosen ownership policy.
Explanation
Correct Answers
B:Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying. Provider schemas can require replacement for some attribute changes; plan review exposes this before an apply. Confirm the cause with: Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply. A concrete acceptance test is: The execution plan explicitly identifies replacement impact and deployment approval records show the risk was addressed. This forms one element of the required two-step diagnosis and correction.
D:Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply. Provider schemas can require replacement for some attribute changes; plan review exposes this before an apply. A justified correction is: Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Reformat the affected.tf files using terraform fmt and rerun both style checking and validation independently. This relates to ci terraform fmt check distinguishes style from validity rather than the matching diagnosis-and-remediation pair required here. Check: Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply. Then change: Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
C:Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. This relates to terraform init backend and provider preparation rather than the matching diagnosis-and-remediation pair required here. Check: Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply. Then change: Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
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: Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply. Then change: Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
Question 219
During a governed HCP Terraform workspace rollout, 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 organization must retain auditable authorization for runs and state. What targeted engineering response should the team implement?
- Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values.
- Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate.
- Grant scoped team access with read or plan permissions as appropriate, reserving apply and administration for authorized groups.
- Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently.
Explanation
Correct Answer
D:Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently. HCP workspace authentication and cloud provider authentication protect different services and cannot substitute for each other. Confirm the cause with: Distinguish HCP Terraform API authentication from the separate credentials used by Terraform providers for cloud resources. A concrete acceptance test is: The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities.
Incorrect Answers
A:Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values. This could address hcp workspace variable sets share scoped configuration, but it does not correct the indicated hcp terraform cli login and execution credentials mechanism. The relevant fix is: Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently.
B:Define the supported cloud integration block with the intended organization and workspace selection, then initialize and authenticate. This could address terraform cloud block hcp workspace integration, but it does not correct the indicated hcp terraform cli login and execution credentials mechanism. The relevant fix is: Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently.
C:Grant scoped team access with read or plan permissions as appropriate, reserving apply and administration for authorized groups. This could address hcp terraform team permissions and audit trail, but it does not correct the indicated hcp terraform cli login and execution credentials mechanism. The relevant fix is: Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently.
Question 220
When reviewing a reusable Terraform HCL configuration before deployment, 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 engineer must respect declared resource contracts and data security boundaries. What measurable postchange observation would confirm that the correction worked?
- A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts.
- The plan selects the correct per-environment instance size without relying on arbitrary key ordering.
- The module applies under least privilege without retaining the secret in source control or ordinary state output.
- Terraform reads the existing DNS zone information and plans no duplicate zone creation from the lookup alone.
Explanation
Correct Answer
A: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. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A pipeline….
Incorrect Answers
B:The plan selects the correct per-environment instance size without relying on arbitrary key ordering. This might validate map versus list addressing for environment inputs, 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 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. This matters here because when reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A pipeline….
D:Terraform reads the existing DNS zone information and plans no duplicate zone creation from the lookup alone. This might validate data source versus managed resource definition, 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.