Skip to content

This project is a simple AWS serverless microservice that enables users to create and manage movies data. The entire backend is based on API Gateway, Lambda and DynamoDB.

Notifications You must be signed in to change notification settings

Tiamatt/AwsServerlessMicroserviceWithLambda

Repository files navigation

AWS Serverless Microservice With Lambda Application

This project is a simple serverless microservice on AWS that enables users to create and manage movies data. The entire backend is based on API Gateway, Lambda and DynamoDB. To manage, document and visualize all APIs in one place, SwaggerHub is used.

SwaggerHub UI

Overview

The goal of this project is to show how to create an application composed of small, easily deployable, loosely coupled, independently scalable, serverless components.

As I’m strongly against managing environments manually and take Infrastructure as Code 💙 for granted, AWS SAM will be a great fit for this serverless project. As a result, the entire application should be deployed in any AWS account with a single CloudFormation template.

Architecture

1️⃣ A user sends a request to the server by calling APIs from SwaggerHub UI. The request which includes all necessary information is sent to Amazon API Gateway restful service.

2️⃣ API Gateway transfers the collected user information to a Lambda function.

3️⃣ AWS Lambda function executes event-based logic calling DynamoDB database.

4️⃣ DynamoDB provides a persistence layer where data can be stored/retrieved by the API's Lambda function.

The high-level architecture for the serverless microservice is illustrated in the diagram below:

Architecture

Initial Setup

To codify, build, package, deploy, and manage our AWS resources in a fully automated fashion, use the following:

👉 AWS SAM

👉 AWS Cloud​Formation

👉 AWS CLI

👉 AWS SDK for Python (boto3)

👉 Docker

If you don't want to install or maintain a local IDE, use AWS Cloud9 instead (you can find how to set up AWS Cloud9 here). Otherwise you might need to install the latest AWS CLI, AWS SAM and Python on your development machine.

AWS Resources

Here is the list of AWS resources that the project template creates:

✔️ AWS Lambda

✔️ Amazon DynamoDB

✔️ Amazon API Gateway

✔️ AWS IAM

✔️ Amazon S3 (that is where your CloudFormation template will be stored)

Lambda functions are written on Python 3.8.

Demo

SwaggerHub

🎉 Create a new movie:

CreateMovie

CreateMovie

🎉 Get a list of all movies:

GetMovies

GetMovies

🎉 Get a movie by uuid:

GetMovie

GetMovie

🎉 Delete a movie by uuid:

DeleteMovie

DeleteMovie

🎉 Update an existing movie:

UpdateMovie

UpdateMovie

UpdateMovie

A detailed explanation

You can find all the details of the project by reading my articles on dev.to:

👉 AWS project - Building a serverless microservice with Lambda (read)

👉 Serverless - Create, debug and deploy Lambda and API Gateway via AWS SAM and AWS Cloud9 (read)

Download the project

To clone the GitHub repository, execute the following command:

cd my-folder
git clone https://github.com/Tiamatt/AwsServerlessMicroserviceWithLambda.git

If you want to migrating a repository from GitHub into AWS CodeCommit, read this article.

Build and Deploy

To build and deploy your application for the first time, run the following in your shell:

sam build --use-container
sam deploy --guided

Cleanup

To delete the sample application that you created, use the AWS CLI:

aws cloudformation delete-stack --stack-name aws-serverless-microservice-app-stack

Happy dance

Finally, don't forget to do your happy dance!

UpdateMovie

About

This project is a simple AWS serverless microservice that enables users to create and manage movies data. The entire backend is based on API Gateway, Lambda and DynamoDB.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages