Skip to main content
AWS gives you full control over infrastructure, scaling, and networking. This guide covers deploying BunShip with ECS Fargate (the recommended approach), with notes on EC2 and Lambda alternatives.

Architecture Options

This guide focuses on ECS Fargate. It provides the best balance of simplicity and production readiness for BunShip deployments.

Prerequisites

  • An AWS account
  • The AWS CLI v2 installed and configured
  • A Turso account for the database
  • Docker installed locally (for building images)

ECS Fargate Deployment

1

Create an ECR repository

Amazon Elastic Container Registry stores your Docker images.
2

Build and push the image

3

Create an ECS cluster

4

Store secrets in AWS Secrets Manager

Store sensitive values separately from your task definition.
5

Create a task definition

Save this as ecs-task-definition.json:
Register the task definition:
6

Create an Application Load Balancer

The ALB distributes traffic across your ECS tasks and terminates TLS.
7

Create the ECS service

The deployment configuration ensures zero downtime: ECS starts new tasks before draining old ones.
8

Deploy the worker

Create a second task definition for the worker with a different command. The worker does not need a load balancer or port mappings.

ElastiCache for Redis

If you prefer AWS-managed Redis over Upstash or other providers:
Update your REDIS_URL secret to point to the ElastiCache endpoint:
ElastiCache is VPC-only. Your ECS tasks must run in the same VPC and security group must allow port 6379 between the ECS tasks and the ElastiCache cluster.

S3 Bucket Configuration

Create a bucket for file uploads:
Set the environment variables:
For ECS tasks, use an IAM task role with S3 permissions instead of access keys. This avoids storing long-lived credentials.

CloudFront CDN

Place CloudFront in front of your ALB for edge caching and DDoS protection:
Key CloudFront settings for an API: For static assets served from S3, create a separate CloudFront behavior with caching enabled.

ALB Health Checks

The ALB health check confirms each ECS task is ready to serve traffic: ECS also runs the container-level health check defined in the task definition. A task that fails either check is replaced automatically.

CI/CD with GitHub Actions

BunShip includes a release workflow (.github/workflows/release.yml) that builds and pushes Docker images when you create a version tag. Extend it with an ECS deployment step:
Add these secrets to your GitHub repository:
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
For better security, use GitHub OIDC with AWS instead of long-lived access keys.

Scaling

ECS Auto Scaling

Configure target tracking to scale based on CPU utilization:
This maintains average CPU at 70%, scaling between 2 and 10 tasks.

Cost Estimates

Approximate monthly costs for a small production deployment in us-east-1: Costs scale with traffic. Fargate Spot can reduce compute costs by up to 70% for fault-tolerant workloads like the worker.