Skip to content

This project demonstrates how to build a serverless application for managing a fleet of vehicles using AWS Lambda and DynamoDB. The application leverages serverless architecture principles, meaning there is no need to manage or provision any servers.

Notifications You must be signed in to change notification settings

DanielAzeez/Serverless-Vehicle-Inventory-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Vehicle Inventory Management System

This is a serverless vehicle inventory management system built using AWS Lambda and Amazon DynamoDB. It allows you to manage vehicle inventory with the ability to create, update, and query vehicle data. The system is built entirely using Python (Boto3) and integrates with AWS services such as DynamoDB and optionally API Gateway.

🌟 Features

  • Create a Vehicle: Add a new vehicle to the inventory.
  • Update a Vehicle: Modify vehicle attributes such as reserve status.
  • Query a Vehicle: Retrieve vehicle details using its id.

🛠 Technologies Used

  • AWS Lambda: Used for running the serverless vehicle management code.
  • Amazon DynamoDB: NoSQL database to store vehicle inventory.
  • Python (Boto3): AWS SDK for Python to interact with DynamoDB.
  • API Gateway: (Optional) To expose Lambda as an HTTP endpoint.

📖 Setup and Installation

Prerequisites

  • AWS Account: You need an active AWS account.
  • DynamoDB Table: Create a DynamoDB table named locations with the following configuration:
    • Table Name: locations
    • Primary Key: id (String)

Step-by-Step Guide

  1. Clone this repository:

    git clone https://github.com/your-username/Serverless-Vehicle-Inventory-Management-System.git
    cd Serverless-Vehicle-Inventory-Management-System
  2. Upload Lambda function:

    • Go to the AWS Lambda console and create a new function.
    • Upload the lambda_function.py file located in the lambda/ folder.
  3. Configure Lambda to access DynamoDB:

    • Attach the necessary IAM role to allow the Lambda function to interact with DynamoDB.
    • Example policy:
    {
      "Effect": "Allow",
      "Action": [
        "dynamodb:GetItem",
        "dynamodb:PutItem",
        "dynamodb:UpdateItem"
      ],
      "Resource": "arn:aws:dynamodb:region:account-id:table/locations"
    }
  4. DynamoDB Table Setup:

    • Create a DynamoDB table called locations with the primary key as id (String).
    • Ensure that the table is configured to handle read and write capacity as per your application needs.
  5. (Optional) Set Up API Gateway:

    • If you want to trigger the Lambda function via HTTP requests, create a new API Gateway and integrate it with the Lambda function.
    • Use a POST method to send vehicle data in the request body.

📋 Usage

Example Request

Payload: This is an example JSON payload to add a vehicle to the inventory.

{
  "vehicle": {
    "id": "1",
    "available": "true",
    "type": "scooter"
  }
}

Response: The Lambda function will respond with the vehicle details, including its reserve status.

{
  "id": "1",
  "available": "true",
  "type": "scooter",
  "reserve": "yes"
}

🚀 Testing the Lambda Locally

If you want to test the function locally before deploying it to AWS, you can use sample event data in the following format:

event = {
    "vehicle": {
        "id": "1",
        "available": "true",
        "type": "scooter"
    }
}

Then call the lambda_handler() function in your Python environment:

result = lambda_handler(event, None)
print(result)

About

This project demonstrates how to build a serverless application for managing a fleet of vehicles using AWS Lambda and DynamoDB. The application leverages serverless architecture principles, meaning there is no need to manage or provision any servers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages