Question 260
A team asks a small SaaS team to create one service per immutable customer key while preserving stable addresses when entries reorder. Which Terraform mechanism should be used?
Explanation
Correct Answer
For_each favors stable key-based identity. This meets the stated requirement to create one service per immutable customer key while preserving stable addresses when entries reorder.
Incorrect Answers
Conditional count of zero is intended to omit an optional resource completely when a feature flag is disabled; count can model optional presence based on a boolean expression. That is not the specific requirement to create one service per immutable customer key while preserving stable addresses when entries reorder.
for_each with a set of strings is intended to create separate instances for each distinct region name without duplicate instances; for_each accepts sets of strings and uses the element as each.key. That is not the specific requirement to create one service per immutable customer key while preserving stable addresses when entries reorder.
for_each keyed instance reference is intended to select the payment service named blue from a map-created collection; for_each instances are selected by key rather than positional number. That is not the specific requirement to create one service per immutable customer key while preserving stable addresses when entries reorder.






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