Skip to content

Latest commit

 

History

History
86 lines (58 loc) · 2.64 KB

File metadata and controls

86 lines (58 loc) · 2.64 KB

Description

DevOps-focused sample project that combines a simple Nest REST API with:

  • Containerization using Docker
  • Infrastructure as Code using Terraform
  • Deployment to AWS ECS Fargate
  • CI/CD automation via GitHub Actions (build → push → deploy)

Use this repository to demonstrate end-to-end DevOps skills: from application code to cloud infrastructure and automated delivery.

Installation

$ pnpm install

Running the app

# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod

Infrastructure (Terraform + AWS ECS)

This project includes an IaC setup under terraform/ that provisions the runtime environment on AWS:

  • aws_ecr_repository to store the Docker image for the NestJS app.
  • aws_ecs_cluster, Fargate task definition, and service to run the container.
  • Security group exposing port 3000 over TCP.
  • Usage of the default VPC and subnets discovered via data sources.

Basic local Terraform workflow:

cd terraform
terraform init
terraform plan -var="image_url=<your-ecr-repo-url>:tag"
terraform apply -auto-approve -var="image_url=<your-ecr-repo-url>:tag"

The image_url variable is the ECR image URI (including tag) that the ECS task definition will run.

CI/CD (GitHub Actions → ECS)

Automated deployment is handled by a GitHub Actions workflow in .github/workflows/deploy.yml:

  • Triggers on pushes to the main branch or via manual workflow_dispatch.
  • Configures AWS credentials using repository secrets (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION).
  • Runs Terraform (terraform init and terraform apply) in the terraform/ directory.
  • Logs in to Amazon ECR.
  • Builds the Docker image from this repository, tags it as nestjs-app:latest, and pushes it to ECR.
  • Terraform applies the updated image_url, which updates the ECS service to the new container image.

DevOps workflow overview

  1. Developer pushes to main.
  2. GitHub Actions pipeline runs: Terraform apply → Docker build → push to ECR.
  3. ECS service is updated to run the new container image on Fargate.

This demonstrates a full DevOps flow: application code (NestJS), containerization (Docker), infrastructure as code (Terraform), and automated delivery to AWS ECS (GitHub Actions).

Test

# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.