A practical demonstration of how to integrate AWS Lambda with Amazon API Gateway to build a fully serverless REST API β scalable, cost-efficient, and easy to maintain.
This project shows how to:
- Create and deploy AWS Lambda functions.
- Integrate Lambda with API Gateway.
- Configure RESTful endpoints (GET, POST, PUT, DELETE).
- Test and validate API responses.
- Manage deployments through Git and GitHub.
- β Automate CI/CD with GitHub Actions for linting, testing, and Lambda deployment.
- β Define infrastructure with Terraform (IaC) for reproducible and consistent environments.
lambda-rest-api-integration/
βββ .github/
β βββ workflows/
β βββ ci.yml
β βββ deploy.yml
βββ terraform/
β βββ main.tf
β βββ variables.tf
β βββ outputs.tf
βββ src/
β βββ (Lambda source files)
βββ tests/
β βββ handler.test.js
βββ Dockerfile
βββ README.md
βββ ...
β
Serverless Architecture β No need to manage servers
β
API Gateway Integration β Seamless connection between client and Lambda
β
Scalable & Cost-Efficient β Pay only for execution time
β
Secure Endpoints β IAM roles and policies
β
Simple Deployment β Works with AWS Console or CLI
β
CI/CD Ready β Automated testing and deployment with GitHub Actions
β
Infrastructure as Code (IaC) β Terraform-based Lambda provisioning
β
Docker Support β Optional local testing or containerized Lambda builds
Make sure you have:
- An AWS account
- AWS CLI configured
- Terraform (for infrastructure provisioning)
- Node.js or Python (depending on your Lambda runtime)
- Postman or curl for API testing
git clone https://github.com/iftikhar69/lambda-rest-api-integration.git
cd lambda-rest-api-integration
Deploy Using Terraform
cd terraform
terraform init
terraform plan
terraform apply -auto-approveDeploy the Lambda Function (Manual Option)
You can deploy via AWS Console or using AWS CLI:
aws lambda create-function \
--function-name MyLambdaAPI \
--runtime nodejs18.x \
--role arn:aws:iam::<your-account-id>:role/<your-lambda-role> \
--handler index.handler \
--zip-file fileb://function.zipIntegrate with API Gateway
Open API Gateway in AWS Console.
Create a new REST API.
Add a resource (e.g., /users) and methods (GET, POST, etc.).
Link each method to your Lambda function.
Deploy the API to a stage (e.g., prod).
π Testing the API Use curl or Postman to test endpoints like:
curl -X GET https://<api-id>.execute-api.<region>.amazonaws.com/prod/users
Run unit tests locally:
npm test
π§ͺ CI/CD Pipeline
This project includes GitHub Actions workflows that:
Automatically install dependencies and run tests.
Deploy the Lambda function on merge to main.
File: .github/workflows/ci.yml
name: Lambda CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: npm ci
- run: npm test
π³ Docker Support You can run and test locally using Docker:
docker build -t lambda-api .
docker run -p 3000:3000 lambda-api
πΈ Screenshots
πΉ Lambda REST API Setup

π§© Tech Stack
| Component | Description |
|---|---|
| AWS Lambda | Core serverless compute service |
| API Gateway | Manages REST endpoints |
| IAM | Secure permission management |
| Terraform | Infrastructure as Code provisioning |
| Docker | Optional containerized testing |
| GitHub Actions | CI/CD automation |
| Node.js / Python | Runtime for Lambda |
| GitHub | Version control and collaboration |
iftikhar69
π‘ Passionate about cloud computing, serverless systems, and automation.
This project is licensed under the MIT License.
See the LICENSE file for more details.
