Skip to main content


Showing posts from October 16, 2022

Let's build a RESTful CRUD API using AWS serverless services (part 2)

Greetings! In the previous post , I described how to create a serverless REST API using the serverless framework in which we discussed the project setup and the create operation. In this post, we will complete other operations of our API. You can find the complete source code here . Read Item(s) As we created an item in our previous post, we had to check the value using the AWS console. Now it is time to access items via the REST endpoint. Get all books/items When we define APIs for fetching, we use the "get" HTTP method. As we select all the books, we use the DynamoDB scan command hence we need to allow access to it. Get all handler definition getBooks: handler: src/get-books.handler iamRoleStatements: - Effect: Allow Action: - dynamodb:Scan Resource: !GetAtt crudDynamoDBTable.Arn events: - http: path: /books method: get cors: true Get all handler implementation Create a ne

Let's build a RESTful CRUD API using AWS serverless services (part 1)

Greetings! In a previous post , I talked a little about building serverless APIs with AWS. However, I have used a manual approach in that post and that is not maintainable and reusable in a practical project. Hence in this post, I am using the serverless framework to build our infrastructure. You can find the complete source code here . What is the serverless framework? It is a free and open-source framework for building applications on AWS Lambda (though it supports several other cloud providers now), API Gateway, DynamoDB, and many other services. Install and configure the serverless framework We can install the serverless framework using npm. npm install -g serverless Then we need to configure AWS credentials for the serverless framework to access our AWS account. Create a new AWS IAM user (IAM -> Users -> Add users -> with programmatic access) and configure the serverless framework using the IAM user key and secret as below. serverless config credentials --provider