Chapter Six

Iteration and Conditionals

Turning one resource block into many without copy-paste: count and for_each, the for and conditional expressions that feed them, and the splat that reads them back. The chapter where the Hatch pipeline outgrows a single bucket and learns to fan out.

6 topics

The Hatch pipeline has outgrown its single raw bucket. It now lands events into one bucket per source system, fans out to a topic per event type, and stamps a service account per consumer. Done by hand that is dozens of near-identical blocks; done well it is one block and a collection. This chapter is how a single resource becomes many.

Two constructs do the stamping — count by position and for_each by key — and the choice between them decides whether a later edit is a clean diff or a destructive renumber. Around them sit the expression forms that build the collections and read them back: for expressions that reshape a list into the map for_each wants, conditional expressions that decide whether a resource exists at all, and splat expressions that pull one attribute out of every instance.

Topics in This Chapter