HashiCorp Terraform Associate 004 Practice Test 1
Question 1
During a controlled module integration test for a production Terraform stack, the following condition occurs: A database provider supports a write-only password argument, but an engineer uses a normal stored password argument and checks the plan artifact into an unsecured archive. The desired fix must avoid unrelated resource changes. What acceptance evidence best establishes that the Terraform issue has been resolved?
- The provider receives the approved new secret without persisting its plaintext in Terraform's plan or state snapshots.
- 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 plan resolves the intended instance and avoids accidental replacement caused solely by a configuration address rename.
Explanation
Correct Answer
A:The provider receives the approved new secret without persisting its plaintext in Terraform's plan or state snapshots. Write-only resource arguments accept values during an operation without saving those values into Terraform's managed state. It tests the correction: Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required.
Incorrect Answers
B:A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts. This might validate ephemeral variable for short-lived token in terraform 1.12, but it does not prove that write-only provider argument for managed secret rotation was resolved. Confirm instead: The provider receives the approved new secret without persisting its plaintext in Terraform's plan or state snapshots.
C: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 write-only provider argument for managed secret rotation was resolved. Confirm instead: The provider receives the approved new secret without persisting its plaintext in Terraform's plan or state snapshots.
D:The plan resolves the intended instance and avoids accidental replacement caused solely by a configuration address rename. This might validate resource addressing with repeated instances, but it does not prove that write-only provider argument for managed secret rotation was resolved. Confirm instead: The provider receives the approved new secret without persisting its plaintext in Terraform's plan or state snapshots.
Question 2
During a controlled Terraform CLI recovery exercise, 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 same infrastructure must remain managed without unintended replacements. Which diagnostic check provides the strongest evidence for the underlying problem?
- Check the TF_LOG environment variable and filesystem permissions for the requested log path.
- Compare the declared resource address and remote identifier against the selected state snapshot.
- Identify the exact resource instance address from terraform state list and inspect it with terraform state show.
- Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
Explanation
Correct Answer
D:Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data. Terraform logging through TF_LOG adds CLI/provider diagnostics; verbose traces may include sensitive operational information. A justified correction is: 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:Check the TF_LOG environment variable and filesystem permissions for the requested log path. This inspects tf_log_path requires enabled logging rather than the reported tf_log for troubleshooting provider and cli diagnostics issue. The decisive investigation is: Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
B: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 for troubleshooting provider and cli diagnostics issue. The decisive investigation is: Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
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 tf_log for troubleshooting provider and cli diagnostics issue. The decisive investigation is: Inspect the failure mode and select an appropriate TF_LOG verbosity level while protecting credential-bearing log data.
Question 3
During a controlled module integration test for a production Terraform stack, the following condition occurs: A Terraform configuration changes a resource to for_each and a team still refers to the unkeyed address, causing an invalid reference or planned replacement. The desired fix must avoid unrelated resource changes. Which proposed remediation solves this failure without masking its cause?
- Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage.
- Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.
- Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow.
- Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
Explanation
Correct Answer
B:Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring. Repeated resources have instance addresses that include their keys or indexes, rather than a single unqualified instance address. Confirm the cause with: Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. A concrete acceptance test is: The plan resolves the intended instance and avoids accidental replacement caused solely by a configuration address rename.
Incorrect Answers
A:Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage. This could address data source versus managed resource definition, but it does not correct the indicated resource addressing with repeated instances mechanism. The relevant fix is: Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.
C:Rotate the exposed token and retrieve needed credentials through an approved Vault-based ephemeral or runtime authentication flow. This could address vault credential lookup without hardcoding secret values, but it does not correct the indicated resource addressing with repeated instances mechanism. The relevant fix is: Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.
D:Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate. This could address for_each stable identity instead of count index, but it does not correct the indicated resource addressing with repeated instances mechanism. The relevant fix is: Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.
Question 4
While migrating a manually maintained development environment into reviewed Terraform configuration, the following condition occurs: Three product teams rebuild nearly identical staging networks by copying browser instructions, but naming and access rules diverge by team. The team must establish a reproducible and auditable infrastructure change. Which diagnostic check provides the strongest evidence for the underlying problem?
- Inspect whether the deployment process captures a proposed execution plan and identifies create, update, delete, and replacement actions.
- Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces.
- Inspect whether infrastructure choices and dependencies exist as tracked Terraform files or only as undocumented console modifications.
- Compare repeated environment requirements against current configuration differences and find parameters that should vary intentionally.
Explanation
Correct Answer
D:Compare repeated environment requirements against current configuration differences and find parameters that should vary intentionally. Shared IaC patterns reduce accidental divergence without requiring every environment to have identical parameters. A justified correction is: Use reusable Terraform modules and explicit environment inputs to encode shared rules while allowing reviewed differences.
Incorrect Answers
A:Inspect whether the deployment process captures a proposed execution plan and identifies create, update, delete, and replacement actions. This inspects terraform plan review as change safety barrier rather than the reported reusable environment definitions and reduced configuration drift issue. The decisive investigation is: Compare repeated environment requirements against current configuration differences and find parameters that should vary intentionally.
B:Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces. This inspects provider-neutral infrastructure pattern without identical resource types rather than the reported reusable environment definitions and reduced configuration drift issue. The decisive investigation is: Compare repeated environment requirements against current configuration differences and find parameters that should vary intentionally.
C:Inspect whether infrastructure choices and dependencies exist as tracked Terraform files or only as undocumented console modifications. This inspects terraform configuration as reviewable infrastructure specification rather than the reported reusable environment definitions and reduced configuration drift issue. The decisive investigation is: Compare repeated environment requirements against current configuration differences and find parameters that should vary intentionally.
Question 5
During a separate-region Terraform rollout in an approved staging account, the following condition occurs: A maintenance engineer changes a provider constraint but an existing workspace continues using an older locked plugin even though a newer permitted version is needed. The configuration should behave consistently without broadening access. Select TWO: the decisive first check and the change that directly addresses the problem.
- Inspect resource and output attributes persisted in the state and identify whether credential or connection values are present.
- Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior.
- Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions.
- Correct the provider's supported credentials or least-privilege permissions without changing a successfully installed plugin.
- Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
Explanation
Correct Answers
B:Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. Terraform init normally honors locked versions; -upgrade allows choosing newer compatible selections under the declared constraints. A justified correction is: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation. This forms one element of the required two-step diagnosis and correction.
E:Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation. Terraform init normally honors locked versions; -upgrade allows choosing newer compatible selections under the declared constraints. Confirm the cause with: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. A concrete acceptance test is: The plan uses the reviewed new compatible provider version and the updated lock file captures it for teammates. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Inspect resource and output attributes persisted in the state and identify whether credential or connection values are present. This relates to state as sensitive operational metadata rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. Then change: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
C:Commit the dependency lock file for a root configuration and use ordinary terraform init to honor its selected provider versions. This relates to dependency lock file reproducible selection rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. Then change: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
D:Correct the provider's supported credentials or least-privilege permissions without changing a successfully installed plugin. This relates to provider authorization versus installation failure rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. Then change: Review the upgrade impact and run terraform init -upgrade intentionally, then commit the updated lock selection after validation.
Question 6
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: An external record lookup runs during planning even though the underlying managed resource is not ready and the data source returns no matching object. The engineer must respect declared resource contracts and data security boundaries. Which diagnostic check provides the strongest evidence for the underlying problem?
- Inspect the graph references and whether the data source must wait for a managed resource's creation.
- Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration.
- Inspect the child module output declarations and the root's module block name and available output values.
- Inspect the variable's ephemeral setting and whether downstream use is an allowed ephemeral context such as provider configuration.
Explanation
Correct Answer
A:Inspect the graph references and whether the data source must wait for a managed resource's creation. Data reads may happen during planning unless their prerequisites require deferral; dependency structure matters for lookup timing. A justified correction is: Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists.
Incorrect Answers
B:Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. This inspects resource addressing with repeated instances rather than the reported data source read ordering versus creation issue. The decisive investigation is: Inspect the graph references and whether the data source must wait for a managed resource's creation.
C: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 read ordering versus creation issue. The decisive investigation is: Inspect the graph references and whether the data source must wait for a managed resource's creation.
D:Inspect the variable's ephemeral setting and whether downstream use is an allowed ephemeral context such as provider configuration. This inspects ephemeral variable for short-lived token in terraform 1.12 rather than the reported data source read ordering versus creation issue. The decisive investigation is: Inspect the graph references and whether the data source must wait for a managed resource's creation.
Question 7
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. Select TWO: the decisive first check and the change that directly addresses the problem.
- Encode the network and firewall resources in version-controlled Terraform and require a reviewed plan in the change process.
- Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces.
- Run a reviewed Terraform plan before application, investigate unexpected replacements, and require appropriate authorization.
- Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
- Identify which attributes Terraform declares and which external system writes to the same managed object between runs.
Explanation
Correct Answers
D: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. This forms one element of the required two-step diagnosis and correction.
E:Identify which attributes Terraform declares and which external system writes to the same managed object between runs. Declarative reconciliation requires a clear ownership contract; competing controllers can create perpetual drift. A justified correction is: Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices. This forms one element of the required two-step diagnosis and correction.
Incorrect Answers
A:Encode the network and firewall resources in version-controlled Terraform and require a reviewed plan in the change process. This relates to terraform configuration as reviewable infrastructure specification rather than the matching diagnosis-and-remediation pair required here. Check: Identify which attributes Terraform declares and which external system writes to the same managed object between runs. Then change: Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
B:Compare provider-specific resource schemas, instance properties, network dependencies, and modules' input interfaces. This relates to provider-neutral infrastructure pattern without identical resource types rather than the matching diagnosis-and-remediation pair required here. Check: Identify which attributes Terraform declares and which external system writes to the same managed object between runs. Then change: Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
C:Run a reviewed Terraform plan before application, investigate unexpected replacements, and require appropriate authorization. This relates to terraform plan review as change safety barrier rather than the matching diagnosis-and-remediation pair required here. Check: Identify which attributes Terraform declares and which external system writes to the same managed object between runs. Then change: Assign authoritative ownership to one control plane or explicitly divide attribute responsibility using supported lifecycle practices.
Question 8
As an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A company creates production and staging workspaces for dozens of product teams in one flat list, and support staff cannot manage their permissions cleanly. The workflow must apply least privilege and preserve workspace isolation. What acceptance evidence best establishes that the Terraform issue has been resolved?
- Teams locate and administer their approved workspaces without accidentally gaining access to unrelated project state.
- Plans and applies execute in the intended HCP run environment with centralized state and auditable run outcomes.
- A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals.
- A shared setting update reaches exactly the approved workspaces while unrelated projects retain independent configuration.
Explanation
Correct Answer
A:Teams locate and administer their approved workspaces without accidentally gaining access to unrelated project state. HCP projects organize related workspaces and can simplify team governance without merging their independent state snapshots. It tests the correction: Organize related workspaces into appropriate HCP projects and apply reviewed permissions and conventions for each group.
Incorrect Answers
B:Plans and applies execute in the intended HCP run environment with centralized state and auditable run outcomes. This might validate hcp terraform remote execution and state hosting, but it does not prove that hcp projects group workspaces by ownership was resolved. Confirm instead: Teams locate and administer their approved workspaces without accidentally gaining access to unrelated project state.
C:A noncompliant plan is rejected at policy evaluation while a compliant plan continues through its required approvals. This might validate hcp terraform policy enforcement governance, but it does not prove that hcp projects group workspaces by ownership was resolved. Confirm instead: Teams locate and administer their approved workspaces without accidentally gaining access to unrelated project state.
D:A shared setting update reaches exactly the approved workspaces while unrelated projects retain independent configuration. This might validate hcp workspace variable sets share scoped configuration, but it does not prove that hcp projects group workspaces by ownership was resolved. Confirm instead: Teams locate and administer their approved workspaces without accidentally gaining access to unrelated project state.
Question 9
During a controlled module integration test for a production Terraform stack, the following condition occurs: An automated Terraform run uses an obsolete deployment region even though an operator changed the default region in variables.tf, because another source supplies an overriding value. The desired fix must avoid unrelated resource changes. What measurable postchange observation would confirm that the correction worked?
- CLI output is appropriately redacted and the selected secret-handling path avoids unwanted persistent state exposure.
- An invalid subnet input fails with a clear Terraform validation error while authorized values continue to plan.
- The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
- Routine Terraform output suppresses the marked secret while protected state access remains restricted.
Explanation
Correct Answer
C:The plan records the authorized region value, and a second run produces the same selection under the same variable inputs. Terraform variable defaults apply only when no higher-precedence assignment supplies a different value. It tests the correction: Remove or update the overriding variable source and make the intended region input explicit for the controlled run.
Incorrect Answers
A:CLI output is appropriately redacted and the selected secret-handling path avoids unwanted persistent state exposure. This might validate sensitive variable does not erase state secrets, but it does not prove that variable input precedence and configuration injection was resolved. Confirm instead: The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
B:An invalid subnet input fails with a clear Terraform validation error while authorized values continue to plan. This might validate input variable custom validation rule, but it does not prove that variable input precedence and configuration injection was resolved. Confirm instead: The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
D:Routine Terraform output suppresses the marked secret while protected state access remains restricted. This might validate sensitive output display behavior, but it does not prove that variable input precedence and configuration injection was resolved. Confirm instead: The plan records the authorized region value, and a second run produces the same selection under the same variable inputs.
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.