"Clicking in the console is good enough." Not twice. The console is a fine place to learn and explore, but the first time you need the same setup again (for staging, for a second Region, for a new client) you find out that nobody remembers every click. Settings drift apart, a security group rule is missing, and the two environments that "should be identical" behave differently. Infrastructure as code (IaC) fixes that.
What infrastructure as code means
With IaC you describe your servers, networks, databases and permissions in text files, and a tool creates them for you. Most IaC tools are declarative: you describe the end state ("a VPC with two private subnets and this security group"), and the tool works out which API calls to make and in what order. Change the file, run the tool again, and it updates only what changed.
Why it matters
- Repeatable. Run the same files twice and you get two identical environments. Staging finally matches production, so tests mean something.
- Reviewable. The files live in Git. Every change goes through a pull request, someone reviews it like any other code, and the history shows who changed what and when.
- Recoverable. If an environment breaks or is deleted, you rebuild it from the files, not from memory or an outdated wiki page.
- Documented. The code is the documentation of what exists, and it cannot go stale the way a diagram can.
A common mistake is mixing the two worlds: building with IaC and then "quickly fixing" something in the console. That manual change is invisible to the code and can be overwritten on the next deployment. Make the fix in the code instead.
The main tools on AWS
- AWS CloudFormation: the AWS service that builds stacks from YAML or JSON templates (covered in the next two episodes).
- AWS CDK: write infrastructure in TypeScript, Python, Java, C# or Go; it generates CloudFormation templates.
- Terraform: HashiCorp's tool, written in HCL, with an AWS provider and support for many other platforms.
All three work well. The right choice depends on your team's languages, whether you run more than one cloud, and what you already have. Picking one and using it consistently matters more than which one you pick.
Where AI fits
AI assistants are good at the first draft. Describe "a private S3 bucket with versioning and a Lambda function that reads from it" and you get a template or CDK code in seconds. AWS also publishes an open-source AWS IaC MCP server that gives assistants current CloudFormation and CDK documentation and can validate templates with tools like cfn-lint and cfn-guard.
But a draft is not a decision. A generated template can open a port to the whole internet, grant * permissions, or use a property that does not exist. Treat AI output like a pull request from a new teammate: read it, run the validators, and preview the change before it reaches production.
Quick recap
- Describe infrastructure in files, and let a tool build it.
- Review it like code: Git, pull requests, history.
- Rebuild anytime, and let AI write drafts that a human still reviews.