30-Day Terraform Challenge · March 2026
I spent this day on count, for_each, for expressions, and conditionals—then refactored my webserver cluster module so repeated blocks disappear and optional pieces (autoscaling) actually stay out of the graph when they’re off.
| Path | Notes |
|---|---|
modules/services/webserver-cluster/ |
for_each on security group rules and on scaling policy / alarm maps; locals for instance size by environment; outputs built with for |
live/dev/services/webserver-cluster/ |
Dev stack, autoscaling enabled |
live/production/services/webserver-cluster/ |
Production stack, autoscaling disabled, larger default instance type |
labs/iam-count-list/ |
IAM users driven by count + length(list) — shows why list order bites |
labs/iam-for-each/ |
Same idea with for_each on toset(list) plus a tagged user map |
- Folder: open
terraform-challenge-day10as the workspace root so paths inlive/andmodules/resolve cleanly. - Terminal: integrated terminal (
Ctrl+`) — PowerShell on Windows is fine; I run allterraformcommands from the specific stack directory. - Extensions: HashiCorp Terraform (syntax,
terraform validateintegration), optional AWS Toolkit if I’m jumping to the console. - Format: from repo root,
terraform fmt -recursivebefore commits.
Dev (us-east-1, autoscaling on):
cd C:\Users\felix\terraform-challenge-day10\live\dev\services\webserver-cluster
terraform init
terraform validate
terraform planFlip enable_autoscaling to false in that main.tf, run terraform plan again, and the scaling policies / CPU alarms drop out—that’s the conditional map pattern in locals.tf doing its job.
Production:
cd C:\Users\felix\terraform-challenge-day10\live\production\services\webserver-cluster
terraform init
terraform validate
terraform planenvironment = "production" drives t3.small when instance_type is left empty; dev stays on t3.micro.
Small, isolated roots—terraform destroy when finished so IAM users don’t linger.
count + ordered list (labs/iam-count-list/):
cd C:\Users\felix\terraform-challenge-day10\labs\iam-count-list
terraform init
terraform applyRemove a middle element from user_names, plan again, and watch indices shift—that’s the behaviour I’m documenting in my write-up.
for_each + set / map (labs/iam-for-each/):
cd C:\Users\felix\terraform-challenge-day10\labs\iam-for-each
terraform init
terraform apply
terraform output principal_arns
terraform destroy- Terraform
>= 1.0 - AWS provider
~> 5.0 - AWS credentials on the machine (env vars or shared config)