top of page

Tutorial to Create a Microservice using AWS Lambda & Amazon API Gateway

Updated: Nov 9, 2023

Note: This is the old UI, Please refer to this blog for New UI.


Tutorial to create a Microservice using AWS Lambda & Amazon API Gateway

Tutorial Objectives:

1. Learn to create a REST API using Amazon API Gateway.

2. Learn to create AWS Lambda function using AWS CLI


Step 1: Log on to your AWS Management Console and open AWS Lambda console.

Click on Create Function.

Step 2: Creating an API

Choose Use a blueprint.

Enter ‘microservice’ in the search bar. Choose the microservice-http-endpoint blueprint. Click on Configure.

Configure your function with the following settings.

· Name – lambda-microservice

· Role – Create a new role from AWS policy templates

· Role name – lambda-apigateway-role

· Policy templates – Simple microservice permissions

· API – Create an API

· API Type – HTTP API

· Security – Open

Choose Create function.


Step 3: Testing the API

With your lambda-microservice function still open in the Lambda console, in the bottom, choose the Test tab.

Choose New event.

Choose the Hello World template.

In Name, enter as the name as TestEvent.

In the text entry panel, replace the existing text with the following and click on save changes.

{
     "httpMethod": "GET",
     "queryStringParameters": {
     "TableName": "MyTable"
    }
}

(This GET command scans your DynamoDB table and returns all items found.)


Step 4: Once this is done, open AWS Management Console on another tab and open the DynamoDB console. Let us now create a table.

Make sure to name the table as ‘MyTable’ and set the partition key as Name.

Keeping the rest as default, click on Create Table.

Once the table is active, get back to the Lambda tab.

Now click on Test

Once you click on Test, the following details will be visible.

Note: Now, if you no longer need the resources, delete the DynamoDB table and the Lambda function that was created.



Was this document helpful? How can we make this document better? Please provide your insights. You can download PDF version for reference.

Microservice using AWS Lambda & Amazon API Gateway
.pdf
Download PDF • 469KB

We provide the best AWS training from Pune, India.

For AWS certification, contact us now.


566 views12 comments
bottom of page