AWS Copilot
The easiest way to deploy containers to AWS ECS Fargate
What is AWS Copilot?
AWS Copilot is a command-line tool that simplifies deploying and managing containerized applications on AWS. Instead of manually configuring VPCs, ECS clusters, load balancers, and IAM roles, Copilot handles everything with simple commands.
Perfect for Beginners
Installation
Install using Homebrew:
Verify Installation
copilot version: v1.32.0
Copilot Concepts
| Concept | What It Is | Example |
|---|---|---|
| Application | A collection of related services | "my-app" |
| Environment | A deployment stage | "staging", "production" |
| Service | A containerized workload | "frontend", "api" |
Quick Deploy Guide
Initialize Application
Run this in your project directory with a Dockerfile:
Create an Environment
This creates your VPC, ECS cluster, and load balancer:
Deploy Your Service
Build, push to ECR, and deploy to ECS Fargate:
Application name: my-app Workload type: Load Balanced Web Service Service name: frontend Dockerfile: ./Dockerfile
Environment name: staging Credential source: [profile default] Default environment configuration? Yes
Building your container image... Pushing to ECR... Creating CloudFormation stack... ✔ Deployed frontend to staging. URL: http://my-app-staging-123456.ap-southeast-1.elb.amazonaws.com
First Deploy Takes Time
Useful Commands
| Command | Purpose |
|---|---|
copilot svc status | Check service health and URL |
copilot svc logs | View application logs |
copilot svc exec | SSH into a running container |
copilot app delete | Remove everything (careful!) |
What Copilot Creates
Behind the scenes, Copilot provisions:
- VPC with public/private subnets
- ECS Cluster in Fargate mode
- Application Load Balancer
- ECR Repository for your images
- CloudWatch Log Groups
- IAM Roles and Policies
- Security Groups
Service Manifest
Copilot uses manifest files to configure your service. Choose the right level:
A minimal manifest for learning and development:
name: frontend
type: Load Balanced Web Service
http:
path: '/'
image:
build: Dockerfile
port: 3000
cpu: 256
memory: 512
count: 1
variables:
NODE_ENV: productionMissing for Production
- No health check endpoint
- Single task (no high availability)
- No auto-scaling
- No HTTPS configured
AWS Services Configuration
If your app uses AWS services like S3, SQS, or CloudWatch, you need to configure environment variables. Choose the appropriate method for your use case:
Security Warning
copilot/frontend/manifest.yml to your .gitignore when using plain text credentials for POC testing.Quick setup for testing. Put credentials directly in the manifest. Not recommended for production - rotate these credentials after testing!
# Full working manifest for POC with AWS services
name: frontend
type: Load Balanced Web Service
http:
path: '/'
healthcheck:
path: '/api/health'
healthy_threshold: 2
unhealthy_threshold: 3
interval: 15s
timeout: 10s
image:
build: Dockerfile
port: 3000
cpu: 256
memory: 512
count: 1
exec: true # Enable ECS Exec for debugging
variables:
# App Configuration
HOSTNAME: "0.0.0.0"
PORT: "3000"
NODE_ENV: production
# AWS Configuration - CHANGE THESE TO YOUR VALUES
AWS_REGION: "us-east-1"
AWS_S3_BUCKET_NAME: "your-bucket-name"
AWS_SQS_QUEUE_URL: "https://sqs.us-east-1.amazonaws.com/123456789012/your-queue-name"
AWS_CLOUDWATCH_LOG_GROUP: "your-log-group-name"
# AWS Credentials - REPLACE WITH YOUR KEYS (rotate after testing!)
AWS_ACCESS_KEY_ID: "YOUR_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY: "YOUR_SECRET_ACCESS_KEY"
logging:
retention: 7Don't Forget!
- 1. Add
copilot/frontend/manifest.ymlto.gitignore - 2. Replace all placeholder values with your actual AWS resource IDs
- 3. Rotate credentials in IAM console after testing
Deploy with AWS Services
Building your container image... Pushing to ECR... Deploying to ECS... ✔ Deployed frontend to staging.
Verify AWS Integration
After deployment, navigate to your app's /demos page. If configured correctly, you'll see "Live AWS" badges instead of "Mock Mode".
⚠️ Cost Awareness - READ THIS
Running an ECS Fargate service with ALB costs approximately $30-50/month for a small workload. Major cost components:
- ALB: ~$16/month (fixed cost while running)
- Fargate: ~$15-30/month (depends on vCPU/memory)
- NAT Gateway: ~$32/month if using private subnets
Always delete resources when done: copilot app delete
See our Costs & Cleanup Guide for detailed breakdown and cleanup instructions.