AWS Copilot

Beginner Friendly

The simplest way to deploy containers to AWS

šŸ’µ Cost Warning: Copilot creates real AWS resources that incur charges. A typical deployment costs $30-50/month: ALB (~$16/mo), Fargate (~$15/mo), NAT Gateway (~$32/mo if using private subnets). Use copilot svc pause to scale to zero when not needed, or copilot app delete to remove everything. See our Costs & Cleanup Guide.

What is AWS Copilot?

AWS Copilot is a CLI tool that simplifies deploying containerized applications to AWS. It abstracts away the complexity of ECS, VPC, ALB, and IAM configuration into simple commands and YAML manifests.

Best for Getting Started

Copilot is perfect if you want to deploy quickly without learning CloudFormation, Terraform, or the intricacies of ECS networking. It makes opinionated choices that work well for most applications.

Copilot Architecture

Plain Text
Application: "my-app"
ā”œā”€ā”€ Environment: "staging"
│   ā”œā”€ā”€ VPC with public/private subnets
│   ā”œā”€ā”€ ECS Cluster
│   ā”œā”€ā”€ Application Load Balancer
│   └── Services:
│       ā”œā”€ā”€ frontend (Load Balanced Web Service)
│       └── worker (Worker Service)
│
└── Environment: "production"
    ā”œā”€ā”€ VPC with public/private subnets
    ā”œā”€ā”€ ECS Cluster
    ā”œā”€ā”€ Application Load Balancer
    └── Services:
        ā”œā”€ā”€ frontend
        └── worker

Service Types

TypeUse CaseFeatures
Load Balanced Web ServiceWeb apps, APIsALB, HTTPS, autoscaling
Backend ServiceInternal APIsService discovery, no public access
Worker ServiceBackground jobsSQS queue processing
Scheduled JobCron tasksEventBridge scheduled execution

Deployment Workflow

1

Initialize Application

Create a Copilot application that groups all your services and environments.

2

Create Environment

Set up a deployment environment (staging, production) with VPC and networking.

3

Initialize Service

Configure your container service with the appropriate type and settings.

4

Deploy

Build your container, push to ECR, and deploy to ECS Fargate.

Step 1: Initialize Application

Terminal
$copilot app init my-app
āœ” Created directory copilot/ for application my-app
āœ” Created application my-app

Step 2: Create Environment

Terminal
$copilot env init --name staging --profile default --default-config
āœ” Proposing infrastructure changes for stack my-app-staging
āœ” Created environment staging in region ap-southeast-1
Terminal
$copilot env deploy --name staging
āœ” Deployed staging environment
VPC: vpc-0abc123...
Subnets: subnet-pub-a, subnet-pub-b, subnet-priv-a, subnet-priv-b

Step 3: Initialize Service

Terminal
$copilot svc init --name frontend --svc-type "Load Balanced Web Service" --dockerfile ./Dockerfile
āœ” Created manifest file copilot/frontend/manifest.yml
āœ” Your manifest contains configurations like port 3000

Step 4: Deploy

Terminal
$copilot deploy --name frontend --env staging
Building your container image...
Pushing to ECR...
Deploying to ECS Fargate...

āœ” Deployed frontend to staging
URL: http://my-app-staging-Publi-XXXXX.ap-southeast-1.elb.amazonaws.com

Useful Commands

CommandPurpose
copilot svc statusCheck service health
copilot svc logs --followStream logs
copilot svc execSSH into container
copilot svc pauseScale to zero (save costs)
copilot svc resumeScale back up
copilot app deleteDelete everything

Cost Control - Important Commands

  • copilot svc pause --name frontend --env staging - Scale service to 0 tasks (stops Fargate charges)
  • copilot env delete --name staging - Delete an environment (removes VPC, ALB, NAT Gateway)
  • copilot app delete - Delete entire application and ALL resources (irreversible)

Always delete unused environments to avoid ongoing charges, especially NAT Gateway costs.

When to Use Copilot vs Terraform

Use Copilot WhenUse Terraform When
Getting started quicklyNeed fine-grained control
Standard web app patternsComplex multi-service architectures
Small team, move fastInfrastructure team, governance needs
AWS-only deploymentMulti-cloud deployment

AWS Deployment Guide — Built with Next.js