count and for_each: The Index Trap, Cond...
DevOpsAWS

count and for_each: The Index Trap, Conditionals, templatefile

Two ways to create multiple resources: count by index and for_each by key. This article shows the real-world trap of using count with a list — dropping a middle element shifts the indexes and wrongly destroys-and-recreates a whole row of resources — with a live demo, then shows how for_each avoids it. Plus conditional resource creation and templatefile.

K
KaiMay 25, 2026· 1 views
Data Sources, Functions, for Expressions...
DevOpsAWS

Data Sources, Functions, for Expressions and Dynamic Blocks

Read existing information on AWS with data sources (latest AMI, available zones, current account), transform and filter data with for expressions, then generate repeated nested blocks with dynamic blocks. A security group with ingress rules auto-generated from a list of ports serves as the running example.

K
KaiMay 25, 2026
Variables, Outputs, Locals and Catching ...
DevOpsAWS

Variables, Outputs, Locals and Catching Bad Values Early

Parameterize configuration so the same code runs for multiple environments: variables take input, outputs return results, locals name derived expressions. More important is catching errors early — validation blocks bad input right at plan, precondition and postcondition check assumptions around each resource.

K
KaiMay 25, 2026
HCL Inside Out: Blocks, Data Types, Expr...
DevOpsAWS

HCL Inside Out: Blocks, Data Types, Expressions

Dissect the HCL language thoroughly: what a block is made of, the string/number/bool/list/map/null data types, expressions and functions, string interpolation. Use terraform console to try things directly, and see what else the terraform{} block can declare.

K
KaiMay 25, 2026