In this post, we take a look at AWS Lambda, a good example of serverless compute. As with any serverless application, there is no need to manage any servers and related server activities like OS installation, patching, etc. Scaling is handled automatically in that AWS Lambda code is triggered in response to an event. If more events occur, then, for each event, AWS Lambda code is executed. Similarly, if lesser events occur, lesser corresponding amount of AWS Lambda code are executed. If no events occur, no Lambda is executed. Billing for Lambda is for the number of times the code is executed and code execution time in multiples of 100 milliseconds. We will see a few simple examples on AWS Lambda below.
After logging into Management Console, call AWS Lambda, click on Create Function:
We will not write any code from scratch. Instead, we will borrow code from an existing blueprint. In the next window, after clicking Use a blueprint, using the filter under Blueprints, bring up hello-world-python blueprint. Select it and click Configure:
Under Function name, enter FirstLambda. Select Create a new role with basic Lambda permissions under Execution role. Observe the code and click Crate Function at the bottom of the page:
Click on Save button. Then, click on Test button to the left of Save button. In the Configure test event window, replace value1 to Hello, world! and enter LambdaEvent under Event name and click Create button at bottom:
Once the event test event details are saved, click on Test button:
The results can be seen below:
Click on Details to see more details:
See the results output that is in line with the code. Click on Monitoring to see CloudWatch metric details:
Then, click on View logs in CloudWatch:
Click on the only record under Log Streams to see more details:
Create a second function using existing role as shown below:
Then, click Create Function at bottom of page. Default code generated is shown below:
Modify the code to include context properties as shown below including handler name:
Then, click Test to configure Text event details:
Then, save and test the function. Results are shown below:
Execution results are shown below:
This concludes the introduction to AWS Lambda
After logging into Management Console, call AWS Lambda, click on Create Function:
We will not write any code from scratch. Instead, we will borrow code from an existing blueprint. In the next window, after clicking Use a blueprint, using the filter under Blueprints, bring up hello-world-python blueprint. Select it and click Configure:
Under Function name, enter FirstLambda. Select Create a new role with basic Lambda permissions under Execution role. Observe the code and click Crate Function at the bottom of the page:
Click on Save button. Then, click on Test button to the left of Save button. In the Configure test event window, replace value1 to Hello, world! and enter LambdaEvent under Event name and click Create button at bottom:
Once the event test event details are saved, click on Test button:
Click on Details to see more details:
See the results output that is in line with the code. Click on Monitoring to see CloudWatch metric details:
Then, click on View logs in CloudWatch:
Click on the only record under Log Streams to see more details:
Create a second function using existing role as shown below:
Then, click Create Function at bottom of page. Default code generated is shown below:
Modify the code to include context properties as shown below including handler name:
Then, click Test to configure Text event details:
Then, save and test the function. Results are shown below:
Execution results are shown below:
This concludes the introduction to AWS Lambda