cert
cert-1
cert-2

Pass HashiCorp Terraform Associate 004 Exam in First Attempt Guaranteed!

Get 100% Latest Exam Questions, Accurate & Verified Answers to Pass the Actual Exam!
30 Days Free Updates, Instant Download!

cert-5
cert-6
Terraform Associate 004 Exam - Verified By Experts
Terraform Associate 004 Premium Bundle
$29.98

Terraform Associate 004 Premium Bundle

$79.99
$109.97
  • Premium File 167 Questions & Answers. Last update: Nov 28, 2026
  • Training Course 118 Video Lectures
  • Study Guide 285 Pages
 
$109.97
$79.99
accept 60 downloads in last 7 days
block-screenshots
Purchase HashiCorp Terraform Associate 004 Exam Training Products Individually
HashiCorp Terraform Associate 004 Premium File
Premium File 167 Q&A
$76.99$69.99
HashiCorp Terraform Associate 004 Video Training Course
Training Course 118 Lectures
$21.99 $19.99
HashiCorp Terraform Associate 004 PDF Study Guide
Study Guide 285 Pages
$21.99 $19.99
HashiCorp Terraform Associate 004 Practice Test 35

Question 340

When reviewing a reusable Terraform HCL configuration before deployment, 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 engineer must respect declared resource contracts and data security boundaries. Select TWO: the decisive first check and the change that directly addresses the problem.

  1. Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.
  2. Check the for_each keys and the collection shape of the declared resource instances.
  3. Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage.
  4. Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration.
  5. Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated.

Explanation

Correct Answers

A:

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. This forms one element of the required two-step diagnosis and correction.

D:

Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. Repeated resources have instance addresses that include their keys or indexes, rather than a single unqualified instance address. A justified correction is: Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring. This forms one element of the required two-step diagnosis and correction.

Incorrect Answers

B:

Check the for_each keys and the collection shape of the declared resource instances. This relates to collection references for for_each resources rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. Then change: Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.

C:

Use a provider-supported data block to look up the existing zone and reserve resource declarations for objects this state should manage. This relates to data source versus managed resource definition rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. Then change: Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.

E:

Use a narrowly scoped lifecycle ignore_changes list for that attribute only when its ownership has been formally delegated. This relates to ignore_changes ownership of externally managed tag rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the declared for_each keys, current state addresses, and references elsewhere in the configuration. Then change: Reference the correct keyed resource instance or use a reviewed moved block to preserve its existing state identity during refactoring.

Question 341

During a controlled module integration test for a production Terraform stack, the following condition occurs: A pipeline needs a temporary provider API token but its input variable is ordinary and the security reviewer wants to avoid persisting the token in plan or state artifacts. The desired fix must avoid unrelated resource changes. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?

  1. Inspect the provider resource schema for supported write-only arguments and associated rotation or version requirements.
  2. Inspect the graph references and whether the data source must wait for a managed resource's creation.
  3. Inspect the graph for a dependency edge and confirm the service genuinely requires the policy to exist first.
  4. Inspect the variable's ephemeral setting and whether downstream use is an allowed ephemeral context such as provider configuration.

Explanation

Correct Answer

D:

Inspect the variable's ephemeral setting and whether downstream use is an allowed ephemeral context such as provider configuration. This investigates ephemeral variable for short-lived token in terraform 1.12 in the reported workflow. Ephemeral values are available during an operation but cannot be referenced in arbitrary normal persisted expressions. A justified correction is: Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration.

Incorrect Answers

A:

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 ephemeral variable for short-lived token in terraform 1.12 issue. The decisive investigation is: Inspect the variable's ephemeral setting and whether downstream use is an allowed ephemeral context such as provider configuration.

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 ephemeral variable for short-lived token in terraform 1.12 issue. The decisive investigation is: Inspect the variable's ephemeral setting and whether downstream use is an allowed ephemeral context such as provider configuration.

C:

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 ephemeral variable for short-lived token in terraform 1.12 issue. The decisive investigation is: Inspect the variable's ephemeral setting and whether downstream use is an allowed ephemeral context such as provider configuration.

Question 342

As the deployment team prepares a reviewed Terraform CLI change, the following condition occurs: A test team runs terraform destroy from a shared state backend believing it removes only the temporary virtual machine they recently created. The change must preserve the distinction between previewing and modifying infrastructure. Which diagnostic check provides the strongest evidence for the underlying problem?

  1. Read the terraform plan action symbols and provider explanation for forces replacement before scheduling apply.
  2. Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure.
  3. Inspect the .terraform working directory and initialization output for missing backend, module, and provider setup.
  4. Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope.

Explanation

Correct Answer

D:

Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope. Terraform destroy targets the managed resources recorded in the selected state, not only the objects recently added by one operator. A justified correction is: Use a dedicated isolated workspace/state and inspect terraform plan -destroy before removing its tracked infrastructure.

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 terraform destroy is managed-scope deletion issue. The decisive investigation is: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope.

B:

Inspect the bucket's resource address and distinguish removing state ownership from destroying remote infrastructure. This inspects selective cleanup without destroying retained object rather than the reported terraform destroy is managed-scope deletion issue. The decisive investigation is: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope.

C:

Inspect the.terraform working directory and initialization output for missing backend, module, and provider setup. This inspects terraform init backend and provider preparation rather than the reported terraform destroy is managed-scope deletion issue. The decisive investigation is: Inspect all resource addresses present in the selected workspace state and the destroy plan's complete deletion scope.

Question 343

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. What acceptance evidence best establishes that the Terraform issue has been resolved?

  1. The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities.
  2. The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot.
  3. Teams locate and administer their approved workspaces without accidentally gaining access to unrelated project state.
  4. Contributors can collaborate on plans while unauthorized accounts cannot approve or apply production infrastructure changes.

Explanation

Correct Answer

A:

The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities. HCP workspace authentication and cloud provider authentication protect different services and cannot substitute for each other. It tests the correction: Authenticate to HCP Terraform using a supported CLI login or secure token workflow and retain least-privilege provider credentials independently. This matters here because as an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A….

Incorrect Answers

B:

The CLI plan targets the selected HCP Terraform workspace and uses its controlled state rather than a local accidental snapshot. This might validate terraform cloud block hcp workspace integration, but it does not prove that hcp terraform cli login and execution credentials was resolved. Confirm instead: The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities. This matters here because as an infrastructure team integrates an existing repository with HCP Terraform, the following condition occurs: A….

C:

Teams locate and administer their approved workspaces without accidentally gaining access to unrelated project state. This might validate hcp projects group workspaces by ownership, but it does not prove that hcp terraform cli login and execution credentials was resolved. Confirm instead: The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities.

D:

Contributors can collaborate on plans while unauthorized accounts cannot approve or apply production infrastructure changes. This might validate hcp terraform team permissions and audit trail, but it does not prove that hcp terraform cli login and execution credentials was resolved. Confirm instead: The CLI can access the authorized workspace while provider API access remains governed by separate scoped identities.

Question 344

During a clean initialization of a newly composed infrastructure root module, the following condition occurs: A monorepo contains many Terraform modules, but a root module downloads the entire Git repository as though its desired network child module lives at repository root. The team must preserve reproducibility across callers. Which TWO options together provide the relevant diagnosis and its targeted remediation? Select TWO.

  1. Add the intended child output declaration and access it through module.network.<output_name> in the caller.
  2. Set the source to an accurate local relative module path and initialize or validate from the correct root directory.
  3. Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch.
  4. Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout.
  5. Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref.

Explanation

Correct Answers

D:

Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. Terraform module source addresses can include a package subdirectory; the path after double slash identifies the module inside it. A justified correction is: Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. This forms one element of the required two-step diagnosis and correction. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….

E:

Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. Terraform module source addresses can include a package subdirectory; the path after double slash identifies the module inside it. Confirm the cause with: Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. A concrete acceptance test is: Initialization selects the network module code from the intended repository path and revision rather than unrelated root files. This forms one element of the required two-step diagnosis and correction. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….

Incorrect Answers

A:

Add the intended child output declaration and access it through module.network.<output_name> in the caller. This relates to child output exposure to calling module rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. Then change: Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref.

B:

Set the source to an accurate local relative module path and initialize or validate from the correct root directory. This relates to local child module source path resolution rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. Then change: Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref. This matters here because during a clean initialization of a newly composed infrastructure root module, the following condition occurs: A….

C:

Inspect the module Git source URL and whether it contains a commit, tag or versioned ref rather than an unpinned branch. This relates to git module ref pin rather than floating main branch rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the Git source URL, requested revision ref, and the actual module subdirectory layout. Then change: Use the supported Git module source form with the correct double-slash subdirectory and pinned revision ref.

Question 345

When reviewing a reusable Terraform HCL configuration before deployment, 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 engineer must respect declared resource contracts and data security boundaries. Select TWO: the decisive first check and the change that directly addresses the problem.

  1. Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource.
  2. Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version.
  3. Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.
  4. Inspect the variable declaration, resource schema, and stored state behavior for that password input.
  5. Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration.

Explanation

Correct Answers

B:

Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version. Check blocks generally issue warnings rather than blocking applies; lifecycle conditions enforce resource pre/post invariants. A justified correction is: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports. This forms one element of the required two-step diagnosis and correction.

C:

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 forms one element of the required two-step diagnosis and correction.

Incorrect Answers

A:

Use a lifecycle precondition with a precise boolean condition and actionable error message on the resource. This relates to resource precondition for unsafe configuration rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version. Then change: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.

D:

Inspect the variable declaration, resource schema, and stored state behavior for that password input. This relates to sensitive variable does not erase state secrets rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version. Then change: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.

E:

Declare the token input as ephemeral = true and pass it only into compatible runtime contexts such as provider configuration. This relates to ephemeral variable for short-lived token in terraform 1.12 rather than the matching diagnosis-and-remediation pair required here. Check: Inspect the chosen custom condition mechanism and whether its failure is advisory or blocking for the intended Terraform version. Then change: Use a resource precondition or postcondition for a hard lifecycle invariant and reserve check blocks for non-blocking validation reports.

Question 346

During a controlled Terraform CLI recovery exercise, the following condition occurs: An existing managed network is defined in Terraform but has never been imported, so the next plan attempts to create a duplicate resource with an already-used name. The same infrastructure must remain managed without unintended replacements. What measurable postchange observation would confirm that the correction worked?

  1. The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation.
  2. The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract.
  3. The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds.
  4. The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source.

Explanation

Correct Answer

A:

The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation. Import establishes a state binding for a real object; it does not automatically infer or validate the complete HCL desired configuration. It tests the correction: Use an import block or terraform import with the correct resource address and provider-specific remote ID before a reviewed plan. This matters here because an existing managed network is defined in Terraform but has never been imported, so the next plan attempts to create….

Incorrect Answers

B:

The planned refactor covers every tracked instance and does not omit resources merely because source code is abstract. This might validate state list for tracking managed addresses, but it does not prove that terraform import binds preexisting remote object was resolved. Confirm instead: The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation.

C:

The target restricted log file contains troubleshooting detail without leaving verbose tracing enabled for normal builds. This might validate tf_log_path requires enabled logging, but it does not prove that terraform import binds preexisting remote object was resolved. Confirm instead: The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation. This matters here because an existing managed network is defined in Terraform but has never been imported, so the next plan attempts to create….

D:

The next plan shows the intended objects being imported rather than created and adoption mappings remain reviewable in source. This might validate import blocks for reproducible adoption workflow, but it does not prove that terraform import binds preexisting remote object was resolved. Confirm instead: The existing object is tracked under the intended resource address and Terraform no longer proposes a duplicate creation. This matters here because an existing managed network is defined in Terraform but has never been imported, so the next plan attempts to create….

Question 347

As a second engineer rehearses an infrastructure state migration, the following condition occurs: A team assumes a default Terraform directory automatically stores state in a centralized shared service, but every engineer sees their own terraform.tfstate file. The operation must not delete or duplicate existing production objects. What targeted engineering response should the team implement?

  1. Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration.
  2. Select the intended workspace before planning and check the corresponding workspace-specific state directory.
  3. Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.
  4. Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change.

Explanation

Correct Answer

C:

Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. The local backend persists state on the executing filesystem; it does not provide shared remote coordination by default. Confirm the cause with: Inspect the backend configuration and state file location on each workstation to identify local state behavior. A concrete acceptance test is: Authorized team members reference one intended remote snapshot rather than maintaining conflicting independent local files. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A team assumes a….

Incorrect Answers

A:

Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration. This could address backend credentials kept out of plan artifacts, but it does not correct the indicated local backend path and exposure mechanism. The relevant fix is: Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.

B:

Select the intended workspace before planning and check the corresponding workspace-specific state directory. This could address local workspace state separation, but it does not correct the indicated local backend path and exposure mechanism. The relevant fix is: Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: A team assumes a….

D:

Review whether to restore desired IaC attributes or update configuration deliberately to adopt the observed change. This could address out-of-band drift detection in managed resource, but it does not correct the indicated local backend path and exposure mechanism. The relevant fix is: Configure a suitable remote backend for shared operations or explicitly isolate disposable local state with restricted permissions.

Question 348

As a second engineer rehearses an infrastructure state migration, the following condition occurs: An engineer passes a remote state storage key through plaintext -backend-config arguments in a shared build log and assumes Terraform will never retain that key. The operation must not delete or duplicate existing production objects. What should the engineer inspect FIRST to distinguish this issue from unrelated failures?

  1. Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace.
  2. Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values.
  3. Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state.
  4. Compare old and new resource addresses and verify the provider object is the same logical managed resource.

Explanation

Correct Answer

B:

Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values. Backend configuration can be captured in Terraform working-directory metadata and plan files; secret-bearing arguments require extra care. A justified correction is: Use the backend's supported environment or short-lived credential mechanism instead of hardcoding secrets into backend configuration. This matters here because as a second engineer rehearses an infrastructure state migration, the following condition occurs: An engineer passes….

Incorrect Answers

A:

Inspect the terraform block for mutually incompatible cloud and backend settings and the intended HCP Terraform workspace. This inspects hcp cloud integration versus remote backend rather than the reported backend credentials kept out of plan artifacts issue. The decisive investigation is: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values.

C:

Inspect the selected terraform workspace and the backend's paths used for nondefault workspace state. This inspects local workspace state separation rather than the reported backend credentials kept out of plan artifacts issue. The decisive investigation is: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values.

D:

Compare old and new resource addresses and verify the provider object is the same logical managed resource. This inspects moved block preserves state during address refactor rather than the reported backend credentials kept out of plan artifacts issue. The decisive investigation is: Inspect backend initialization and saved plan artifacts for embedded configuration parameters and authentication values.

Question 349

In a clean CI runner initializing a Terraform root configuration, the following condition occurs: A team publicly commits terraform.tfstate because it believes sensitive-marked variables guarantee that all secret material has been scrubbed from state. The engineers must keep provider choices and identities reproducible. What targeted engineering response should the team implement?

  1. Recover the correct protected state snapshot or deliberately import existing objects before applying destructive duplicate provisioning.
  2. Install and configure the appropriate provider through terraform init so Terraform can use its resource and data source implementations.
  3. Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly.
  4. Move state to an access-controlled encrypted backend, restrict readers, and avoid storing secret inputs where ephemeral paths are supported.

Explanation

Correct Answer

D:

Move state to an access-controlled encrypted backend, restrict readers, and avoid storing secret inputs where ephemeral paths are supported. The sensitive marking mainly controls presentation; state can still contain secret values unless configured to avoid persistence. Confirm the cause with: Inspect resource and output attributes persisted in the state and identify whether credential or connection values are present. A concrete acceptance test is: Unauthorized users cannot read the state snapshot while approved Terraform runs continue tracking infrastructure.

Incorrect Answers

A:

Recover the correct protected state snapshot or deliberately import existing objects before applying destructive duplicate provisioning. This could address state binding between resource address and remote object, but it does not correct the indicated state as sensitive operational metadata mechanism. The relevant fix is: Move state to an access-controlled encrypted backend, restrict readers, and avoid storing secret inputs where ephemeral paths are supported.

B:

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 state as sensitive operational metadata mechanism. The relevant fix is: Move state to an access-controlled encrypted backend, restrict readers, and avoid storing secret inputs where ephemeral paths are supported.

C:

Use distinct least-privilege credentials or supported role assumptions for each aliased provider and map resources explicitly. This could address multiple provider instances requiring separate authentication, but it does not correct the indicated state as sensitive operational metadata mechanism. The relevant fix is: Move state to an access-controlled encrypted backend, restrict readers, and avoid storing secret inputs where ephemeral paths are supported.

Question 350

During a controlled module integration test for a production Terraform stack, the following condition occurs: A name-sensitive network endpoint needs replacement, but Terraform plans to remove the old endpoint first and an application would become unavailable. The desired fix must avoid unrelated resource changes. What targeted engineering response should the team implement?

  1. Add an explicit depends_on reference to the necessary policy attachment where an ordinary attribute reference cannot express the relationship.
  2. Use for_each over stable unique names and migrate existing addresses with reviewed moved blocks where appropriate.
  3. Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required.
  4. Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists.

Explanation

Correct Answer

C:

Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required. create_before_destroy changes replacement ordering but cannot override remote API uniqueness rules or capacity limits. Confirm the cause with: Inspect the provider's replacement behavior, uniqueness constraints, and whether old and new instances can coexist. A concrete acceptance test is: The replacement can come online and pass health checks before the former endpoint is destroyed when provider constraints permit.

Incorrect Answers

A:

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 create_before_destroy lifecycle for availability mechanism. The relevant fix is: Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required.

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 create_before_destroy lifecycle for availability mechanism. The relevant fix is: Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required.

D:

Express the necessary dependency explicitly or reference a resource attribute so the lookup can occur when its prerequisite exists. This could address data source read ordering versus creation, but it does not correct the indicated create_before_destroy lifecycle for availability mechanism. The relevant fix is: Use lifecycle create_before_destroy when the platform allows coexistence and design unique names or a controlled cutover if required.

HashiCorp Certified: Terraform Associate (004) (Terraform Associate 004) Practice Tests