CloudFormation

Infrastructure as Code (IaC). Write a recipe (YAML), and let AWS cook the infrastructure (Stack) for you.

๐Ÿ—๏ธ Core Concepts

The Template

A YAML file that describes the end state.
"I want 1 VPC and 2 EC2 instances."

The Stack

The actual collection of resources created from your template. You manage them as a single unit.

Drift

When someone manually changes a resource (e.g., deletes a rule) so the Stack no longer matches the Template.

๐Ÿ•น๏ธ Simulator: Stack Builder

Resources
Tip: Add resources, then Deploy.
template.yaml
AWSTemplateFormatVersion: '2010-09-09' Description: My First Stack Resources: # Add resources from the left panel...
Cloud Events REVIEW_IN_PROGRESS

๐Ÿงช Hands-on Lab: Deploy Real Infra

Ready for the real thing? Follow this guide to deploy a VPC, ALB, and ECS cluster using the provided zip file.

Part 1: Prerequisites (The "Foolproof" Setup)

1

Install AWS CLI

You need the command line tool to talk to AWS. Open your terminal and type:

aws --version

If it says "command not found", download it here: AWS CLI Installer

2

Get Access Keys

Go to the AWS Console > IAM > Users > Security Credentials.

Click Create Access Key. You will get two strings:

  • Access Key ID: (e.g., AKIAIOSFODNN7EXAMPLE)
  • Secret Access Key: (e.g., wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY)

โš ๏ธ Save these! You won't see the secret again.

3

Login to Terminal

Run this command and paste your keys when asked:

aws configure

Region: us-east-1 (or your preferred region)
Output format: json

Part 2: Run the Lab

We have prepared a zip file with clean, production-ready code. It contains a deploy.sh script that handles the complex commands for you.

Download test.zip
# 1. Unzip the file and enter the folder
unzip test.zip
cd Test
# 2. Make the scripts executable (Mac/Linux only)
chmod +x deploy.sh cleanup.sh
# 3. Deploy the stack! (Takes ~5 minutes)
./deploy.sh
> Waiting for changeset to be created...
> Stack aws-test-root creation completed successfully!
# 4. Cleanup (IMPORTANT: Run this when done to save money)
./cleanup.sh