HashiCorp Terraform Associate Practice Test 41
Question 400
An analytics team stores a list of required security group ports in an input variable but declares it as string and loops over it incorrectly. The team has implemented an approved Terraform change. Which observed result most directly confirms that the original requirement is now met, beyond a successful command exit code?
- The planned rules match the approved numeric port list.
- The module outputs a consistent address list matching selected instances.
- Terraform plans creation of the intended network rather than failing a lookup.
- Terraform blocks unapproved destruction while separate platform controls guard the live object.
Explanation
Correct Answer
A:This is the appropriate measurable post-change acceptance criterion: The planned rules match the approved numeric port list. A successful Terraform command or a completed change request alone would not demonstrate that outcome. Preserve this control during validation: Test empty, duplicate and out-of-range port cases.
Incorrect Answers
B:“The module outputs a consistent address list matching selected instances” would address a different Terraform configuration concern; the source instead describes An analytics team stores a list of required security group ports in an input variable but declares it as string and loops over it incorrectly. The appropriate design is to define an appropriate collection type with input validation and use a collection-aware expression. Confirm whether the planned rules match the approved numeric port list.
C:“Terraform plans creation of the intended network rather than failing a lookup” would address a different Terraform configuration concern; the source instead describes An analytics team stores a list of required security group ports in an input variable but declares it as string and loops over it incorrectly. The appropriate design is to define an appropriate collection type with input validation and use a collection-aware expression. Confirm whether the planned rules match the approved numeric port list.
D:“Terraform blocks unapproved destruction while separate platform controls guard the live object” would address a different Terraform configuration concern; the source instead describes An analytics team stores a list of required security group ports in an input variable but declares it as string and loops over it incorrectly. The appropriate design is to define an appropriate collection type with input validation and use a collection-aware expression. Confirm whether the planned rules match the approved numeric port list.
Question 401
A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The infrastructure review requires a supported, least-disruptive Terraform solution. Which proposed change most directly addresses this specific situation?
- Keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly.
- Use narrowly scoped ignore_changes for the externally controlled count while still tracking required security attributes.
- Declare an explicit root output for the required subnet ID and consume that supported interface.
- Use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects.
Explanation
Correct Answer
D:The proposed intervention addresses the reported Terraform engineering failure: A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. It applies the design choice Use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Review the primary diagnostic: Compare old and new index-based resource addresses in the plan. The expected outcome is: Removing one subnet does not renumber unrelated managed subnet addresses. The rollout safeguard is: Introduce moved blocks for existing addresses during a careful migration.
Incorrect Answers
A:“Keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
B:“Use narrowly scoped ignore_changes for the externally controlled count while still tracking required security attributes” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
C:“Declare an explicit root output for the required subnet ID and consume that supported interface” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
Question 402
A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. Before choosing a remedy, the team needs independent evidence of the actual root cause. Which TWO checks most directly test this case? (Select TWO.)
- Inspect the load balancer resource's exported address attribute.
- Compare old and new index-based resource addresses in the plan.
- Inspect proposed stable business keys for each subnet.
- Inspect the module's internal resource address and public outputs.
- Inspect name constructions across resource blocks.
Explanation
Correct Answers
B:This is directly relevant evidence for the reported behavior: Compare old and new index-based resource addresses in the plan. Pair it with a separate check from the same case rather than assuming one finding proves the cause. The evidence supports or refutes the change proposal: Use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. The expected confirmation is Removing one subnet does not renumber unrelated managed subnet addresses.
C:This is directly relevant evidence for the reported behavior: Inspect proposed stable business keys for each subnet. Pair it with a separate check from the same case rather than assuming one finding proves the cause. The evidence supports or refutes the change proposal: Use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. The expected confirmation is Removing one subnet does not renumber unrelated managed subnet addresses.
Incorrect Answers
A:“Inspect the load balancer resource's exported address attribute” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
D:“Inspect the module's internal resource address and public outputs” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
E:“Inspect name constructions across resource blocks” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
Question 403
A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. If this behavior continues without correction, which specific risk is most closely supported by the facts, without assuming harm has already occurred?
- Mis-scoped iteration expressions can prevent planning.
- Duplicated resource declarations can create conflicting objects.
- Index churn may cause unnecessary destructive replacements.
- Implicit ordering assumptions can create unstable downstream configuration.
Explanation
Correct Answer
C:The reported condition creates the specific potential exposure: Index churn may cause unnecessary destructive replacements. A risk is not evidence that every adverse outcome already occurred. Two independent checks can corroborate the assessment. First diagnostic: Compare old and new index-based resource addresses in the plan. Second diagnostic: Inspect proposed stable business keys for each subnet.
Incorrect Answers
A:“Mis-scoped iteration expressions can prevent planning” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
B:“Duplicated resource declarations can create conflicting objects” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
D:“Implicit ordering assumptions can create unstable downstream configuration” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
Question 404
A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. A reviewer asks for BOTH a targeted technical response and a corresponding change-control safeguard. Which TWO actions together meet that requirement? (Select TWO.)
- Verify Vault token lifecycle and any provider data-source state exposure.
- Introduce moved blocks for existing addresses during a careful migration.
- Use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects.
- Pass the input explicitly in the module call and validate the child's required variable contract.
- Write a clear condition message and test unknown values.
Explanation
Correct Answers
B:This is one of the two necessary decisions for a safe design: Introduce moved blocks for existing addresses during a careful migration. Together the corrective action and its implementation safeguard need to address the recorded condition: A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. Acceptance requires Removing one subnet does not renumber unrelated managed subnet addresses.
C:This is one of the two necessary decisions for a safe design: Use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Together the corrective action and its implementation safeguard need to address the recorded condition: A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. Acceptance requires Removing one subnet does not renumber unrelated managed subnet addresses.
Incorrect Answers
A:“Verify Vault token lifecycle and any provider data-source state exposure” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
D:“Pass the input explicitly in the module call and validate the child's required variable contract” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
E:“Write a clear condition message and test unknown values” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
Question 405
A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The team has implemented an approved Terraform change. Which observed result most directly confirms that the original requirement is now met, beyond a successful command exit code?
- The planned rules match the approved numeric port list.
- The migration preserves availability without impossible duplicate naming.
- Removing one subnet does not renumber unrelated managed subnet addresses.
- Secrets are handled under encrypted restricted state controls with understood redaction limits.
Explanation
Correct Answer
C:This is the appropriate measurable post-change acceptance criterion: Removing one subnet does not renumber unrelated managed subnet addresses. A successful Terraform command or a completed change request alone would not demonstrate that outcome. Preserve this control during validation: Introduce moved blocks for existing addresses during a careful migration.
Incorrect Answers
A:“The planned rules match the approved numeric port list” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
B:“The migration preserves availability without impossible duplicate naming” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
D:“Secrets are handled under encrypted restricted state controls with understood redaction limits” would address a different Terraform configuration concern; the source instead describes A platform engineer uses count for subnet resources keyed by position and removes the middle entry, making Terraform propose replacement of later subnets. The appropriate design is to use for_each keyed by stable subnet identifiers rather than a shifting positional list for independently named objects. Confirm whether removing one subnet does not renumber unrelated managed subnet addresses.
Question 406
A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The infrastructure review requires a supported, least-disruptive Terraform solution. Which proposed change most directly addresses this specific situation?
- Evaluate whether a temporary distinct name or staged migration can support create_before_destroy safely.
- Use narrowly scoped ignore_changes for the externally controlled count while still tracking required security attributes.
- Keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly.
- Use lookup with a default or try for genuinely optional nested attributes while maintaining clear validation.
Explanation
Correct Answer
C:The proposed intervention addresses the reported Terraform engineering failure: A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. It applies the design choice Keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Review the primary diagnostic: Inspect the resource for_each declaration and expression context. The expected outcome is: The configuration evaluates map entries only inside valid iteration contexts. The rollout safeguard is: Test map inputs with distinct keys and values.
Incorrect Answers
A:“Evaluate whether a temporary distinct name or staged migration can support create_before_destroy safely” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
B:“Use narrowly scoped ignore_changes for the externally controlled count while still tracking required security attributes” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
D:“Use lookup with a default or try for genuinely optional nested attributes while maintaining clear validation” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
Question 407
A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. Before choosing a remedy, the team needs independent evidence of the actual root cause. Which TWO checks most directly test this case? (Select TWO.)
- Check whether the intended network ID already exists in the provider API.
- Inspect the resource for_each declaration and expression context.
- Run terraform validate to identify undefined each references.
- Inspect conditional true and false branch types.
- Inspect which map keys are required versus optional.
Explanation
Correct Answers
B:This is directly relevant evidence for the reported behavior: Inspect the resource for_each declaration and expression context. Pair it with a separate check from the same case rather than assuming one finding proves the cause. The evidence supports or refutes the change proposal: Keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. The expected confirmation is The configuration evaluates map entries only inside valid iteration contexts.
C:This is directly relevant evidence for the reported behavior: Run terraform validate to identify undefined each references. Pair it with a separate check from the same case rather than assuming one finding proves the cause. The evidence supports or refutes the change proposal: Keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. The expected confirmation is The configuration evaluates map entries only inside valid iteration contexts.
Incorrect Answers
A:“Check whether the intended network ID already exists in the provider API” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
D:“Inspect conditional true and false branch types” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
E:“Inspect which map keys are required versus optional” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
Question 408
A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. If this behavior continues without correction, which specific risk is most closely supported by the facts, without assuming harm has already occurred?
- Incompatible expression types can prevent evaluation or mask wrong assumptions.
- Mis-scoped iteration expressions can prevent planning.
- A secret assumed ephemeral may still be exposed if copied to persistent attributes.
- A missing guard can send traffic to an unintended network.
Explanation
Correct Answer
B:The reported condition creates the specific potential exposure: Mis-scoped iteration expressions can prevent planning. A risk is not evidence that every adverse outcome already occurred. Two independent checks can corroborate the assessment. First diagnostic: Inspect the resource for_each declaration and expression context. Second diagnostic: Run terraform validate to identify undefined each references.
Incorrect Answers
A:“Incompatible expression types can prevent evaluation or mask wrong assumptions” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
C:“A secret assumed ephemeral may still be exposed if copied to persistent attributes” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
D:“A missing guard can send traffic to an unintended network” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
Question 409
A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. A reviewer asks for BOTH a targeted technical response and a corresponding change-control safeguard. Which TWO actions together meet that requirement? (Select TWO.)
- Declare an explicit root output for the required subnet ID and consume that supported interface.
- Document the hidden dependency and test a clean deployment.
- Keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly.
- Test empty, duplicate and out-of-range port cases.
- Test map inputs with distinct keys and values.
Explanation
Correct Answers
C:This is one of the two necessary decisions for a safe design: Keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Together the corrective action and its implementation safeguard need to address the recorded condition: A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. Acceptance requires The configuration evaluates map entries only inside valid iteration contexts.
E:This is one of the two necessary decisions for a safe design: Test map inputs with distinct keys and values. Together the corrective action and its implementation safeguard need to address the recorded condition: A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. Acceptance requires The configuration evaluates map entries only inside valid iteration contexts.
Incorrect Answers
A:“Declare an explicit root output for the required subnet ID and consume that supported interface” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
B:“Document the hidden dependency and test a clean deployment” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
D:“Test empty, duplicate and out-of-range port cases” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
Question 410
A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The team has implemented an approved Terraform change. Which observed result most directly confirms that the original requirement is now met, beyond a successful command exit code?
- The target credential is rotated without a plaintext password field saved in state.
- The resource exists once with the correct optional logging configuration.
- The configuration evaluates map entries only inside valid iteration contexts.
- The configuration rejects an endpoint that violates the declared invariant.
Explanation
Correct Answer
C:This is the appropriate measurable post-change acceptance criterion: The configuration evaluates map entries only inside valid iteration contexts. A successful Terraform command or a completed change request alone would not demonstrate that outcome. Preserve this control during validation: Test map inputs with distinct keys and values.
Incorrect Answers
A:“The target credential is rotated without a plaintext password field saved in state” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
B:“The resource exists once with the correct optional logging configuration” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.
D:“The configuration rejects an endpoint that violates the declared invariant” would address a different Terraform configuration concern; the source instead describes A security policy module creates multiple rules from a map but refers to each.value outside the for_each resource body, causing an undefined-symbol error. The appropriate design is to keep each.key and each.value scoped to blocks with for_each or pass derived values explicitly. Confirm whether the configuration evaluates map entries only inside valid iteration contexts.