Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 3.58 KB

README.md

File metadata and controls

52 lines (39 loc) · 3.58 KB

Setup Instructions

This is an instruction guide for our demo use case which is:- Serverless website.
The problem can be replicated using terminal or the AWS console. However, for tutorial purposes and quick understanding, we will demonstrate using the AWS Lambda console in a browser.

Pre requisites

  • An Amazon AWS account with administrative access.

Configuration

1. Configuring the Lambda function

  • Log in to you AWS console using any standard browser.
  • Navigate to Services-> Compute-> Lambda to open the Lambda dashboard.
  • Click on Create Function
  • Select Author from scratch tab (we'll do everything from scratch! (¬‿¬) )
  • Configure the options as shown in the figure below and click Create Function:
    Here, we select Runtime=python3.6 since the lambda function we'll write is in python3. The function is named myLambdaFunction.

Next, we'll define the lambda function and add an API to trigger lambda function.

2. Define Lambda Function

  • Click on the myLambdaFunction field and scroll down to configure.

  • Copy and paste the entire lambda_function.py into the default lambda_function.py shown on the aws console. The result should look like this:

The lambda function is now defined and only thing left is to add an API to trigger the lambda function.

3. Configure API Gateway Trigger

  • Scroll up and select Designer-> Add Trigger-> API Gateway that will add an API gateway trigger for the lambda function.

  • Scroll down to configure the API gateway. We'll create a new API named LambdaAPI as shown below:

  • Click Add to finish configuration of API gateway.

All the necessary configurations for the lambda function are done. Click on Save at the top to save all the configurations.

4. Additional configiuration for API Gateway

  • Our client will require an invocation url to make a GET call to the serverless lambda function.

  • Navigate to Services-> Networking & Content Delivery-> API Gateway. You will find the LambdaAPI already existing there. Delete the ANY method and create a GET method.

  • Configure the GET method as follows and click Save:

  • You get an invocation url after saving, modify it in index.html to pass it as the second argument.

Testing

Now we are all set to see our website in action. Run the modified index.html file in a browser and click on the Click me button to see the result from the lambda function.

Viola! We have our first serverless website up and running!!