Giter VIP home page Giter VIP logo

terraform-sls-crud-api's Introduction

Serverless CRUD REST API with AWS Lambda, API Gateway, and DynamoDB

This project demonstrates the implementation of a serverless CRUD (Create, Read, Update, Delete) REST API using AWS Lambda, API Gateway, and DynamoDB. The infrastructure is provisioned and managed with Terraform, and the Lambda functions are written in Node.js 18.

Table of Contents

Prerequisites

Before you begin, ensure you have the following tools and accounts set up:

Project Structure

The project is organized into the following directories:

  • modules/: Contains Terraform modules for infrastructure provisioning.

    • dynamodb/: Terraform module for DynamoDB.
    • api_gateway/: Terraform module for API Gateway.
    • lambda/: Terraform module for Lambda functions.
  • infra/: Contains the main Terraform configuration files.

    • main.tf: The main Terraform configuration file.
    • variables.tf: Variable definitions.
    • outputs.tf: Output definitions.
  • src/: Contains the source code for Lambda functions.

    • functions/: Organized by CRUD operations (create, read, update, delete).
  • tests/: Contains unit tests for Lambda functions.

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd my-serverless-api
  2. Install Node.js dependencies:

    cd src/functions/create
    npm install
    
    cd ../read
    npm install
    
    # Repeat for update and delete directories
  3. Install Terraform dependencies:

    cd modules/dynamodb
    terraform init
    
    cd ../api_gateway
    terraform init
    
    cd ../lambda_functions
    terraform init

Usage

  1. Update the variables.tf files in the modules/api_gateway, modules/lambda, and modules/dynamodb directories with your specific configuration.

  2. Deploy the infrastructure using Terraform:

    cd infra
    terraform apply
  3. Update the Lambda function code in the src/functions/ directory as needed.

  4. Redeploy the Lambda functions:

    cd infra/lambda_functions
    terraform apply

Testing

Run unit tests for Lambda functions:

cd tests
npm install
npm test

terraform-sls-crud-api's People

Contributors

fonnkwenti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.