โ˜๏ธ PuffCloud Computing 101๐ŸŽž๏ธ Slides

Course 2 ยท Compute, data and the 3-tier app

Your app on ECS with a database, wide open

๐ŸŽฏ By the end of today

๐Ÿ—“๏ธ The plan for today

TimeWhatWhere
0:00 (15 min)The course is now one project: groups of 3, the M0 โ†’ M5 map, Floci on your laptop or in a CodespaceLecture
0:15 (40 min)Compute: VM vs container vs function, EC2, ECS, ECR, user data, pricingLecture
0:55 (25 min)Data: RDS vs DynamoDB vs S3, the 3-tier app from laptop to cloudLecture
1:20 (10 min)Break
1:30 (40 min)Project M0 catch-up: setup, group users, the auditor's AccessDeniedProject
2:10 (85 min)Project M1: your app from GitHub on ECS, a load balancer, a database, a status page, the VM wayProject
3:35 (15 min)Check M1, commit, push, and list what's wrong with this deployProject
4:00End. Not done? Course 3's project block opens with 15 minutes of catch-up

๐Ÿ–ฅ๏ธ EC2: a computer you rent by the second

Your code needs a computer to run on.
Buying one means waiting weeks and paying for it even while it sleeps, so instead you rent one from AWS in about a minute and pay by the second.

๐ŸŽฌ Servers you rent (1 min 27)

That rented computer is an EC2 instance, a virtual machine living in one Availability Zone.
It's like a hotel room, you pick the size, you check in, you check out, and someone else fixes the plumbing.

Launching one means four choices:

The network part waits for next course.

An AMI is what the instance boots from, like a fresh laptop with the operating system already installed.
We use Amazon Linux 2023, its package manager is dnf.

The instance type is the room size. A t3.micro has 2 vCPUs (virtual processors) and 1 GiB of memory, plenty for the board app.
Families exist because apps need different things:

FamilyBuilt forPick it whenExample
T (t3, t4g)Short bursts of CPUThe CPU is mostly idle with short spikesA small API, a dev box, the board app
M (m7i, m7g)A bit of everythingYou don't know yet, and the load is steadyA web app with real traffic
C (c7i, c7g)Raw CPUThe processor is what slows you downVideo encoding, batch jobs, busy APIs
R (r7i, r7g)Lots of memoryYour data must fit in RAMCaches you run yourself, in-memory analytics
I (i4i)Very fast local diskYou read and write the disk nonstopDatabases or search engines you run yourself
G, P (g5, p5)GPUsYou train or serve machine learning modelsInference servers

Start small in T or M, measure for a week, then resize.
Resizing is stop, change type, start, so a wrong guess costs you five minutes.

๐Ÿ” Want more? Reading an instance type name, baking an AMI
  • You can bake your own AMI from a configured instance, boots get faster but you rebuild the image every time you patch something.
  • In m7g.large, m is the family, 7 the generation, g means Graviton (AWS's own ARM processor), and large is the size.
  • Each size step roughly doubles the resources and the price: large, xlarge, 2xlarge, and so on.
๐Ÿ–ฅ๏ธ Pick the instanceOpen full screen

๐Ÿ’พ Where your data lives on a server

Servers die, and when yours does, the question is which files die with it.
AWS gives you four places to keep data, and they don't behave the same when that happens.
EBS is like a USB drive plugged in through the network, EFS is the Elastic File System, and S3 is the storage you met in course 1.

EBSInstance storeEFSS3
What it isA disk over the networkA physical disk in the host machineA shared folder (NFS)Files you fetch over HTTP
Plugged intoOne instance, one AZThat instance onlyMany instances, many AZsNothing, you call an API
Survives a stopYesNo, wipedYesYes
Survives terminateOnly if "delete on termination" is offNoYesYes
Good forThe main disk, database filesScratch space, cachesFiles shared by many serversStatic sites, uploads, backups
Price feelMediumIncluded in the instance priceHigh per GBCheapest per GB

Treat the instance and its disks as disposable.
Anything you can't lose goes to RDS, S3 or EFS, because in next courses, Puff will kill and replace your instances automatically.

๐Ÿ” Want more? Disk details
  • EBS snapshots are backups of a disk that only store what changed since the last one.
  • A small app needs a few GB, and on real AWS you pay for every provisioned GB, used or not.
๐Ÿ’พ Storage matchOpen full screen

๐Ÿš€ User data and getting into the box

User data is a script the instance runs once, as root (the admin user), on its first boot.
A tool called cloud-init reads it and runs it.

It's the cheapest automation there is, the instance sets itself up from a stock image and you never log in to install anything.

The script's output lands in /var/log/cloud-init-output.log.
That's the first file to read when something didn't start.

Sometimes you still need a shell on the machine, and there are two ways in.

๐Ÿ’ถ Paying for EC2

The same machine can cost very different prices, depending on what you promise AWS.
It's like a taxi meter (On-Demand), a gym subscription (Savings Plans) or a standby plane ticket (Spot).

ModelHow it worksDiscount vs On-DemandUse it for
On-DemandPay per second, stop anytimeNoneNew workloads, spiky or short-lived things, a course project
Savings PlansPromise to spend a fixed \$/hour for 1 or 3 yearsUp to about 72%The steady base you'll run all year anyway
Reserved InstancesPromise to run one specific instance type for 1 or 3 yearsUp to about 72%Same idea, older and less flexible (still common for RDS)
SpotUse AWS's spare machines, AWS can take them backUp to about 90%Work that can be interrupted: test runners, batch jobs, rendering

The discount grows with what you give AWS, time for Savings Plans, the right to interrupt you for Spot.
Spot is a bad idea for anything that can't stop at two minutes' notice, like your only API server.

๐Ÿ” Want more? Spot in practice

If the work can save its progress and retry (a batch job, a test run), that's 70 to 90% off.
If it holds data, losing the instance means your app is down.

A sensible mix is a Savings Plan for the base, On-Demand for peaks, Spot for work that doesn't mind dying.

๐Ÿ’ถ Pay for EC2Open full screen

๐Ÿณ Containers on a plain VM

You already know Docker, so the question is where the containers run.

AWS has two container platforms:

Both are orchestrators, they decide which container runs on which machine.
Your project runs on ECS: you give it an image and a count, it keeps that many containers running and replaces the ones that die. Running Docker by hand on an EC2 box also works, and step 7 of M1 shows you why people stopped doing it.

For a small app that's a valid real-world setup, one image you can rebuild, the same everywhere, nothing new to learn.
You give up what the orchestrator does, rolling out new versions without downtime, moving containers off a dead machine, packing many services onto few machines.

With one service and a handful of instances, Kubernetes is overhead.
Use it when you have many services and a team to run it.

๐Ÿ—„๏ธ RDS: what "managed" means

The database is the one piece of your app you can't rebuild from a script, lose it and the messages are gone.

๐ŸŽฌ Managed databases (1 min 23)

RDS runs a relational engine (PostgreSQL, MySQL, MariaDB, Oracle, SQL Server, Aurora) on machines AWS operates, like renting a flat with a caretaker instead of owning a house.
You get an address like puff-db.abc123xyz.us-east-1.rds.amazonaws.com (the endpoint) and no shell on the server.

AWS handles:

The table design, slow queries, indexes, how many connections you open, passwords, sizing and the bill stay your job.

RDS PostgreSQLPostgreSQL on EC2
SetupA form or one CLI commandYou install, configure and lock it down
Backups and restoreBuilt in, rewind to any secondYou script pg_dump or log archiving and test restores
Surviving a crashTick the Multi-AZ boxYou build replication and failover
ControlNo superuser, limited extensionsFull root, any extension, any version
CostHigher per hourLower per hour, higher in your time

The hours of human work you save on backups and failover are worth far more than the price difference.
Run it yourself only when you need something RDS can't do.

๐Ÿงฎ DynamoDB or RDS?

Picking the wrong kind of database hurts for years, because data is hard to move.

DynamoDB is a serverless key-value and document database, no instance to size, millisecond reads at any scale, and you pay per request.
It's like a giant coat check, hand over your ticket and you get your coat back instantly, but you can't ask for every red coat.
So you design the table around the questions you'll ask it, up front, and there are no joins.

RDS (relational)DynamoDB
How data looksTables that reference each otherItems fetched by their key
Questions you can askAny SQL, even ones you invent laterOnly what your keys and indexes allow
GrowingBigger instance, read-only copiesAutomatic, nearly unlimited
Work for youInstance size, connections, maintenanceAlmost none
Good forBusiness data with relations, reporting, future questionsSessions, shopping carts, device state, lookups by ID

Pick by how you'll read the data.
Relations and questions nobody has written yet go relational, huge volumes of lookups by key go to DynamoDB.

An insurer's members, contracts and claims reference each other and get queried in ways nobody predicted on day one, that's relational.
A "last seen" time per mobile phone, read and written millions of times a day by device ID, is a DynamoDB table.

The board app uses PostgreSQL, it's the safe default, and "list the 20 latest messages" is one line of SQL.

๐Ÿงฐ Purpose-built databases

AWS sells one database per shape of data.
You won't use most of them this week, but you should recognize them on an architecture diagram.

๐Ÿ” Want more? The database menu
ServiceShapeTypical use
AuroraRelational, MySQL or PostgreSQL compatible, AWS storage layerSame as RDS with faster failover and more read replicas
DynamoDBKey-value and documentHigh-volume lookups by key
ElastiCacheIn-memory (Redis/Valkey, Memcached)Caching, sessions, rate limiting (ElastiCache, it runs on Floci too)
DocumentDBJSON documents, MongoDB compatibleApps written against MongoDB
NeptuneGraphFraud rings, recommendations, social graphs
TimestreamTime seriesMetrics, IoT sensor readings
OpenSearchSearch indexFull-text search, log analytics
RedshiftColumnar data warehouseAnalytics over billions of rows
๐Ÿ—„๏ธ Pick the databaseOpen full screen

๐Ÿ—๏ธ The 3-tier app, from your laptop to the cloud

Most web apps have three tiers, like a restaurant:

Each one only talks to its neighbor, so you can grow, protect or replace them separately.

On your laptop, it fits in a compose.yaml next to the code below:

services:
  db:
    image: postgres:16
    environment:
      POSTGRES_DB: puff
      POSTGRES_USER: puff
      POSTGRES_PASSWORD: localdev
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "puff"]
      interval: 2s
      retries: 15
  api:
    build: .
    ports:
      - "8080:8080"
    environment:
      DB_HOST: db
      DB_NAME: puff
      DB_USER: puff
      DB_PASSWORD: localdev
    depends_on:
      db:
        condition: service_healthy

Moving to the cloud means swapping each line for an AWS piece.
Today is the most direct swap, and Puff improves it piece by piece over the next courses:

On your laptopToday on AWSWhere it ends up
db container and its volumeRDS puff-db in the default VPCRDS in private subnets (course 3)
api built from the DockerfileDocker on EC2 puff-api, built by user dataAuto Scaling group behind a load balancer (courses 3 and 5)
Opening index.html locallyS3 static websiteBehind CloudFront, AWS's content delivery network (course 5)
ports: 8080:8080Port 8080 open to the internetOnly the load balancer is public (course 3)
Password in environment:Password in a docker run -eSSM Parameter Store (course 4)
docker compose upYou, typing CLI commandsCloudFormation (course 6)

The default VPC (Virtual Private Cloud) is the ready-made network every AWS account starts with.

๐Ÿ—บ๏ธ Today's deployOpen full screen

The browser loads index.html from your S3 bucket, then calls puff-api on EC2 by its public IP, on port 8080.
puff-api reads and writes messages in puff-db on port 5432, and both sit in the default VPC.
Anyone can reach the bucket and port 8080, only puff-api can reach puff-db.

๐Ÿ—๏ธ Laptop to cloudOpen full screen

๐Ÿงช Project M1: your app on ECS, a database, a status page

You deploy the naive version on purpose: everything in the default VPC, everything open.
It works, and it's wrong in at least five ways. Courses 3 to 6 fix it one capability at a time.

Before you start: M0 done, Floci running, source env.sh and export GROUP=gXX in your terminal.
Copy every command that works into infra/deploy.sh as you go. That file is your infra.

Step 1: your app from GitHub, into ECR. Default app below, swap the URL for any simple app with a Dockerfile that listens on port 80.

# A repository in ECR, the registry that holds your images
aws ecr create-repository --repository-name $GROUP-app

# Get the app's code
git clone --depth 1 https://github.com/traefik/whoami.git app-src

# Build the image, named after Floci's registry ($REGISTRY = localhost:5100)
docker build -t $REGISTRY/$GROUP-app:v1 app-src

# Push it, then check ECR sees it
docker push $REGISTRY/$GROUP-app:v1
aws ecr list-images --repository-name $GROUP-app
# A repository in ECR, the registry that holds your images
aws ecr create-repository --repository-name "$env:GROUP-app"

# Get the app's code
git clone --depth 1 https://github.com/traefik/whoami.git app-src

# Build the image, named after Floci's registry ($env:REGISTRY = localhost:5100)
docker build -t "$env:REGISTRY/$env:GROUP-app:v1" app-src

# Push it, then check ECR sees it
docker push "$env:REGISTRY/$env:GROUP-app:v1"
aws ecr list-images --repository-name "$env:GROUP-app"

On real AWS you'd push to the ECR URI after aws ecr get-login-password | docker login.

Step 2: the network pieces, naive. The default VPC, two subnets, two security groups open to the world.

# The default VPC every account starts with
VPC=$(aws ec2 describe-vpcs --filters Name=is-default,Values=true \
  --query 'Vpcs[0].VpcId' --output text)

# Two of its subnets, in two Availability Zones, comma-separated
SUBNETS=$(aws ec2 describe-subnets --filters Name=vpc-id,Values=$VPC \
  --query 'Subnets[:2].SubnetId' --output text | tr '\t' ',')

# One firewall for the load balancer, one for the app
ALB_SG=$(aws ec2 create-security-group --group-name $GROUP-alb-sg \
  --description "ALB" --vpc-id $VPC --query GroupId --output text)
APP_SG=$(aws ec2 create-security-group --group-name $GROUP-app-sg \
  --description "app" --vpc-id $VPC --query GroupId --output text)

# Both open on port 80 to the whole internet (sin number 1, fixed in course 3)
aws ec2 authorize-security-group-ingress --group-id $ALB_SG --protocol tcp --port 80 --cidr 0.0.0.0/0
aws ec2 authorize-security-group-ingress --group-id $APP_SG --protocol tcp --port 80 --cidr 0.0.0.0/0
# The default VPC every account starts with
$VPC = aws ec2 describe-vpcs --filters Name=is-default,Values=true `
  --query 'Vpcs[0].VpcId' --output text

# Two of its subnets, in two Availability Zones
$SUBNETS = (aws ec2 describe-subnets --filters "Name=vpc-id,Values=$VPC" `
  --query 'Subnets[:2].SubnetId' --output text) -split '\s+'

# One firewall for the load balancer, one for the app
$ALB_SG = aws ec2 create-security-group --group-name "$env:GROUP-alb-sg" `
  --description "ALB" --vpc-id $VPC --query GroupId --output text
$APP_SG = aws ec2 create-security-group --group-name "$env:GROUP-app-sg" `
  --description "app" --vpc-id $VPC --query GroupId --output text

# Both open on port 80 to the whole internet (sin number 1, fixed in course 3)
aws ec2 authorize-security-group-ingress --group-id $ALB_SG --protocol tcp --port 80 --cidr 0.0.0.0/0
aws ec2 authorize-security-group-ingress --group-id $APP_SG --protocol tcp --port 80 --cidr 0.0.0.0/0

Step 3: a load balancer, the single address your users hit.

# The Application Load Balancer, spread over the two subnets
ALB=$(aws elbv2 create-load-balancer --name $GROUP-alb \
  --subnets ${SUBNETS//,/ } --security-groups $ALB_SG \
  --query 'LoadBalancers[0].LoadBalancerArn' --output text)

# A target group: the containers the ALB sends traffic to, and how it checks they're alive
TG=$(aws elbv2 create-target-group --name $GROUP-tg \
  --protocol HTTP --port 80 --target-type ip --vpc-id $VPC --health-check-path / \
  --query 'TargetGroups[0].TargetGroupArn' --output text)

# A listener: "on port 80, forward to the target group"
aws elbv2 create-listener --load-balancer-arn $ALB --protocol HTTP --port 80 \
  --default-actions Type=forward,TargetGroupArn=$TG
# The Application Load Balancer, spread over the two subnets
$ALB = aws elbv2 create-load-balancer --name "$env:GROUP-alb" `
  --subnets $SUBNETS --security-groups $ALB_SG `
  --query 'LoadBalancers[0].LoadBalancerArn' --output text

# A target group: the containers the ALB sends traffic to, and how it checks they're alive
$TG = aws elbv2 create-target-group --name "$env:GROUP-tg" `
  --protocol HTTP --port 80 --target-type ip --vpc-id $VPC --health-check-path / `
  --query 'TargetGroups[0].TargetGroupArn' --output text

# A listener: "on port 80, forward to the target group"
aws elbv2 create-listener --load-balancer-arn $ALB --protocol HTTP --port 80 `
  --default-actions "Type=forward,TargetGroupArn=$TG"

Step 4: run the app on ECS, one container for now.

# A cluster: the logical home of your services
aws ecs create-cluster --cluster-name $GROUP

# A task definition: which image, how much CPU and memory, which port
aws ecs register-task-definition --family $GROUP-app \
  --network-mode awsvpc --requires-compatibilities FARGATE --cpu 256 --memory 512 \
  --container-definitions "[{\"name\":\"app\",\"image\":\"$REGISTRY/$GROUP-app:v1\",\"portMappings\":[{\"containerPort\":80}],\"essential\":true}]"

# A service: keep 1 copy running, plugged into the target group
aws ecs create-service --cluster $GROUP --service-name $GROUP-app \
  --task-definition $GROUP-app --desired-count 1 --launch-type FARGATE \
  --network-configuration "awsvpcConfiguration={subnets=[$SUBNETS],securityGroups=[$APP_SG],assignPublicIp=ENABLED}" \
  --load-balancers "targetGroupArn=$TG,containerName=app,containerPort=80"
# A cluster: the logical home of your services
aws ecs create-cluster --cluster-name $env:GROUP

# A task definition: which image, how much CPU and memory, which port (written to a file)
@"
[{"name": "app", "image": "$env:REGISTRY/$env:GROUP-app:v1", "portMappings": [{"containerPort": 80}], "essential": true}]
"@ | Set-Content task.json
aws ecs register-task-definition --family "$env:GROUP-app" `
  --network-mode awsvpc --requires-compatibilities FARGATE --cpu 256 --memory 512 `
  --container-definitions file://task.json

# A service: keep 1 copy running, plugged into the target group
aws ecs create-service --cluster $env:GROUP --service-name "$env:GROUP-app" `
  --task-definition "$env:GROUP-app" --desired-count 1 --launch-type FARGATE `
  --network-configuration "awsvpcConfiguration={subnets=[$($SUBNETS -join ',')],securityGroups=[$APP_SG],assignPublicIp=ENABLED}" `
  --load-balancers "targetGroupArn=$TG,containerName=app,containerPort=80"

Open it in your browser after about 30 seconds:

# Print your app's URL
echo "http://$(aws elbv2 describe-load-balancers --names $GROUP-alb \
  --query 'LoadBalancers[0].DNSName' --output text)/"
# Print your app's URL
$DNS = aws elbv2 describe-load-balancers --names "$env:GROUP-alb" `
  --query 'LoadBalancers[0].DNSName' --output text
"http://$DNS/"

In a Codespace, open the Ports tab and click the globe on port 80 instead.

Step 5: a database, PostgreSQL managed by RDS. Public, password in clear: sins number 2 and 3.

# A small PostgreSQL, reachable from anywhere, password typed in clear
aws rds create-db-instance --db-instance-identifier $GROUP-db \
  --engine postgres --db-instance-class db.t3.micro --allocated-storage 20 \
  --master-username app --master-user-password 'ChangeMe-123' \
  --publicly-accessible

# Its status and the address your app would connect to
aws rds describe-db-instances --db-instance-identifier $GROUP-db \
  --query 'DBInstances[0].[DBInstanceStatus,Endpoint.Address,Endpoint.Port]'
# A small PostgreSQL, reachable from anywhere, password typed in clear
aws rds create-db-instance --db-instance-identifier "$env:GROUP-db" `
  --engine postgres --db-instance-class db.t3.micro --allocated-storage 20 `
  --master-username app --master-user-password 'ChangeMe-123' `
  --publicly-accessible

# Its status and the address your app would connect to
aws rds describe-db-instances --db-instance-identifier "$env:GROUP-db" `
  --query 'DBInstances[0].[DBInstanceStatus,Endpoint.Address,Endpoint.Port]'

Step 6: a status page on S3, the page your users see when everything else is down.

# The page itself, uploaded to your group bucket
echo "<h1>$GROUP is up</h1>" > index.html
aws s3 cp index.html s3://$GROUP-site/

# Turn the bucket into a website
aws s3 website s3://$GROUP-site/ --index-document index.html

# New buckets block public policies, like on real AWS: lift that block
aws s3api delete-public-access-block --bucket $GROUP-site

# Let anyone read the files
aws s3api put-bucket-policy --bucket $GROUP-site --policy "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::$GROUP-site/*\"}]}"

# Check it answers
curl http://$GROUP-site.s3-website-us-east-1.localhost:4566/
# The page itself, uploaded to your group bucket
Set-Content index.html "<h1>$env:GROUP is up</h1>"
aws s3 cp index.html "s3://$env:GROUP-site/"

# Turn the bucket into a website
aws s3 website "s3://$env:GROUP-site/" --index-document index.html

# New buckets block public policies, like on real AWS: lift that block
aws s3api delete-public-access-block --bucket "$env:GROUP-site"

# Let anyone read the files (policy written to a file)
@"
{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::$env:GROUP-site/*"}]}
"@ | Set-Content site-policy.json
aws s3api put-bucket-policy --bucket "$env:GROUP-site" --policy file://site-policy.json

# Check it answers
curl.exe "http://$env:GROUP-site.s3-website-us-east-1.localhost:4566/"

Step 7: the VM way, 10 minutes to feel the difference with ECS. A real Linux box that sets itself up with user data.

# The script the VM runs by itself on first boot
cat > vm.sh <<'VM'
#!/bin/bash
dnf install -y python3 >/dev/null
echo "hello from a VM" > /tmp/index.html
cd /tmp && python3 -m http.server 8080 &
VM

# Launch one instance with that script ($AMI and $TYPE come from env.sh)
VM_ID=$(aws ec2 run-instances --image-id $AMI --instance-type $TYPE \
  --user-data file://vm.sh --query 'Instances[0].InstanceId' --output text)

# Is it running?
aws ec2 describe-instances --instance-ids $VM_ID \
  --query 'Reservations[0].Instances[0].State.Name'

# After a minute or two, look inside (on Floci the VM is a container on your machine)
docker exec floci-aws-ec2-$VM_ID curl -s localhost:8080

# Done with it
aws ec2 terminate-instances --instance-ids $VM_ID
# The script the VM runs by itself on first boot (saved with Linux line endings)
$userData = @'
#!/bin/bash
dnf install -y python3 >/dev/null
echo "hello from a VM" > /tmp/index.html
cd /tmp && python3 -m http.server 8080 &
'@
[IO.File]::WriteAllText((Join-Path $PWD vm.sh), ($userData -replace "`r`n", "`n") + "`n")

# Launch one instance with that script ($env:AMI and $env:TYPE come from env.ps1)
$VM_ID = aws ec2 run-instances --image-id $env:AMI --instance-type $env:TYPE `
  --user-data file://vm.sh --query 'Instances[0].InstanceId' --output text

# Is it running?
aws ec2 describe-instances --instance-ids $VM_ID `
  --query 'Reservations[0].Instances[0].State.Name'

# After a minute or two, look inside (on Floci the VM is a container on your machine)
docker exec "floci-aws-ec2-$VM_ID" curl -s localhost:8080

# Done with it
aws ec2 terminate-instances --instance-ids $VM_ID

Ask yourself: what did you have to install and run by hand on the VM, that ECS did for you?

Step 8: check, commit, push.

# Run the milestone check, keep its output in NOTES.md
./checks/check.sh M1 | tee -a NOTES.md

# Share it with your group
git add -A
git commit -m "M1"
git push
# Run the milestone check, keep its output in NOTES.md
$r = .\checks\check.ps1 M1
$r; $r | Add-Content NOTES.md

# Share it with your group
git add -A
git commit -m "M1"
git push
๐Ÿงฏ If it doesn't work
  • The ALB returns nothing for 30 seconds: the container is starting, wait. Still nothing after 2 minutes: aws ecs describe-services --cluster $GROUP --services $GROUP-app --query 'services[0].events[:3]'.
  • docker push says "HTTP response to HTTPS client": you pushed to the ECR URI, push to $REGISTRY/$GROUP-app:v1.
  • A variable like $VPC or $TG is empty: new terminal, rerun the line that sets it. That's why infra/deploy.sh exists.
  • Your own app doesn't answer: it must listen on 0.0.0.0:80 inside the container, change containerPort otherwise.
  • The VM's curl is empty: user data is still installing Python, retry in a minute. It's not part of the check.
  • Something is in a weird state: ./wipe.sh then ./infra/deploy.sh.
๐Ÿ“ธ On real AWS

The same commands work on a real account, with three differences: the image goes to the ECR URI, Fargate needs a task execution role to pull it, and the load balancer gets a real public DNS name on the internet.
The console shows the same objects: ECS โ†’ Clusters โ†’ your service โ†’ Tasks, EC2 โ†’ Load balancers โ†’ Listeners, RDS โ†’ Databases.

๐Ÿ•ต๏ธ What's wrong with this deploy?

M1 works, now list at least five problems with it, and for each one, what could happen and which AWS piece would fix it.
Five minutes alone, then compare with your group, and write the list in NOTES.md.

๐Ÿ’ก The list we'll fix
  • The app's security group is open to the whole internet, anyone can skip the load balancer. Course 3.
  • Everything sits in the default VPC with public IPs, nothing is private. Course 3.
  • The database is publicly accessible. Course 3.
  • The DB password is in clear, in your shell history and in your script. Course 4.
  • Everyone uses the admin keys, nobody has least privilege. Course 4.
  • No logs, no alarms: if it breaks, nobody knows. Course 4.
  • One container in one place: if it dies, you're down. Course 5.
  • No CDN, no HTTPS. Course 5.
  • Everything typed by hand: can another member rebuild it identically? Course 6.

๐ŸŽฒ Today's quiz

๐ŸŽฒ Today's quizOpen full screen

๐Ÿค” Think about it

๐Ÿ’ก Hints
  • Burstable instances earn credits during the quiet 50 minutes. Look at whether the credit balance ever hits zero.
  • Spot is built for work that can be interrupted. Think about the deadline: what if no spare machine is free for an hour?
  • RDS moves the endpoint name to the twin. An IP would keep pointing at the dead database.
  • The data is in RDS, the code is rebuilt from user data. Nothing on the instance is precious, which is exactly what Auto Scaling needs in course 5.

๐Ÿ“š Go deeper

Back to the timeline