Collecting Lambda logs via CloudWatch
In this topic, we are going to deploy a simple Python function in order to investigate logs via the CloudWatch service. Let’s do so step by step:
- Create a Lambda function in AWS. In Chapter 3, where we covered Lambda, the basic steps of the Lambda deployment were explained. Hence, here, we will provide a summary of the Lambda steps. The name of the Lambda function is
TestLogs
:
Figure 7.1 – Creating a Lambda function
- The Lambda function creates a basic template, like the following:
Figure 7.2 – The Lambda template
- Copy the following code block to the handler:
import json import os def lambda_handler(event, context): print('ENVIRONMENT VARIABLES') print(os.environ) return { 'statusCode': 200, ...