Day 3 of 5
⏱ ~60 minutes
Deploy to AWS — Day 3

AWS App Runner — Deploy Containerized Apps in Minutes

Deploy a containerized web app to AWS App Runner from an ECR image or GitHub repo with auto-scaling and HTTPS out of the box.

AWS App Runner

App Runner is the easiest way to deploy containerized apps on AWS. You give it a container image (from ECR) or a source code repo (from GitHub), and it handles provisioning, load balancing, auto-scaling, TLS, and health checks. No ECS task definitions, no ALB configuration, no ASG tuning.

Push a Docker Image to ECR

Terminal — Create ECR repository and push image
# Create repository
aws ecr create-repository --repository-name my-ai-app

# Get your account ID
ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
REGION=us-east-1
REPO=$ACCOUNT.dkr.ecr.$REGION.amazonaws.com/my-ai-app

# Authenticate Docker to ECR
aws ecr get-login-password | docker login --username AWS --password-stdin $REPO

# Build and push
docker build -t my-ai-app .
docker tag my-ai-app:latest $REPO:latest
docker push $REPO:latest

Create an App Runner Service

apprunner.json — Service configuration
{
  "ServiceName": "my-ai-app",
  "SourceConfiguration": {
    "ImageRepository": {
      "ImageIdentifier": "123456789.dkr.ecr.us-east-1.amazonaws.com/my-ai-app:latest",
      "ImageRepositoryType": "ECR",
      "ImageConfiguration": {
        "Port": "3000",
        "RuntimeEnvironmentVariables": {
          "NODE_ENV": "production",
          "ANTHROPIC_API_KEY": "{{resolve:secretsmanager:prod/anthropic-key}}"
        }
      }
    },
    "AutoDeploymentsEnabled": true
  },
  "InstanceConfiguration": {
    "Cpu": "1 vCPU",
    "Memory": "2 GB"
  },
  "HealthCheckConfiguration": {
    "Protocol": "HTTP",
    "Path": "/health",
    "Interval": 10,
    "Timeout": 5,
    "HealthyThreshold": 2,
    "UnhealthyThreshold": 3
  }
}
Terminal — Deploy
aws apprunner create-service --cli-input-json file://apprunner.json

# Check status
aws apprunner list-services

# Get service URL
aws apprunner describe-service   --service-arn arn:aws:apprunner:us-east-1:123456:service/my-ai-app/abc   --query 'Service.ServiceUrl' --output text
ℹ️
Auto-scaling: App Runner scales to zero when there's no traffic. Cold starts take ~2-3 seconds. For low-latency requirements, set a minimum of 1 instance.

Add a Health Check Endpoint

Node.js — /health endpoint
app.get('/health', (req, res) => {
  res.json({
    status: 'ok',
    timestamp: new Date().toISOString(),
    version: process.env.npm_package_version
  });
});
Day 3 Exercise
Deploy Your App to App Runner
  1. Create an ECR repository and push your Docker image
  2. Create an IAM role for App Runner with ECR pull permissions
  3. Create an App Runner service using the console or CLI
  4. Add a /health endpoint to your app if you don't have one
  5. Wait for the service to deploy and test the live URL

Day 3 Summary

  • App Runner handles load balancing, TLS, and auto-scaling automatically
  • ECR is where you push your Docker images for App Runner to pull
  • AutoDeploymentsEnabled auto-deploys when you push a new image to ECR
  • Environment variables in App Runner can reference Secrets Manager values
  • A /health endpoint lets App Runner verify your app started correctly
Finished this lesson?