HashiCorp Terraform Associate 004 Practice Test 50
Question 490
During a controlled module integration test for a production Terraform stack, the following condition occurs: An operator adds a Terraform check asserting that an HTTP service is healthy and expects a failed check to halt the same apply as a mandatory precondition. The desired fix must avoid unrelated resource changes. Which proposed remediation solves this failure without masking its cause?
- Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values.
- Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
- Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
- Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
Explanation
Correct Answer
D:Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports. Check blocks generally issue warnings rather than blocking applies; lifecycle conditions enforce resource pre/post invariants. Confirm the cause with: Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version. A concrete acceptance test is: A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: An….
Incorrect Answers
A:Declare a suitable object type such as object({ cidr = string, enabled = bool }) and supply matching attribute values. This could address object type contract with nested attributes, but it does not correct the indicated check block observability versus hard failure mechanism. The relevant fix is: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
B: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 check block observability versus hard failure mechanism. The relevant fix is: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
C:Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource. This could address resource precondition for unsafe configuration, but it does not correct the indicated check block observability versus hard failure mechanism. The relevant fix is: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
Question 491
During a controlled module integration test for a production Terraform stack, the following condition occurs: A server requires a network subnet that Terraform creates in the same plan, but the author hardcodes the expected subnet name and gets an ordering error. The desired fix must avoid unrelated resource changes. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first.
- Check the for_each keys and the collection shape of the declared resource instances.
- Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings.
- Inspect the variable's ephemeral setting and whether downstream use is an allowed ephemeral context such as provider configuration.
Explanation
Correct Answer
C:Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings. A reference to another resource attribute establishes an implicit graph dependency and avoids fragile guessed identifiers. A justified correction is: Use the managed subnet resource's appropriate output attribute directly in the server configuration.
Incorrect Answers
A:Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first. This inspects explicit depends_on for behavior-only dependencies rather than the reported implicit dependency through resource attribute reference issue. The decisive investigation is: Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings.
B:Check the for_each keys and the collection shape of the declared resource instances. This inspects collection references for for_each resources rather than the reported implicit dependency through resource attribute reference issue. The decisive investigation is: Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings.
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 implicit dependency through resource attribute reference issue. The decisive investigation is: Inspect the subnet and server blocks for real attribute references versus unrelated hardcoded strings.
Question 492
During an operational review of a Terraform state backend, the following condition occurs: A developer switches Terraform CLI workspaces using a local backend and assumes all named workspaces write to the same terraform.tfstate file. The team must preserve managed-object identity and safe collaboration. Which outcome most directly validates the intended fix?
- 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.
- Concurrent runs against the same state are serialized according to the backend's supported locking contract.
- The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement.
Explanation
Correct Answer
A:A plan in staging reads staging bindings while a default workspace plan remains independent. Local backend workspaces have separate state snapshots, though they share the same configuration and local backend mechanism. It tests the correction: Select the intended workspace before planning and check the corresponding workspace-specific state directory. This matters here because a developer switches Terraform CLI workspaces using a local backend and assumes all named workspaces write to the….
Incorrect Answers
B: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 local workspace state separation was resolved. Confirm instead: A plan in staging reads staging bindings while a default workspace plan remains independent. This matters here because a developer switches Terraform CLI workspaces using a local backend and assumes all named workspaces write to the….
C:Concurrent runs against the same state are serialized according to the backend's supported locking contract. This might validate backend-specific state locking support, but it does not prove that local workspace state separation was resolved. Confirm instead: A plan in staging reads staging bindings while a default workspace plan remains independent. This matters here because a developer switches Terraform CLI workspaces using a local backend and assumes all named workspaces write to the….
D:The resource identity is preserved through a state address move and the refactor avoids unnecessary physical replacement. This might validate moved block preserves state during address refactor, but it does not prove that local workspace state separation was resolved. Confirm instead: A plan in staging reads staging bindings while a default workspace plan remains independent.
Question 493
When reviewing a reusable Terraform HCL configuration before deployment, the following condition occurs: A compliance controller adds a standard cost tag after provisioning and each Terraform plan tries to revert the independently managed tag. The engineer must respect declared resource contracts and data security boundaries. What targeted engineering response should the team implement?
- Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage.
- Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship.
- Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required.
- Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.
Explanation
Correct Answer
D:Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated. ignore_changes omits configured attribute differences from update decisions and should not be a blanket excuse to hide drift. Confirm the cause with: Identify the externally owned attribute and verify that ignoring it does not mask business-critical configuration drift. A concrete acceptance test is: Normal plans do not oscillate the delegated tag, while other resource drift remains visible and managed.
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 ignore_changes ownership of externally managed tag mechanism. The relevant fix is: Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.
B:Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship. This could address explicit depends_on for behavior-only dependencies, but it does not correct the indicated ignore_changes ownership of externally managed tag mechanism. The relevant fix is: Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.
C:Supply a supported write-only password argument from an ephemeral value and use the provider's explicit version mechanism when required. This could address write-only provider argument for managed secret rotation, but it does not correct the indicated ignore_changes ownership of externally managed tag mechanism. The relevant fix is: Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.
Question 494
During a controlled module integration test for a production Terraform stack, the following condition occurs: A server requires a network subnet that Terraform creates in the same plan, but the author hardcodes the expected subnet name and gets an ordering error. The desired fix must avoid unrelated resource changes. Which outcome most directly validates the intended fix?
- Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays.
- The root plan resolves the supported module output without attempting to address private child resource internals.
- Terraform reads the existing DNS zone information and plans no duplicate zone creation from the lookup alone.
- Development and production plan different approved retention settings with otherwise shared definitions and no copied modules.
Explanation
Correct Answer
A:Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays. A reference to another resource attribute establishes an implicit graph dependency and avoids fragile guessed identifiers. It tests the correction: Use the managed subnet resource's appropriate output attribute directly in the server configuration.
Incorrect Answers
B:The root plan resolves the supported module output without attempting to address private child resource internals. This might validate module output references across composition, but it does not prove that implicit dependency through resource attribute reference was resolved. Confirm instead: Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays.
C: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 implicit dependency through resource attribute reference was resolved. Confirm instead: Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays.
D:Development and production plan different approved retention settings with otherwise shared definitions and no copied modules. This might validate conditional expressions for environment configuration, but it does not prove that implicit dependency through resource attribute reference was resolved. Confirm instead: Terraform builds the dependency edge and provisions the subnet before the dependent server without manual delays.
Question 495
During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A root Terraform configuration calls a child module with a relative source path that points to a nonexistent sibling directory on the CI runner. The team must preserve reproducibility across callers. Which outcome most directly validates the intended fix?
- The child module files are located consistently by local and CI runs without copying the same definitions into the root.
- Terraform fetches the intended module revision without mixing registry-only and Git source selection semantics.
- Web resources use the subnet created in the same reviewed configuration and maintain a graph dependency on it.
- Dependent modules receive only necessary authorized values and terminal output does not reveal secret material.
Explanation
Correct Answer
A:The child module files are located consistently by local and CI runs without copying the same definitions into the root. Local module sources are paths resolved relative to the calling module; incorrect layout cannot be repaired by provider credentials. It tests the correction: Set the source to an accurate local relative module path and initialize or validate from the correct root directory. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A root….
Incorrect Answers
B:Terraform fetches the intended module revision without mixing registry-only and Git source selection semantics. This might validate registry module source naming contract, but it does not prove that local child module source path resolution was resolved. Confirm instead: The child module files are located consistently by local and CI runs without copying the same definitions into the root.
C:Web resources use the subnet created in the same reviewed configuration and maintain a graph dependency on it. This might validate module outputs coordinate dependencies instead of duplicate data, but it does not prove that local child module source path resolution was resolved. Confirm instead: The child module files are located consistently by local and CI runs without copying the same definitions into the root.
D:Dependent modules receive only necessary authorized values and terminal output does not reveal secret material. This might validate sensitive input forwarding between nested modules, but it does not prove that local child module source path resolution was resolved. Confirm instead: The child module files are located consistently by local and CI runs without copying the same definitions into the root.
Question 496
During an isolated staging rehearsal of the Terraform workflow, 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 operator must obtain auditable evidence before touching production resources. Select TWO: the decisive first check and the change that directly addresses the problem.
- Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics.
- 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.
- Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes.
- Review and approve a safe migration or redesign the configuration when replacement is unacceptable, rather than blindly applying.
Explanation
Correct Answers
B: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. This matters here because a database argument changes and Terraform shows a replacement action, but the change reviewer reads only the new….
E: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. This matters here because a database argument changes and Terraform shows a replacement action, but the change reviewer reads only the new….
Incorrect Answers
A:Inspect the terraform fmt -check -diff output and separate style failures from terraform validate diagnostics. 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: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. This matters here because a database argument changes and Terraform shows a replacement action, but the change reviewer reads only the new….
D:Run terraform fmt or terraform fmt -recursive where intended, then review the resulting source formatting changes. This relates to terraform fmt normalizes hcl style 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 497
As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A novice team runs terraform apply in a directory containing unreviewed edits and cannot explain the difference between proposed and actual resource changes. The change must preserve the distinction between previewing and modifying infrastructure. Which proposed remediation solves this failure without masking its cause?
- Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
- Reformat the affected .tf files using terraform fmt and rerun both style checking and validation independently.
- Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources.
- Use terraform validate to catch configuration errors and separately run plan or controlled provider checks to assess remote feasibility.
Explanation
Correct Answer
A:Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment. Terraform's normal lifecycle separates desired-state authoring and plan evaluation from the operation that changes managed infrastructure. Confirm the cause with: Check whether configuration was written, providers initialized, execution plan inspected, and the apply decision approved in the intended order. A concrete acceptance test is: A planned change is inspected before approval, then the resulting infrastructure matches the reviewed configuration where supported.
Incorrect Answers
B:Reformat the affected.tf files using terraform fmt and rerun both style checking and validation independently. This could address ci terraform fmt check distinguishes style from validity, but it does not correct the indicated core write plan apply workflow order mechanism. The relevant fix is: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
C:Run terraform plan to evaluate the configuration change and terraform apply after review, rather than expecting terraform init to modify resources. This could address workflow repeatability after configuration change, but it does not correct the indicated core write plan apply workflow order mechanism. The relevant fix is: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
D:Use terraform validate to catch configuration errors and separately run plan or controlled provider checks to assess remote feasibility. This could address terraform validate versus cloud permission testing, but it does not correct the indicated core write plan apply workflow order mechanism. The relevant fix is: Use the write, init, plan, and apply sequence with a deliberate review checkpoint before changing the remote environment.
Question 498
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 proposed remediation solves this failure without masking its cause?
- Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings.
- Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow.
- Grant scoped team access with read or plan permissions as appropriate, reserving apply and administration for authorized groups.
- Create a controlled HCP Terraform variable set scoped to the intended workspaces and remove conflicting duplicated values.
Explanation
Correct Answer
A:Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings. VCS-driven HCP Terraform workflows respond to repository changes when the workspace is explicitly integrated with that source. Confirm the cause with: Inspect workspace workflow configuration, VCS repository association, branch selection and recent run triggers. A concrete acceptance test is: An approved commit creates the intended Terraform plan run under the selected workspace without laptop-only execution. This matters here because as an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A….
Incorrect Answers
B:Connect the configuration to the appropriate HCP Terraform workspace and select a governed remote execution workflow. This could address hcp terraform remote execution and state hosting, but it does not correct the indicated vcs-driven hcp terraform run on approved changes mechanism. The relevant fix is: Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings. This matters here because as an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A….
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 vcs-driven hcp terraform run on approved changes mechanism. The relevant fix is: Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings.
D: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 vcs-driven hcp terraform run on approved changes mechanism. The relevant fix is: Configure an authorized VCS-driven workspace with the appropriate repository and branch and review the plan/apply settings. This matters here because as an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A….
Question 499
In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A project intended to stay on a provider's version 5 releases but a broad >= 5.0 constraint unexpectedly selected a breaking 6.x release. The engineers must keep provider choices and identities reproducible. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?
- Compare state resource addresses to actual remote objects and the active backend's selected state snapshot.
- Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior.
- Review the child module provider requirements and root module providers mapping for the child call.
- Examine required_providers version constraints and the selected version recorded in the dependency lock file.
Explanation
Correct Answer
D:Examine required_providers version constraints and the selected version recorded in the dependency lock file. A lower-bound-only version constraint does not prevent future major releases; compatible-release constraints bound allowed versions. A justified correction is: Use a justified upper-bound or compatible-release constraint such as ~> 5.0 and test upgrades before committing them. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A project intended….
Incorrect Answers
A:Compare state resource addresses to actual remote objects and the active backend's selected state snapshot. This inspects state binding between resource address and remote object rather than the reported provider version range semantics issue. The decisive investigation is: Examine required_providers version constraints and the selected version recorded in the dependency lock file.
B:Inspect the version constraint, lock file version, and the difference between ordinary terraform init and terraform init -upgrade behavior. This inspects controlled provider upgrade using init upgrade rather than the reported provider version range semantics issue. The decisive investigation is: Examine required_providers version constraints and the selected version recorded in the dependency lock file.
C:Review the child module provider requirements and root module providers mapping for the child call. This inspects module provider mapping for aliased configurations rather than the reported provider version range semantics issue. The decisive investigation is: Examine required_providers version constraints and the selected version recorded in the dependency lock file. This matters here because in a clean CI runner initializing a Terraform root configuration, the following condition occurs: A project intended….
Question 500
During a controlled module integration test for a production Terraform stack, the following condition occurs: An application service needs a policy attachment completed before creating a dependent service, but no attribute reference exists to order the two operations. The desired fix must avoid unrelated resource changes. What measurable postchange observation would confirm that the correction worked?
- The plan orders the policy attachment before the application service, and the service no longer races its prerequisite.
- Normal plans do not oscillate the delegated tag, while other resource drift remains visible and managed.
- A controlled Terraform operation can authenticate using the short-lived token while its value is omitted from plan and state artifacts.
- A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately.
Explanation
Correct Answer
A:The plan orders the policy attachment before the application service, and the service no longer races its prerequisite. depends_on expresses dependencies that cannot be inferred from configuration values, but unnecessary broad dependencies add conservatism. It tests the correction: Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: An….
Incorrect Answers
B:Normal plans do not oscillate the delegated tag, while other resource drift remains visible and managed. This might validate ignore_changes ownership of externally managed tag, but it does not prove that explicit depends_on for behavior-only dependencies was resolved. Confirm instead: The plan orders the policy attachment before the application service, and the service no longer races its prerequisite. This matters here because during a controlled module integration test for a production Terraform stack, the following condition occurs: An….
C: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 explicit depends_on for behavior-only dependencies was resolved. Confirm instead: The plan orders the policy attachment before the application service, and the service no longer races its prerequisite.
D:A violated mandatory invariant stops the controlled operation, while optional service checks report diagnostic results appropriately. This might validate check block observability versus hard failure, but it does not prove that explicit depends_on for behavior-only dependencies was resolved. Confirm instead: The plan orders the policy attachment before the application service, and the service no longer races its prerequisite.