Access AWS DynamoDB from Serverless Web Application
The serverless web application is a good example to utilize AWS S3, AWS API gateway, AWS Lambda, and AWS DynamoDB. In my online training course Hands-on AWS DynamoDB, I demonstrated a simple product utility serverless web application to access DynamoDB for searching the product and inserting the new product. The serverless web application is very simple and is good enough to demo DynamoDB access. You can extend this web application by adding more CRUD(Create, Read, Update and Delete) functionalities and access to different DynamoDB tables.
Serverless Web Application Working Flow
Here is a high-level working flow on our serverless web app product utility example:
- The users go to the static website hosted on AWS S3bucket.
- AWS S3 points to AWS API gateway.
- AWS API Gateway has two web methods requests: Get request and Post request:
- Get request calls lambda function to retrieve the item from DynamoDB table.
- Post request calls another lambda function to put the item into AWS DynamoDB table.
- DynamoDB has the table with the data.
AWS DynamoDB is a fully managed cloud NoSQL database. DynamoDB supports both document and key-value store models. The products information is saved in DynamoDB table.
AWS Lambda provides a serverless compute that lets you run code without provisioning or managing servers. So use Lambda functions to access DynamoDB for executing data operations such as retrieving data, modifying data, and writing data.
AWS API Gateway
AWS API Gateway is a fully managed API service to create, publish, maintain, monitor, and secure APIs at any scale. API Gateway integrates with Lambda functions.
Static Website on AWS S3
You can attend this simple serverless web application:
- Use your own domain along with Route 53 instead of accessing the website by using S3 website endpoint.
- Add the extra layer of authentication and authorization. For example, use AWS Cognito users pool management. Or use a web identity federation with identity providers to set up access control. More on AWS Cloud Security.
- Add SNS notification for certain operations.
If you want to know more detail on this project, please enroll in my online training course: Hands-on AWS DynamoDB.