Hands-on guide: one Node.js api deployed via AWS Console, SAM, and Terraform
| Tech | Description |
|---|---|
| Node.js | JavaScript runtime |
| Express | Web framework for building REST APIs |
| Nginx | Reverse proxy (load balancing, caching, SSL available) |
| Docker | Containerization platform |
| AWS ECR | Elastic Container Registry - stores Docker images |
| AWS ECS | Elastic Container Service - runs containers |
| AWS Fargate | Serverless compute engine for ECS |
| AWS Secrets Manager | Stores and manages secrets like API keys |
| AWS IAM | Manages access roles and permissions |
| AWS VPC | Virtual Private Cloud - isolated network for resources |
| AWS CLI | Command-line tool for managing AWS services |
| GitHub Actions | CI/CD β automates deploy/cleanup for each deployment pattern |
| Method | Description | Tool Type |
|---|---|---|
| AWS Console | Manual deployment via the AWS Management Console β click-through UI setup | Manual |
| AWS SAM | Infrastructure-as-code using AWS SAM and CloudFormation | IaC (AWS-native) |
| Terraform | Infrastructure-as-code using Terraform β multi-cloud, state-managed | IaC (Cloud-agnostic) |
[ Docker Build ] βββΆ [ ECR Repo ] βββΆ [ Task Definition ]
β
βββββββββββββββββββββββββββββββββββββ
βΌ
βββ VPC (10.0.0.0/16) βββββββββββββββββββββββββββββββββββββ
β β
β βββ ECS Fargate Cluster βββββββββββββββββββββββββββββββ β
β β β β
β β [ Task: Nginx :80 β Node.js :5000 ] β β
β β β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β Public Subnets βββΆ Security Group βββΆ ENI β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
deploy-patterns/
βββ README.md # This file (overview)
βββ .github/workflows/ # GitHub Actions CI/CD pipelines (one per pattern)
β βββ dev-aws-sam.yml # Deploy/cleanup for the SAM app
β βββ dev-aws-sam-rollback.yml # Manual rollback for the SAM app
βββ 01-deploy-using-aws-console/ # Manual deployment via AWS Console
β βββ README.md # Step-by-step console guide
β βββ src/ # App source code
β βββ Dockerfile
β βββ ...
βββ 02-deploy-using-aws-sam/ # AWS SAM (IaC) deployment
β βββ README.md # SAM deployment guide
β βββ src/ # App source code
β βββ template.yaml # SAM/CloudFormation template
β βββ samconfig.toml # SAM CLI config
β βββ Dockerfile
β βββ ...
βββ 03-deploy-using-terraform/ # Terraform (IaC) deployment
βββ README.md # Coming soon
βββ src/ # App source code
βββ Dockerfile
βββ ...
| Method | Description | Best For |
|---|---|---|
| AWSΒ Console | Manual deployment via AWS Management Console UI | Learning, one-off deployments |
| AWSΒ SAM | IaC using AWS SAM and CloudFormation | Automated, repeatable deployments |
| Terraform | IaC using Terraform β multi-cloud, state-managed (In Progress) | Advanced IaC, multi-cloud |
This repo uses GitHub Actions to automate deployment and cleanup for each deployment pattern. Workflows live in .github/workflows/ β one file per pattern:
| Workflow file | Pattern | Status |
|---|---|---|
dev-aws-sam.yml |
AWS SAM (folder 02-deploy-using-aws-sam/) |
β Implemented |
dev-aws-sam-rollback.yml |
AWS SAM β manual rollback to a pinned image tag | β Implemented |
| (planned) | AWS Console (folder 01-deploy-using-aws-console/) |
Planned |
| (planned) | Terraform (folder 03-deploy-using-terraform/) |
Planned |
Every workflow follows the same conventions:
- Triggers β pushes to a pattern-specific branch (e.g.
release/dev-aws-sam) with a path filter, plus a manual Run workflow button. - Mode β a
modeinput (deploy|cleanup). Cleanup can also be triggered by pushing a commit whose message contains--cleanup. - Rollback β deploys pin the image tag (git SHA); if the new deployment fails, the deploy script automatically reverts to the previous tag. A separate manual rollback workflow redeploys any pinned tag on demand.
- Notifications β every run emails started + SUCCESS/FAILED results with a link to the run.
- Secrets β scoped to a per-pattern GitHub Environment (e.g.
release-dev-aws-sam) holding AWS credentials and notification SMTP settings.
The AWS SAM workflow is the reference implementation β the other patterns will mirror its structure.
- Node.js 22+
- Docker
- AWS CLI configured
- Additional tools depending on deployment method (see each folder's README)
# Navigate to any deployment folder (they all contain the same app)
cd 01-deploy-using-aws-console
# Install dependencies
npm install
# Run in development mode
npm run devGET /weather?q=manila
- Go to https://openweathermap.org/api
- Click Sign Up and create a free account
- Verify your email address
- Go to API Keys tab in your account dashboard
- Copy your default API key (or click Generate to create a new one)
- The free tier includes:
- Current weather data
- 1,000 API calls/day
- No credit card required
Note: API keys take ~10 minutes to activate after creation.
# Navigate to any deployment folder
cd 01-deploy-using-aws-console
# Create nginx.conf from template
cp nginx.conf.example nginx.conf
# Build and run
docker build -t node-app .
docker run -p 80:80 -e API_ENDPOINT=https://api.openweathermap.org -e API_KEY=<API_KEY> node-appMichael B. Antoni
- Email: michaelantoni.tech@gmail.com
- Website: https://michaelantoni.vercel.app
- LinkedIn: https://linkedin.com/in/m-antoni