Skip to content

Latest commit

 

History

History
84 lines (57 loc) · 2.83 KB

README.md

File metadata and controls

84 lines (57 loc) · 2.83 KB

AWS Lambda with Redis, Terraform, Node.js, and TypeScript

Jest Workflow

AWS Lambda Redis Terraform Node.js TypeScript Jest

This repository contains an AWS Lambda example demonstrating rate limiting implemented with Redis, Node.js, and TypeScript.

The application enforces a Time Limit based on the companyId provided in the request. It offers two distinct plan types: a free plan and a paid plan, each with its own monthly usage quotas.

Development

Prerequisites

Before you begin, ensure that you have the following prerequisites installed:

Getting Started

  1. Install project dependencies:
  yarn install
  1. Start a local Redis instance (requires Docker):
  yarn start-local-redis
  1. Run the development server:
  yarn dev

Deploy AWS Lambda from your Local Machine

To deploy the Lambda function from your local machine, follow these steps:

  • rename env to .env and add your redis database url
  • Install the AWS CLI and Terraform CLI on your local machine.
  • Create an AWS account and generate AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  • Configure your AWS credentials with aws configure
  • Initialize Terraform:
  Terraform init
  • Build and deploy the Lambda function:
  sh build.sh

Continuous Delivery (CD)

Automate the deployment of your Lambda function using GitHub Actions. The deployment workflow is defined in the .github/workflows/main.yaml file.

Setup

To set up Continuous Delivery (CD) using GitHub Actions:

  • Install the AWS CLI and Terraform CLI on your local machine.
  • Create an AWS account and generate AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  • Configure your AWS credentials with aws configure
  • Create an S3 bucket to store Terraform state using the provided script, createBucket.sh.
  • Add the following secrets to your GitHub Actions repository:
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
    • REDIS_DB_PATH
  • The main.yaml workflow will automatically trigger with every new push to the main branch.