Skip to content

Aijazkhan123/node-terraform-devops-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌍 Node.js App Deployment on AWS with Terraform

Node.js Terraform AWS Docker GitHub Actions

A production-ready DevOps project that provisions AWS cloud infrastructure using Terraform (Infrastructure as Code) and deploys a containerized Node.js application through an automated GitHub Actions CI/CD pipeline. Everything from cloud resources to application deployment is fully automated — no manual AWS console clicks required.


🏗️ Architecture Diagram

Image

📁 Project Structure

node-terraform-devops-project/
├── .github/
│   └── workflows/
│       └── deploy.yml        # GitHub Actions CI/CD pipeline
├── terraform/
│   ├── main.tf               # Core AWS infrastructure resources
│   ├── variables.tf          # Input variables (region, instance type, etc.)
│   ├── outputs.tf            # Output values (public IP, URLs)
│   └── provider.tf           # AWS provider configuration
├── app.js                    # Node.js application entry point
├── package.json              # Node.js dependencies and scripts
└── Dockerfile                # Container image definition

🛠️ Tech Stack

Layer Technology Purpose
Application Node.js + JavaScript Backend API / web server
Containerization Docker Package the application
Infrastructure as Code Terraform Provision AWS resources
Cloud Provider AWS (EC2 / ECS / VPC) Host and run the application
CI/CD GitHub Actions Automate build → push → deploy
Image Registry AWS ECR / Docker Hub Store Docker images

⚡ Getting Started

Prerequisites

1. Clone the Repository

git clone https://github.com/Aijazkhan123/node-terraform-devops-project.git
cd node-terraform-devops-project

2. Configure AWS Credentials

aws configure
# Enter: AWS Access Key, Secret Key, Region (e.g. us-east-1)

3. Provision AWS Infrastructure with Terraform

cd terraform

terraform init        # Download provider plugins
terraform plan        # Preview what will be created
terraform apply       # Create AWS resources

4. Build & Run with Docker

docker build -t node-terraform-app .
docker run -p 3000:3000 node-terraform-app

Visit: http://localhost:3000

5. Destroy Infrastructure (when done)

cd terraform
terraform destroy

⚙️ CI/CD Pipeline

On every git push to main, the GitHub Actions workflow automatically:

  1. Checks out the source code
  2. Builds the Docker image
  3. Pushes the image to AWS ECR or Docker Hub
  4. Runs terraform apply to provision/update AWS infrastructure
  5. Deploys the latest container to EC2 / ECS

AWS credentials are stored securely as GitHub Secrets (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY).


🔐 GitHub Secrets Required

Secret Name Description
AWS_ACCESS_KEY_ID Your AWS IAM access key
AWS_SECRET_ACCESS_KEY Your AWS IAM secret key
AWS_REGION Target AWS region (e.g. us-east-1)
DOCKER_USERNAME Docker Hub username (if used)
DOCKER_PASSWORD Docker Hub password (if used)

🧠 What I Learned

  • Writing Terraform configurations to provision real AWS infrastructure from scratch
  • Deploying containerized applications to AWS EC2 / ECS using Docker
  • Building end-to-end automated CI/CD pipelines with GitHub Actions
  • Managing cloud credentials securely with GitHub Secrets
  • Understanding Infrastructure as Code (IaC) and its role in modern DevOps

🗺️ Planned Improvements

  • Add an Application Load Balancer (ALB) in front of EC2
  • Use Terraform remote state with AWS S3 + DynamoDB locking
  • Add Terraform workspaces for dev / staging / prod environments
  • Integrate AWS CloudWatch for monitoring and logging
  • Add auto-scaling group for high availability

📜 License

MIT License — free to fork, learn from, and build upon.


Node.js · Terraform · AWS · Docker · GitHub Actions · IaC · CI/CD · DevOps · EC2 · VPC

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors