AWS Lambda is a serverless compute solution that allows you to run code without the need for server provisioning or management. You only pay for the compute time you use. This indicates that my own project, which will not receive a lot of traffic, is a great choice for AWS Lambda. This use case is ideal for applications with variable traffic or that can scale to zero.
IAM Role/IAM User with the enough permissions.
AWS CLI installed
3. AWS Resources
You'll need the AWS resources listed below.
AWS IAM Role
AWS API Gateway
You can create the resources manually using the AWS Console, or you can leverage this using any IAC options like Terraform, AWS SAM/CloudFormation. In this Article you will use the AWS Console to things easier
5. Deployment Steps
Step -1 - Create a role (name it as you wish and add permissions)
Step -2 - Create a lambda function (name it as you wish, chose the latest python version as runtime)
Python codes can be found here:
Step -3 - Build the REST API
Create 3 resources
health with path /health
product path /product
products path /products
Create Methods for each resources
On health resource, create "GET" method
On product resource, create "GET", "POST", "PATCH" and
On products resource, create "GET"
check all boxes as followed for all Methods on each resource and chose your created lambda (Step -2)
Step -5 Deploy the API
Step -6 Create DynamoDB Table
6. TEST ALL APIs
POST: For a single product
GET: For a single product
PATCH: For a single product
DELETE: For a single product
GET multiple products:
Notes: You will need POST few products before trying to GET all of them.
END - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like my work and want to support me…
The BEST way is following me on dev.to here
Feel free to give likes, or writing comments so I know how helpful this post was for you.
Connect with me on LinkdIn