Deploy web application with Lambda, API Gateway and DynamoDB | AWS Serverless Services
In this post, I am going to build a serverless REST API using API Gateway, AWS Lambda, and DynamoDB.
What is Amazon API Gateway?
Amazon API Gateway is an AWS services for creating, publishing, maintaining, monitoring, and securing REST, HTTP, and WebSocket APIs at any scale. API developers can create APIs that access AWS or other web services, as well as data stored in the aws cloud.
What is the difference between GET and POST in REST API?
GET is for fetching data, appending parameters in the URL, ideal for searches. POST, used for updates, sends data securely in the request body, perfect for forms.
Steps
Creating IAM Role for lambda
Create a Lambda Function
Creating an Amazon DynamoDB table
Creating an AWS API gateway in REST API
Integrating API endpoints with Amazon API Gateway
Testing
Creating IAM Role for lambda
Sign in to the AWS Management Console and open IAM.
Click on "Create role"
Add "AmazonDynamoDBFullAccess"
Create a Lambda Function
Click on "Create function" to create a new Lambda function.
Provide a name for your function and select the desired programming language, such as Python.
Leave the advanced settings as default and click "Create function" to create the Lambda function.
Add your role which you created earlier
Build Your Website
From my Github : https://github.com/gutkarsh08/aws-projects-Lambda-API-Gateway-and-DynamoDB
Download a zip file.
Click on "Upload from"
Now, code uploaded in your Lambda function code
Creating an Amazon DynamoDB table
Provide a name for your table and Partition key "email"
Creating an AWS API gateway in REST API
Now, need to create a method [GET and POST]
FOR GET
FOR POST
After creating your API, you must deploy it to make it callable by your users
To deploy an API, you create an API deployment and associate it with a stage. A stage is a logical reference to a lifecycle state of your API (for example, dev
, prod
, beta
, v2
).
API stages are identified by the API ID and stage name. They're included in the URL that you use to invoke the API. Each stage is a named reference to a deployment of the API and is made available for client applications to call.
Choose the copy icon to copy your API's resource-level invoke URL. Pasted in browser:
Now, you going to fill your information. Then, Click "submit"
Whenever we submitting your information the data it's storing in the backend Dynamodb table.