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 35

Question 340

A municipal IT office wants automation to read a new load balancer address while keeping database passwords out of routine CLI output. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Define input variables with appropriate types and defaults, provide environment-specific values through supported tfvars or command options and review precedence. Verify: 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.
  2. Implement: Declare useful output blocks for created resource identifiers while marking genuinely sensitive values appropriately and avoiding broad data exposure. Verify: Run plans with two separate tfvars fixtures and confirm the chosen resource sizing changes while immutable module source remains identical.
  3. 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.
  4. Implement: Declare useful output blocks for created resource identifiers while marking genuinely sensitive values appropriately and avoiding broad data exposure. Verify: 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.

Answer & Explanations

Correct answer: D

A.

The question is set in this situation: A municipal IT office wants automation to read a new load balancer address while keeping database passwords out of routine CLI output. The test would be relevant: 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. But the offered implementation—Define input variables with appropriate types and defaults, provide environment-specific values through supported tfvars or command options and review precedence.—addresses “Use typed variables and supplied values without hardcoded environment secrets”. The action needed here is: Declare useful output blocks for created resource identifiers while marking genuinely sensitive values appropriately and avoiding broad data exposure.

B.

The question is set in this situation: A municipal IT office wants automation to read a new load balancer address while keeping database passwords out of routine CLI output. The action is applicable: Declare useful output blocks for created resource identifiers while marking genuinely sensitive values appropriately and avoiding broad data exposure. But its proposed test—Run plans with two separate tfvars fixtures and confirm the chosen resource sizing changes while immutable module source remains identical.—addresses “Use typed variables and supplied values without hardcoded environment secrets”. This requirement is confirmed instead by: 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.

C.

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: Declare useful output blocks for created resource identifiers while marking genuinely sensitive values appropriately and avoiding broad data exposure.

D.

The question is set in this situation: A municipal IT office wants automation to read a new load balancer address while keeping database passwords out of routine CLI output. Declare useful output blocks for created resource identifiers while marking genuinely sensitive values appropriately and avoiding broad data exposure. Confirm it through this test: 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. Outputs are a controlled interface between modules and users, but sensitive flags hide display rather than preventing all possible state persistence.

Question 341

A company module needs a network specification containing CIDR, environment name and security-zone designation as one validated input. Which HashiCorp Terraform infrastructure implementation best satisfies this requirement?

  1. Define resource postconditions for required output invariants and suitable check blocks for observable health assertions, understanding their different failure consequences.
  2. Declare Terraform resource blocks for objects the configuration owns and data blocks to query existing objects the configuration should not create or delete.
  3. Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.
  4. Select list when positional order matters and set when unique unordered membership is appropriate, especially before deriving keys for resources.

Answer & Explanations

Correct answer: C

A.

Define resource postconditions for required output invariants and suitable check blocks for observable health assertions, understanding their different failure consequences. This addresses “Use postconditions and check blocks for explicit infrastructure assertions”, where the governing principle is: Lifecycle postconditions can block dependent operations if false, while check assertions generally report warnings rather than rejecting the plan or apply. The stated case instead calls for: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

B.

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: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

C.

Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions. Verify the result with this test: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

D.

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: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

Question 342

A company module needs a network specification containing CIDR, environment name and security-zone designation as one validated input. The infrastructure engineer proposes this change: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. Which mechanism explains why it works?

  1. An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.
  2. Lists preserve ordering and can contain duplicates, while sets remove duplicates and do not guarantee positional indices for resource identity.
  3. Managed resources have Terraform-controlled lifecycle and state bindings, whereas data sources read existing objects supplied by external systems or other owners.
  4. Lifecycle postconditions can block dependent operations if false, while check assertions generally report warnings rather than rejecting the plan or apply.

Answer & Explanations

Correct answer: A

A.

An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions. The corresponding implementation is: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

B.

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: An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

C.

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: An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

D.

Lifecycle postconditions can block dependent operations if false, while check assertions generally report warnings rather than rejecting the plan or apply. That explains “Use postconditions and check blocks for explicit infrastructure assertions”, not the mechanism behind the described change. The relevant principle is: An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

Question 343

A company module needs a network specification containing CIDR, environment name and security-zone designation as one validated input. After implementing this change—Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.—which test most directly validates its intended outcome?

  1. Plan a disposable managed bucket alongside a data lookup of an approved existing network and inspect which objects would be created.
  2. Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses.
  3. Create an isolated fixture that violates a postcondition and compare the outcome with a failing check block before relying on either as a release gate.
  4. Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

Answer & Explanations

Correct answer: D

A.

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: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

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: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

C.

Create an isolated fixture that violates a postcondition and compare the outcome with a failing check block before relying on either as a release gate. That would help test “Use postconditions and check blocks for explicit infrastructure assertions”, not the outcome required in this scenario. The relevant acceptance check is: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

D.

Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply. This check is decisive because an object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

Question 344

A company module needs a network specification containing CIDR, environment name and security-zone designation as one validated input. Which proposed shortcut most directly risks silent misconfiguration and broken attribute access across shared modules and should therefore be rejected?

  1. Use an ordinary check block as the only mandatory security-control gate and assume its failed assertion always cancels the apply.
  2. Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields.
  3. Define an existing production network as a new managed resource and assume Terraform will automatically adopt it without import or conflict.
  4. Use toset on an ordered subnet list and assume each element still has the same stable integer position for count.index.

Answer & Explanations

Correct answer: B

A.

Use an ordinary check block as the only mandatory security-control gate and assume its failed assertion always cancels the apply. That shortcut risks critical policy controls bypassed because warning-level checks were mistaken for hard failures. Here the specific shortcut is: Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields.

B.

Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields. The foreseeable failure is silent misconfiguration and broken attribute access across shared modules. The safer response is: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

C.

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: Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields.

D.

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: Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields.

Question 345

A company module needs a network specification containing CIDR, environment name and security-zone designation as one validated input. 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: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.
  2. Implement: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. Verify: Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses.
  3. Implement: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. Verify: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.
  4. Implement: Declare Terraform resource blocks for objects the configuration owns and data blocks to query existing objects the configuration should not create or delete. Verify: Plan a disposable managed bucket alongside a data lookup of an approved existing network and inspect which objects would be created.

Answer & Explanations

Correct answer: C

A.

The test would be relevant: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply. But the offered implementation—Select list when positional order matters and set when unique unordered membership is appropriate, especially before deriving keys for resources.—addresses “Use sets and lists with awareness of order and uniqueness”. The action needed here is: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

B.

The action is applicable: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. But its proposed test—Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses.—addresses “Use sets and lists with awareness of order and uniqueness”. This requirement is confirmed instead by: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

C.

Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. Confirm it through this test: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply. An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

D.

This action/test pair addresses “Use resource blocks to manage objects and data blocks to read them”. Declare Terraform resource blocks for objects the configuration owns and data blocks to query existing objects the configuration should not create or delete. Plan a disposable managed bucket alongside a data lookup of an approved existing network and inspect which objects would be created. The case instead calls for: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

Question 346

A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. Which HashiCorp Terraform infrastructure implementation best satisfies this requirement?

  1. Select list when positional order matters and set when unique unordered membership is appropriate, especially before deriving keys for resources.
  2. Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.
  3. Use indexed addresses for count-created instances and key-based addresses for for_each-created instances when referencing individual resource attributes.
  4. Reference a created network resource's ID in a dependent instance resource argument so Terraform builds its dependency graph automatically.

Answer & Explanations

Correct answer: B

A.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. 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: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

B.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions. Verify the result with this test: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

C.

Use indexed addresses for count-created instances and key-based addresses for for_each-created instances when referencing individual resource attributes. This addresses “Address resources correctly when count and for_each are used”, where the governing principle is: Resource instance addresses encode either numeric instance positions or stable collection keys; confusing them causes invalid references or churn. The stated case instead calls for: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

D.

Reference a created network resource's ID in a dependent instance resource argument so Terraform builds its dependency graph automatically. This addresses “Use direct resource references to establish implicit dependencies”, where the governing principle is: Terraform analyzes expressions that reference resource attributes and schedules dependent operations after the values needed for them are available. The stated case instead calls for: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

Question 347

A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. The infrastructure engineer proposes this change: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. Which mechanism explains why it works?

  1. An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.
  2. Lists preserve ordering and can contain duplicates, while sets remove duplicates and do not guarantee positional indices for resource identity.
  3. Terraform analyzes expressions that reference resource attributes and schedules dependent operations after the values needed for them are available.
  4. Resource instance addresses encode either numeric instance positions or stable collection keys; confusing them causes invalid references or churn.

Answer & Explanations

Correct answer: A

A.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions. The corresponding implementation is: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

B.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. 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: An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

C.

Terraform analyzes expressions that reference resource attributes and schedules dependent operations after the values needed for them are available. That explains “Use direct resource references to establish implicit dependencies”, not the mechanism behind the described change. The relevant principle is: An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

D.

Resource instance addresses encode either numeric instance positions or stable collection keys; confusing them causes invalid references or churn. That explains “Address resources correctly when count and for_each are used”, not the mechanism behind the described change. The relevant principle is: An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

Question 348

A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. After implementing this change—Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.—which test most directly validates its intended outcome?

  1. Plan a disposable subnet and server, inspect resource ordering and verify the server uses the created subnet's ID rather than a manually copied string.
  2. Create an isolated test resource for each environment key, inspect terraform state list and prove the intended key selects only its matching resource.
  3. Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses.
  4. Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

Answer & Explanations

Correct answer: D

A.

Plan a disposable subnet and server, inspect resource ordering and verify the server uses the created subnet's ID rather than a manually copied string. That would help test “Use direct resource references to establish implicit dependencies”, not the outcome required in this scenario. The relevant acceptance check is: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

B.

Create an isolated test resource for each environment key, inspect terraform state list and prove the intended key selects only its matching resource. That would help test “Address resources correctly when count and for_each are used”, not the outcome required in this scenario. The relevant acceptance check is: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

C.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. 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: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

D.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply. This check is decisive because an object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

Question 349

A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. Which proposed shortcut most directly risks silent misconfiguration and broken attribute access across shared modules and should therefore be rejected?

  1. Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields.
  2. Hardcode a subnet name while relying on Terraform to infer a dependency on a separately declared resource with no expression reference.
  3. Refer to a for_each-created resource as a singleton name with no index or key and expect Terraform to select one arbitrary instance.
  4. Use toset on an ordered subnet list and assume each element still has the same stable integer position for count.index.

Answer & Explanations

Correct answer: A

A.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields. The foreseeable failure is silent misconfiguration and broken attribute access across shared modules. The safer response is: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

B.

Hardcode a subnet name while relying on Terraform to infer a dependency on a separately declared resource with no expression reference. That shortcut risks race conditions or binding a server to the wrong network after changes. Here the specific shortcut is: Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields.

C.

Refer to a for_each-created resource as a singleton name with no index or key and expect Terraform to select one arbitrary instance. That shortcut risks invalid references and accidental resource changes caused by incorrect addresses. Here the specific shortcut is: Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields.

D.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. 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: Pass a comma-delimited untyped string as a pretend object and parse it ad hoc in resource names without checking fields.

Question 350

A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. Which combined implementation and verification plan is the best match for this workload?

  1. Implement: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. Verify: Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses.
  2. Implement: Select list when positional order matters and set when unique unordered membership is appropriate, especially before deriving keys for resources. Verify: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.
  3. 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.
  4. Implement: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. Verify: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

Answer & Explanations

Correct answer: D

A.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. The action is applicable: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. But its proposed test—Feed intentionally duplicated environment labels into list and set test expressions and inspect resulting order, uniqueness and resource addresses.—addresses “Use sets and lists with awareness of order and uniqueness”. This requirement is confirmed instead by: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply.

B.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. The test would be relevant: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply. But the offered implementation—Select list when positional order matters and set when unique unordered membership is appropriate, especially before deriving keys for resources.—addresses “Use sets and lists with awareness of order and uniqueness”. The action needed here is: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

C.

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: Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together.

D.

The question is set in this situation: A laboratory sets storage retention, allowed regions and labels through a structured parameter contract reused by several teams. Use typed object variables with documented attributes, optional values where appropriate, and consistent validation to pass related configuration settings together. Confirm it through this test: Supply a valid typed object and then a missing required key in a test, confirming Terraform reports the error before any apply. An object has named attributes and defined types, whereas an untyped string cannot safely represent a structured group of configuration decisions.

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