Serverless Application with AWS Lambda and API Gateway

Project Description

This project involves developing a serverless application using AWS Lambda for backend logic, API Gateway for creating a RESTful API, and DynamoDB for data storage. Terraform scripts are used to manage the serverless infrastructure, and CloudWatch is set up for monitoring and logging.

Technologies Used

  • Terraform

  • AWS Lambda

  • AWS API Gateway

  • AWS CloudWatch

  • AWS DynamoDB

Key Features

  • Serverless Architecture

  • User Authentication and Security

  • Real-Time Data Processing

  • Monitoring and Logging

Project Steps

Copy the Folder Locally and Install Dependencies

We start with the project locally, so you have to copy the folder to your computer. First, we install the dependencies for the Lambda function:

lambda_function
npm init -y
npm install @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodb

Zip the Lambda Function Code

We go back to the serverless-app directory and zip the lambda_function directory:

cd ..
zip -r lambda_function_payload.zip lambda_function/

Deploy the Infrastructure

Initialize and apply your Terraform configuration:

terraform init
terraform apply

Test the API

Click on the link displayed by the Outputs. The response you will get after you click on the link is [] and it means your API is working correctly. This is an empty array being returned because there are no items in your DynamoDB table. To verify everything is working, you have to add a test item to your DynamoDB table.

Results

The API is successfully:

  • Connecting to DynamoDB

  • Running the scan operation

  • Returning the results

  • Handling CORS correctly

#AWS #Serverless #Lambda #APIGateway #Terraform #DynamoDB #CloudWatch #Infrastructure #IaC

0
Subscribe to my newsletter

Read articles from Georgiana Gorgan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Georgiana Gorgan
Georgiana Gorgan

Originally from Romania 🏑, I have decided to come to Germany in 2022. After a period of travelling, making friends and learning the language, I made the decision to stay here. Currently I am following my passion for IT and I am continuously specialising in Cloud Engineering and Artificial Intelligence.πŸ‘©πŸ»β€πŸ’» I completed a year-long training course here in Germany, where I learned about AWS, Doker, DevOps, Terraform, 🐧Linux, Python and other cloud services and tools. During this time, I also worked as a tutor for my colleagues, explaining cloud concepts and building cloud solutions together.