Skip to content

About

Production-ready AWS library discovery platform with Terraform, Docker, CI/CD, Lambda, API Gateway v2, RDS and CloudWatch

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

26 Commits

Folders and files

Repository files navigation

LibraryFinder AWS

A production-grade serverless library search application built on AWS β€” demonstrating end-to-end Infrastructure as Code, secure CI/CD, and production observability.

AWS Terraform CI/CD License


🎯 Overview

LibraryFinder is a cloud-native portfolio project that helps users discover public libraries. It's deliberately scoped to demonstrate production-ready AWS patterns across the full stack β€” not to ship a feature-complete product.

What this project demonstrates:

  • Infrastructure as Code β€” every AWS resource defined in Terraform, deployable from a single terraform apply
  • Serverless architecture β€” Lambda + API Gateway v2 (HTTP API) + RDS PostgreSQL
  • Secure CI/CD β€” GitHub Actions with OIDC federation, zero stored AWS credentials
  • Production observability β€” 5 CloudWatch alarms on key SLIs, SNS email delivery, verified end-to-end
  • Cost discipline β€” AWS Budget guardrails, RDS stopped when idle

πŸ—οΈ Architecture

Architecture

Request path: User β†’ S3 (static frontend) β†’ API Gateway v2 β†’ Lambda β†’ RDS PostgreSQL Alert path: CloudWatch alarm breach β†’ SNS topic β†’ Email notification Deploy path: git push β†’ GitHub Actions (OIDC auth) β†’ terraform apply


πŸš€ Technology Stack

Cloud Infrastructure

  • Compute: AWS Lambda (Node.js)
  • API: API Gateway v2 (HTTP API)
  • Data: RDS PostgreSQL
  • Frontend hosting: S3 static website
  • Networking: VPC, subnets, security groups
  • IAM: least-privilege roles per service

DevOps & Observability

  • IaC: Terraform
  • CI/CD: GitHub Actions with OIDC federation
  • Monitoring: CloudWatch alarms + dashboards
  • Alerting: SNS β†’ email
  • Cost: AWS Budgets

Application

  • Backend: Node.js Lambda handler
  • Frontend: Static HTML + JavaScript
  • Database: PostgreSQL with seeded library dataset

πŸ“‚ Project Structure

library-finder-aws/
β”œβ”€β”€ frontend/                         # Static site (S3)
β”œβ”€β”€ backend/
β”‚   └── lambda/
β”‚       β”œβ”€β”€ search-api/               # Main API handler
β”‚       └── db-setup/                 # DB bootstrap
β”œβ”€β”€ terraform/
β”‚   └── phase1-serverless/
β”‚       β”œβ”€β”€ provider.tf
β”‚       β”œβ”€β”€ vpc.tf                    # VPC + subnets
β”‚       β”œβ”€β”€ security-groups.tf
β”‚       β”œβ”€β”€ rds.tf                    # PostgreSQL
β”‚       β”œβ”€β”€ s3.tf                     # Frontend bucket
β”‚       β”œβ”€β”€ lambda-search-api.tf      # Search Lambda
β”‚       β”œβ”€β”€ lambda.tf                 # DB setup Lambda
β”‚       β”œβ”€β”€ github-oidc.tf            # CI/CD IAM role
β”‚       β”œβ”€β”€ monitoring.tf             # CloudWatch + SNS
β”‚       β”œβ”€β”€ budget.tf                 # AWS Budget
β”‚       β”œβ”€β”€ variables.tf
β”‚       └── outputs.tf
β”œβ”€β”€ .github/workflows/                # CI/CD pipelines
β”œβ”€β”€ docs/
β”‚   └── architecture.svg              # Architecture diagram
└── README.md

πŸ› οΈ Quick Start

Prerequisites

  • AWS account with appropriate IAM permissions
  • Terraform β‰₯ 1.5
  • AWS CLI v2 configured
  • Node.js β‰₯ 18 (for local development)

Deployment

# Clone the repository
git clone https://github.com/mittal-jn/library-finder-aws.git
cd library-finder-aws/terraform/phase1-serverless

# Set required variables in terraform.tfvars (gitignored)
# See terraform.tfvars.example for the full list

# Deploy
terraform init
terraform plan
terraform apply

After deployment, confirm the SNS email subscription from your inbox β€” alarms won't deliver until confirmed.

Local Development

# Test the Lambda handler locally
cd backend/lambda/search-api
npm install
npm test

πŸ“Š Monitoring & Observability

Five CloudWatch alarms cover the critical SLIs for a serverless API:

Alarm Metric Threshold
lambda-errors Lambda Errors (sum) > 0 per 5 min
lambda-duration-high Lambda Duration (avg) > 80% of timeout
lambda-throttles Lambda Throttles (sum) > 0 per 5 min
api-5xx-rate API Gateway 5xx / Count > 1% over 10 min
api-latency-p95 API Gateway Latency (p95) > 2000 ms over 10 min

All alarms publish to a single SNS topic with email subscription. Pipeline verified end-to-end via direct aws sns publish test.


πŸ”’ Security

  • OIDC federation β€” GitHub Actions assumes AWS IAM roles via short-lived tokens; no long-lived credentials stored as secrets
  • Least-privilege IAM β€” separate roles per Lambda, permissions scoped to required actions only
  • Private networking β€” RDS in private subnet, not publicly accessible
  • Credential hygiene β€” terraform.tfvars and state files gitignored; secrets passed via TF_VAR_* env vars
  • Encryption β€” RDS and S3 encrypted at rest

πŸ’° Cost

Real monthly cost tracks close to $0 when the environment is idle.

Service Active Cost Idle Cost
RDS (db.t3.micro) ~$12–15/mo $0 (stopped)
Lambda < $0.01 $0
API Gateway v2 < $0.01 $0
S3 static hosting < $0.50 < $0.50
CloudWatch alarms ~$0.50/mo ~$0.50/mo
SNS (email) $0 $0

Cost controls in place:

  • AWS Budget at $15/month with email alerts at 80% actual and 100% forecasted
  • RDS stopped when not in active development (dominant cost lever)
  • Free-tier coverage for Lambda, S3, and CloudWatch basic tier

πŸš€ Phase History

Phase Status Scope
2A β€” Core infrastructure βœ… Complete VPC, subnets, security groups, RDS, S3, IAM
2B β€” Search API βœ… Complete Lambda handler + API Gateway v2 (HTTP API), CORS
3 β€” CI/CD pipeline βœ… Complete GitHub Actions + OIDC federation
4 β€” Monitoring βœ… Complete 5 CloudWatch alarms + SNS + AWS Budget

πŸ—ΊοΈ Roadmap (candidate next phases)

  • CloudWatch Dashboard β€” consolidated view of Lambda + API Gateway metrics
  • X-Ray distributed tracing β€” enable on Lambda and API Gateway for request-level observability
  • Aurora Serverless v2 migration β€” eliminate the RDS stop/start pattern, scale to zero
  • API Gateway caching β€” reduce Lambda invocations for repeat queries
  • WAF integration β€” rate limiting and common attack protection

πŸ’‘ Lessons Learned

  • API Gateway v1 vs v2 metric dimensions differ (ApiName vs ApiId, 5XXError vs 5xx). Getting this wrong causes alarms to silently never fire β€” Terraform will accept the config but metrics return no data.
  • Migrating from Lambda Function URLs to API Gateway solved CORS issues cleanly. Taught me to reason about the request boundary separately from the compute layer.
  • OIDC federation is one-time setup complexity for permanent security payoff β€” worth the extra hour on first config.
  • Alarm ok_actions are a free built-in test of the notification path β€” no need to simulate failures to verify the alert pipeline works.

🎬 Demo

Full-stack application deployed and tested end-to-end:

  • Frontend hosted on S3 (static HTML/JS)
  • API served by Lambda behind API Gateway v2
  • Data stored in PostgreSQL on RDS
  • Environment spun down between demos for cost control β€” available on request

Application UI

Search by city returns real library data from RDS PostgreSQL via Lambda and API Gateway:

Search results showing TX libraries

Monitoring in action

5 CloudWatch alarms monitoring the serverless stack β€” all healthy:

CloudWatch alarms showing OK state


πŸ“„ License

MIT β€” see LICENSE.


πŸ‘€ Author

Mittal Jain


πŸ™ Acknowledgments

  • AWS Documentation and Well-Architected Framework
  • HashiCorp Learn (Terraform tutorials)
  • Terraform AWS Provider registry

⭐ Star this repo if you found it useful β€” feedback and suggestions welcome via GitHub Issues or LinkedIn.

About

Production-ready AWS library discovery platform with Terraform, Docker, CI/CD, Lambda, API Gateway v2, RDS and CloudWatch

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages