π― Ready-to-deploy containerized app stack for AWS! Built by BC Government developers, for developers.
This template gives you a complete, production-ready application stack with:
- ποΈ Aurora Serverless v2 PostgreSQL database with PostGIS extension
- π³ ECS Fargate with mixed FARGATE/FARGATE_SPOT capacity providers for cost optimization
- π Flyway Migrations automated through ECS tasks for database schema management
- πͺ API Gateway with VPC link integration for secure backend access
- π CloudFront for frontend content delivery with WAF protection
- ποΈ NestJS TypeScript backend API with Prisma ORM
- βοΈ React with Vite for the frontend application
- ποΈ Terragrunt/Terraform for infrastructure-as-code deployment
- π GitHub Actions for CI/CD pipeline automation
- π AWS Secrets Manager integration for secure credential management
Before you start, make sure you have:
- β BCGOV AWS account with appropriate permissions
- β AWS CLI installed and configured
- β Docker/Podman installed (for local development)
- β Node.js 22+ and npm installed
- β Terraform CLI and Terragrunt
/quickstart-aws-sql
βββ π CODE_OF_CONDUCT.md # Project code of conduct
βββ π COMPLIANCE.yaml # Compliance and regulatory information
βββ π€ CONTRIBUTING.md # Contribution guidelines
βββ π³ docker-compose.yml # Local development environment definition
βββ π§ eslint.config.mjs # ESLint configuration
βββ π GHA.md # GitHub Actions workflows documentation
βββ π LICENSE # Project license
βββ π¦ package.json # Monorepo configuration and dependencies
βββ π README.md # Project documentation
βββ π renovate.json # Renovate bot configuration
βββ π SECURITY.md # Security policy
βββ π§ tsconfig.json # TypeScript configuration
βββ ποΈ backend/ # NestJS backend API code
β βββ π³ Dockerfile # Container definition for backend service
β βββ π§ nest-cli.json # NestJS CLI configuration
β βββ π¦ package.json # Backend dependencies
β βββ π prisma/ # Prisma ORM schema and migrations
β β βββ schema.prisma # Database schema definition
β βββ π» src/ # Source code (controllers, services, modules)
β βββ π§ͺ test/ # Backend test utilities
βββ βοΈ frontend/ # Vite + React SPA
β βββ π Caddyfile # Caddy server config for frontend
β βββ π³ Dockerfile # Container definition for frontend service
β βββ π index.html # Main HTML entry point
β βββ π¦ package.json # Frontend dependencies
β βββ π e2e/ # End-to-end tests using Playwright
β βββ π public/ # Static assets
β βββ π» src/ # React source code
βββ ποΈ infra/ # Terraform code for AWS infrastructure
β βββ π main.tf # Infrastructure root module
β βββ π modules/ # Infrastructure modules
β βββ πͺ api/ # API infrastructure (ECS, ALB, etc.)
β βββ ποΈ database/ # Database infrastructure (Aurora, etc.)
β βββ π frontend/ # Frontend infrastructure (CloudFront, etc.)
βββ π migrations/ # Flyway migrations for database
β βββ π³ Dockerfile # Container for running migrations
β βββ π sql/ # SQL migration scripts
βββ ποΈ terragrunt/ # Terragrunt configuration for environments
β βββ π§ terragrunt.hcl # Root Terragrunt config
β βββ π§ͺ dev/ # Dev environment config
β βββ π prod/ # Prod environment config
β βββ π¬ test/ # Test environment config
βββ π§ͺ tests/ # Test suites beyond component-level
βββ π integration/ # Integration tests across services
βββ β‘ load/ # Load testing scripts
- ποΈ Terragrunt: Orchestrates infrastructure deployment across environments
- π Environment folders (
dev
,test
,prod
): Environment-specific configurations - ποΈ Terraform modules: Reusable infrastructure components
- πͺ API: ECS Fargate backend (ALB, API Gateway, autoscaling, IAM, Secrets Manager)
- π Frontend: CloudFront distribution and WAF
- ποΈ Database: Aurora Serverless v2 PostgreSQL with networking
- ποΈ Backend (
backend/
): NestJS TypeScript API with Prisma ORM - βοΈ Frontend (
frontend/
): React SPA built with Vite - π Migrations (
migrations/
): Flyway database schema management
- π§ͺ Unit Tests: Built into each application
- π E2E Tests: Playwright for UI validation
- β‘ Load Tests: Performance testing with k6
- π Integration Tests: Cross-service validation
-
Clone and navigate to the project:
git clone <repo-url> cd quickstart-aws-sql
-
Start everything with one command:
docker-compose up --build
-
Access your apps:
- π Frontend: http://localhost:3000
- πͺ Backend API: http://localhost:3001
-
Stop when done:
docker-compose down
Prerequisites:
- β JDK 17+
- π¦ Node.js 22+
- ποΈ PostgreSQL 17.4 with PostGIS
- π Flyway CLI
Steps:
-
Start PostgreSQL (as a service)
-
Run database migrations:
java -jar flyway.jar \ -url=jdbc:postgresql://$postgres_host:5432/$postgres_db \ -user=$POSTGRES_USER \ -password=$POSTGRES_PASSWORD \ -baselineOnMigrate=true \ -schemas=$FLYWAY_DEFAULT_SCHEMA \ migrate
-
Start the backend:
cd backend npm run start:dev # or npm run start:debug
-
Start the frontend:
cd frontend npm run dev
The easiest way to deploy! Our pre-configured workflows handle everything:
- β Building and testing changes on pull requests
- π Auto-deployment to AWS environments on merge
- π° Resource management (pause/resume for cost savings)
- π§ͺ Comprehensive testing (unit, integration, load tests)
- π Security scanning with Trivy
Quick Setup:
- π΄ Fork or clone this repository
- π Configure GitHub secrets (see below)
- π€ Push changes to trigger workflows
Required GitHub Secrets:
AWS_ROLE_TO_ASSUME # IAM role ARN with deployment permissions
SONAR_TOKEN_BACKEND # SonarCloud analysis for backend
SONAR_TOKEN_FRONTEND # SonarCloud analysis for frontend
AWS_LICENSE_PLATE # License plate from OCIO (without -dev/-test)
For direct control over your infrastructure:
- Configure AWS credentials locally
- Navigate and deploy:
cd terraform/api/dev terragrunt init terragrunt plan terragrunt apply
π Need help? Check out our detailed AWS deployment guide.
Our GitHub Actions provide a complete DevOps pipeline with smart automation!
When you open a PR:
- ποΈ Code builds with concurrency control (no conflicts!)
- π Infrastructure planning with Terraform/Terragrunt
- π§ͺ Comprehensive testing in isolated environments
- π Security scans with Trivy vulnerability detection
- π Code quality analysis with SonarCloud
- π Optional review environment (manual trigger)
When code merges to main:
- β‘ Auto-resume AWS resources across environments
- π Deploy to dev environment
- π·οΈ Tag containers with 'dev'
- π§ͺ Run E2E tests against dev
- β Deploy to test (on success)
- π·οΈ Tag containers with 'test'
- π€ Auto-pause resources to save costs
- π PR Workflows:
pr-open.yml
,pr-validate.yml
,pr-close.yml
- π Deployment:
merge.yml
,release.yml
- ποΈ Building:
.builds.yml
- π§ͺ Testing:
.tests.yml
,.e2e.yml
,.load-test.yml
- π Deployment:
.deploy_stack.yml
,.destroy_stack.yml
- βΈοΈ Pause Resources:
pause-resources.yml
(scheduled/manual/auto) βΆοΈ Resume Resources:resume-resources.yml
(before deployments)- π§Ή Cleanup:
prune-env.yml
π Want more details? Check out our complete GitHub Actions guide!
- π° Cost-Optimized: 20% FARGATE (reliable) + 80% FARGATE_SPOT (cheap!)
- π Smart Auto-Scaling:
- Scales UP aggressively (+2 instances when busy)
- Scales DOWN conservatively (-1 instance when idle)
- π Migration Tasks: Flyway runs before app deployment
- π Secure Secrets: Database credentials from AWS Secrets Manager
- π HTTP API Gateway with VPC Link integration
- π Routes all traffic to internal Application Load Balancer
- π‘οΈ Supports ANY method with proxy path integration
- π Auto-connects to Aurora PostgreSQL
- π Master credentials from Secrets Manager
- π Schema migrations via Flyway ECS tasks
- π Read/write splitting with separate endpoints
Ready to make this template your own? Here's your roadmap! πΊοΈ
- π΄ Clone this repository
- π Update project names in
package.json
files - π Set up required GitHub secrets
- π§ Terraform/Infrastructure: Modify
terraform
andinfrastructure
directories - βοΈ Environment Variables: Update environment-specific variables
- π ECS Task Definitions (
infrastructure/api/ecs.tf
):- πΎ Customize container resources (CPU/memory)
- π Modify auto-scaling thresholds (
infrastructure/api/autoscaling.tf
) - π° Update capacity provider strategy (cost vs. reliability)
- ποΈ Database: Configure connection parameters and schema
- πͺ API Gateway: Customize settings in
infrastructure/api/api-gateway.tf
- ποΈ Backend: Customize NestJS in the
backend/
directory - βοΈ Frontend: Adapt React app in the
frontend/
directory - π Database: Update schema and migrations in
migrations/sql/
- π§ Workflows: Modify GitHub workflows in
.github/workflows/
- π Deployment: Update configuration for your AWS account
- π° Resource Management: Configure pause/resume schedules
- β° Adjust cron schedules for your working hours
- π‘οΈ Set up environment-specific resource management
- π Customize protection rules for production
- π§ͺ Backend Tests: Adapt Vitest tests in
backend/src/
- βοΈ Frontend Tests: Update tests in
frontend/src/__tests__/
- π E2E Tests: Modify Playwright tests in
frontend/e2e/
- β‘ Load Tests: Customize k6 tests in
tests/load/
- π SonarCloud: Update project keys for code quality analysis
- π GitHub Workflows: Adjust test runners for your environments
We β€οΈ contributions! Want to help make this template even better?
π Check out our CONTRIBUTING.md for:
- π Contribution guidelines
- π Development workflow
- π§ͺ Testing requirements
- π Code standards