This application is built using Node.js and provides RESTful API endpoints, including a /healthz endpoint for health checks and /v1/file endpoints for file uploads, retrieval, and deletion. It integrates with AWS CloudWatch for logging and monitoring and uses AWS S3 for file storage and RDS PostgreSQL for metadata storage.
npm installnode index.jsThe server runs on port 8080.
curl -vvv http://localhost:8080/healthzcurl -X POST -F "profilePic=@path/to/file.jpg" http://localhost:8080/v1/filecurl -X GET http://localhost:8080/v1/file/{file_id}curl -X DELETE http://localhost:8080/v1/file/{file_id}GET: Health check. Returns200 OKif the service is running.- Other methods: Returns
405 Method Not Allowed.
POST: Upload a file.GET&DELETE: Returns400 Bad Request.- Other methods: Returns
405 Method Not Allowed.
GET: Retrieves file metadata.DELETE: Deletes file and metadata.- Other methods: Returns
405 Method Not Allowed.
npm testThis project uses GitHub Actions for CI/CD. The pipeline is triggered on a pull request merge and follows these steps:
- Run unit tests.
- Validate Packer templates.
- Build application artifact(s).
- Build AMI in DEV AWS Account.
- Upgrade OS packages.
- Install system dependencies (Node.js, Python, etc.).
- Install application dependencies (
npm install). - Copy built application and configuration to the target machine.
- Configure the application to auto-start on VM launch.
- Share AMI with the DEMO AWS Account.
- Switch AWS CLI context to use DEMO account credentials.
- Create a new Launch Template version using the latest AMI.
- Update Auto Scaling Group to use the new Launch Template version.
- Trigger an Instance Refresh on the Auto Scaling Group.
- Wait until the instance refresh completes successfully.
- Exit the workflow with the refresh status.
💡 Rollback for failed deployments is not handled.
- API_Call_Count: API call frequency.
- API_Response_Time: Response time per endpoint (ms).
- DB_Query_Time: Query performance in milliseconds.
- S3_Call_Time: Time taken for each S3 call.
- All logs are sent to AWS CloudWatch Logs.
- Logs include levels:
INFO,WARN,ERROR. - Stack traces and meaningful messages are provided.
INFO: Health check passed
INFO: File uploaded successfully: uploads/pic.jpg
INFO: DB query execution time: 35ms
INFO: S3 call completed in 27ms- This app is deployed to EC2 instances behind an Application Load Balancer (ALB).
- ALB supports both HTTP and HTTPS.
- SSL certificate is imported manually (e.g., via Namecheap) and attached to the ALB.
- DNS routing is handled via Route 53.