Chapter Eight
Managing Real Infrastructure
Putting the language to work on actual AWS — networks, scaling compute fleets, least-privilege IAM, secrets, and the provisioners you should reach for last.
The first seven chapters taught the language and the workflow on small, self-contained examples. This chapter is where it meets a real cloud. The resources here are interconnected — a subnet references a VPC, an ASG references a launch template and a target group, an instance profile references a role — and that interconnection is exactly where the dependency graph, lifecycle meta-arguments, and iteration concepts stop being theory.
It is also where Terraform's sharp edges live. CIDRs you can't change without recreating the network, an autoscaler that fights every apply unless you tell Terraform to back off, a single "*" in an IAM policy that hands out admin, and secrets that land in plaintext state. Each topic grounds one of those in correct, concise AWS-provider HCL.
Topics in This Chapter
for_each beats count for subnets, and how cidrsubnet avoids overlap.desired_capacity."*" can undo.local-exec, remote-exec, and file do, why they're a last resort, the cloud-init and Packer alternatives, and the few legitimate uses.