Practice Exams:

HashiCorp Terraform Associate 004 Dumps

EXAM: HashiCorp Certified: Terraform Associate (004)
Verified By Experts
Premium Bundle
$40.00
$59.97 $99.97

Terraform Associate 004 Premium Bundle


  • Premium File 167 Questions & Answers
  • Training Course 118 Lectures
  • Study Guide 285 Pages

HashiCorp Terraform Associate 004 Practice Test 40

Question 390

A regional operations team is deciding whether to add an explicit dependency between a monitoring setup and an application rollout without attribute references. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference. Verify: Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible.
  2. Implement: Use indexed addresses for count-created instances and key-based addresses for for_each-created instances when referencing individual resource attributes. Verify: Create an isolated test resource for each environment key, inspect terraform state list and prove the intended key selects only its matching resource.
  3. Implement: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Verify: Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible.
  4. Implement: Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference. Verify: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

Answer & Explanations

Correct answer: A

A.

The question is set in this situation: A regional operations team is deciding whether to add an explicit dependency between a monitoring setup and an application rollout without attribute references. Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference. Confirm it through this test: Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible. Terraform already infers dependencies from expression references; explicit dependencies are for hidden ordering constraints and can make plans more conservative.

B.

This action/test pair addresses “Address resources correctly when count and for_each are used”. Use indexed addresses for count-created instances and key-based addresses for for_each-created instances when referencing individual resource attributes. Create an isolated test resource for each environment key, inspect terraform state list and prove the intended key selects only its matching resource. The case instead calls for: Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference.

C.

The question is set in this situation: A regional operations team is deciding whether to add an explicit dependency between a monitoring setup and an application rollout without attribute references. The test would be relevant: Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible. But the offered implementation—Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.—addresses “Use create_before_destroy only when replacement sequencing is feasible”. The action needed here is: Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference.

D.

The question is set in this situation: A regional operations team is deciding whether to add an explicit dependency between a monitoring setup and an application rollout without attribute references. The action is applicable: Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference. But its proposed test—Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.—addresses “Use create_before_destroy only when replacement sequencing is feasible”. This requirement is confirmed instead by: Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible.

Question 391

An online service wants to replace a test compute node with less downtime while maintaining enough spare capacity for two nodes. Which HashiCorp Terraform infrastructure implementation best satisfies this requirement?

  1. Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference.
  2. Select list when positional order matters and set when unique unordered membership is appropriate, especially before deriving keys for resources.
  3. Declare Terraform resource blocks for objects the configuration owns and data blocks to query existing objects the configuration should not create or delete.
  4. Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

Answer & Explanations

Correct answer: D

A.

Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference. This addresses “Use depends_on only for otherwise hidden dependencies”, where the governing principle is: Terraform already infers dependencies from expression references; explicit dependencies are for hidden ordering constraints and can make plans more conservative. The stated case instead calls for: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

B.

Select list when positional order matters and set when unique unordered membership is appropriate, especially before deriving keys for resources. This addresses “Use sets and lists with awareness of order and uniqueness”, where the governing principle is: Lists preserve ordering and can contain duplicates, while sets remove duplicates and do not guarantee positional indices for resource identity. The stated case instead calls for: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

C.

Declare Terraform resource blocks for objects the configuration owns and data blocks to query existing objects the configuration should not create or delete. This addresses “Use resource blocks to manage objects and data blocks to read them”, where the governing principle is: Managed resources have Terraform-controlled lifecycle and state bindings, whereas data sources read existing objects supplied by external systems or other owners. The stated case instead calls for: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

D.

Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting. Verify the result with this test: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

Question 392

An online service wants to replace a test compute node with less downtime while maintaining enough spare capacity for two nodes. The infrastructure engineer proposes this change: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Which mechanism explains why it works?

  1. Terraform already infers dependencies from expression references; explicit dependencies are for hidden ordering constraints and can make plans more conservative.
  2. Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.
  3. Lists preserve ordering and can contain duplicates, while sets remove duplicates and do not guarantee positional indices for resource identity.
  4. Managed resources have Terraform-controlled lifecycle and state bindings, whereas data sources read existing objects supplied by external systems or other owners.

Answer & Explanations

Correct answer: B

A.

Terraform already infers dependencies from expression references; explicit dependencies are for hidden ordering constraints and can make plans more conservative. That explains “Use depends_on only for otherwise hidden dependencies”, not the mechanism behind the described change. The relevant principle is: Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

B.

Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting. The corresponding implementation is: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

C.

Lists preserve ordering and can contain duplicates, while sets remove duplicates and do not guarantee positional indices for resource identity. That explains “Use sets and lists with awareness of order and uniqueness”, not the mechanism behind the described change. The relevant principle is: Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

D.

Managed resources have Terraform-controlled lifecycle and state bindings, whereas data sources read existing objects supplied by external systems or other owners. That explains “Use resource blocks to manage objects and data blocks to read them”, not the mechanism behind the described change. The relevant principle is: Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

Question 393

An online service wants to replace a test compute node with less downtime while maintaining enough spare capacity for two nodes. After implementing this change—Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.—which test most directly validates its intended outcome?

  1. Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.
  2. Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses.
  3. Plan a disposable managed bucket alongside a data lookup of an approved existing network and inspect which objects would be created.
  4. Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible.

Answer & Explanations

Correct answer: A

A.

Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly. This check is decisive because terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

B.

Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses. That would help test “Use sets and lists with awareness of order and uniqueness”, not the outcome required in this scenario. The relevant acceptance check is: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

C.

Plan a disposable managed bucket alongside a data lookup of an approved existing network and inspect which objects would be created. That would help test “Use resource blocks to manage objects and data blocks to read them”, not the outcome required in this scenario. The relevant acceptance check is: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

D.

Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible. That would help test “Use depends_on only for otherwise hidden dependencies”, not the outcome required in this scenario. The relevant acceptance check is: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

Question 394

An online service wants to replace a test compute node with less downtime while maintaining enough spare capacity for two nodes. Which proposed shortcut most directly risks failed replacement or deployment outage caused by an impossible coexistence assumption and should therefore be rejected?

  1. Use toset on an ordered subnet list and assume each element still has the same stable integer position for count.index.
  2. Define an existing production network as a new managed resource and assume Terraform will automatically adopt it without import or conflict.
  3. Insert depends_on on every module in a workspace without analysis, expecting this to make plans faster and change-free.
  4. Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously.

Answer & Explanations

Correct answer: D

A.

Use toset on an ordered subnet list and assume each element still has the same stable integer position for count.index. That shortcut risks unexpected element ordering or resource churn from the wrong collection type. Here the specific shortcut is: Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously.

B.

Define an existing production network as a new managed resource and assume Terraform will automatically adopt it without import or conflict. That shortcut risks duplicate creation attempts and unintended ownership of resources managed elsewhere. Here the specific shortcut is: Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously.

C.

Insert depends_on on every module in a workspace without analysis, expecting this to make plans faster and change-free. That shortcut risks unnecessary serialization and conservative unknown values that complicate plans. Here the specific shortcut is: Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously.

D.

Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously. The foreseeable failure is failed replacement or deployment outage caused by an impossible coexistence assumption. The safer response is: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

Question 395

An online service wants to replace a test compute node with less downtime while maintaining enough spare capacity for two nodes. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Select list when positional order matters and set when unique unordered membership is appropriate, especially before deriving keys for resources. Verify: Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses.
  2. Implement: Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference. Verify: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.
  3. Implement: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Verify: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.
  4. Implement: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Verify: Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible.

Answer & Explanations

Correct answer: C

A.

This action/test pair addresses “Use sets and lists with awareness of order and uniqueness”. Select list when positional order matters and set when unique unordered membership is appropriate, especially before deriving keys for resources. Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses. The case instead calls for: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

B.

The test would be relevant: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly. But the offered implementation—Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference.—addresses “Use depends_on only for otherwise hidden dependencies”. The action needed here is: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

C.

Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Confirm it through this test: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly. Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

D.

The action is applicable: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. But its proposed test—Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible.—addresses “Use depends_on only for otherwise hidden dependencies”. This requirement is confirmed instead by: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

Question 396

A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Which HashiCorp Terraform infrastructure implementation best satisfies this requirement?

  1. Declare useful output blocks for created resource identifiers while marking genuinely sensitive values appropriately and avoiding broad data exposure.
  2. Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.
  3. Define a variable validation rule for acceptable input values and use resource preconditions for assumptions that must hold before an operation proceeds.
  4. Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference.

Answer & Explanations

Correct answer: B

A.

Declare useful output blocks for created resource identifiers while marking genuinely sensitive values appropriately and avoiding broad data exposure. This addresses “Use output values to expose only intentional module results”, where the governing principle is: Outputs are a controlled interface between modules and users, but sensitive flags hide display rather than preventing all possible state persistence. The stated case instead calls for: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

B.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting. Verify the result with this test: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

C.

Define a variable validation rule for acceptable input values and use resource preconditions for assumptions that must hold before an operation proceeds. This addresses “Validate inputs using variable validation and lifecycle preconditions”, where the governing principle is: Variable validation rejects bad supplied configuration early; lifecycle preconditions guard resource operation assumptions and can use known dependent values. The stated case instead calls for: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

D.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference. This addresses “Use depends_on only for otherwise hidden dependencies”, where the governing principle is: Terraform already infers dependencies from expression references; explicit dependencies are for hidden ordering constraints and can make plans more conservative. The stated case instead calls for: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

Question 397

A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. The infrastructure engineer proposes this change: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Which mechanism explains why it works?

  1. Outputs are a controlled interface between modules and users, but sensitive flags hide display rather than preventing all possible state persistence.
  2. Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.
  3. Variable validation rejects bad supplied configuration early; lifecycle preconditions guard resource operation assumptions and can use known dependent values.
  4. Terraform already infers dependencies from expression references; explicit dependencies are for hidden ordering constraints and can make plans more conservative.

Answer & Explanations

Correct answer: B

A.

Outputs are a controlled interface between modules and users, but sensitive flags hide display rather than preventing all possible state persistence. That explains “Use output values to expose only intentional module results”, not the mechanism behind the described change. The relevant principle is: Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

B.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting. The corresponding implementation is: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

C.

Variable validation rejects bad supplied configuration early; lifecycle preconditions guard resource operation assumptions and can use known dependent values. That explains “Validate inputs using variable validation and lifecycle preconditions”, not the mechanism behind the described change. The relevant principle is: Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

D.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Terraform already infers dependencies from expression references; explicit dependencies are for hidden ordering constraints and can make plans more conservative. That explains “Use depends_on only for otherwise hidden dependencies”, not the mechanism behind the described change. The relevant principle is: Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

Question 398

A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. After implementing this change—Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.—which test most directly validates its intended outcome?

  1. Try an invalid CIDR or disallowed environment in an isolated plan and verify the custom error blocks the operation before creating resources.
  2. Run a test apply and verify consumers can reference an approved subnet ID from an output while a sensitive output is not printed in ordinary CLI output.
  3. Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible.
  4. Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

Answer & Explanations

Correct answer: D

A.

Try an invalid CIDR or disallowed environment in an isolated plan and verify the custom error blocks the operation before creating resources. That would help test “Validate inputs using variable validation and lifecycle preconditions”, not the outcome required in this scenario. The relevant acceptance check is: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

B.

Run a test apply and verify consumers can reference an approved subnet ID from an output while a sensitive output is not printed in ordinary CLI output. That would help test “Use output values to expose only intentional module results”, not the outcome required in this scenario. The relevant acceptance check is: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

C.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible. That would help test “Use depends_on only for otherwise hidden dependencies”, not the outcome required in this scenario. The relevant acceptance check is: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

D.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly. This check is decisive because terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

Question 399

A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Which proposed shortcut most directly risks failed replacement or deployment outage caused by an impossible coexistence assumption and should therefore be rejected?

  1. Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously.
  2. Insert depends_on on every module in a workspace without analysis, expecting this to make plans faster and change-free.
  3. Publish every secret attribute as a nonsensitive root output because downstream modules might eventually need to inspect it.
  4. Assume a comment saying use only approved regions is an enforceable policy and omit all validation in shared modules.

Answer & Explanations

Correct answer: A

A.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously. The foreseeable failure is failed replacement or deployment outage caused by an impossible coexistence assumption. The safer response is: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

B.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Insert depends_on on every module in a workspace without analysis, expecting this to make plans faster and change-free. That shortcut risks unnecessary serialization and conservative unknown values that complicate plans. Here the specific shortcut is: Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously.

C.

Publish every secret attribute as a nonsensitive root output because downstream modules might eventually need to inspect it. That shortcut risks unnecessary exposure of credentials and unstable cross-module interfaces. Here the specific shortcut is: Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously.

D.

Assume a comment saying use only approved regions is an enforceable policy and omit all validation in shared modules. That shortcut risks invalid infrastructure settings reaching deployment despite written documentation. Here the specific shortcut is: Enable create_before_destroy on a globally unique fixed-name object without checking whether a second object can exist simultaneously.

Question 400

A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Define a variable validation rule for acceptable input values and use resource preconditions for assumptions that must hold before an operation proceeds. Verify: Try an invalid CIDR or disallowed environment in an isolated plan and verify the custom error blocks the operation before creating resources.
  2. Implement: Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference. Verify: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.
  3. Implement: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Verify: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.
  4. Implement: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Verify: Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible.

Answer & Explanations

Correct answer: C

A.

This action/test pair addresses “Validate inputs using variable validation and lifecycle preconditions”. Define a variable validation rule for acceptable input values and use resource preconditions for assumptions that must hold before an operation proceeds. Try an invalid CIDR or disallowed environment in an isolated plan and verify the custom error blocks the operation before creating resources. The case instead calls for: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

B.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. The test would be relevant: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly. But the offered implementation—Add explicit depends_on on a resource or module only when the downstream operation relies on an upstream side effect not represented by a direct attribute reference.—addresses “Use depends_on only for otherwise hidden dependencies”. The action needed here is: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters.

C.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. Confirm it through this test: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly. Terraform may create a replacement before removing the old object, but a uniqueness constraint or shared name can prevent the two instances from coexisting.

D.

The question is set in this situation: A storage administrator considers create_before_destroy for a single globally unique resource name and needs to identify whether its API permits duplicate instances. The action is applicable: Apply lifecycle create_before_destroy for a replaceable resource when temporary coexistence is supported, identifiers are unique and downtime reduction matters. But its proposed test—Create a test dependency without a data reference, inspect graph ordering, and remove the explicit dependency to show why a direct reference would be preferable when possible.—addresses “Use depends_on only for otherwise hidden dependencies”. This requirement is confirmed instead by: Replace a disposable uniquely named resource and inspect the plan order while verifying the remote service allows both versions briefly.

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