Lambda PrintPayloadToLogs Function
Sep 2nd, 2016
- from __future__ import print_function
- import json
- import urllib
- import boto3
- print('Loading function')
- def lambda_handler(event, context):
- #print("Received event: " + json.dumps(event, indent=2))
- return event
- # Code commentary:
- # · I’m importing more than I have to, but I find that I use these often when testing.
- # · Using the ‘print()’ function, I’m writing directly to CloudWatch logs. This is very helpful for troubleshooting.
- # · Line: ‘def lambda_handler(event, context):’ is what allows you to view and manipulate the payload, which is the event. This function also comes with a second argument ‘context’.
- # · There are many use-cases for Lambda, but I find a good first step to print both the event and context to logs and move forward from there.
Please, Sign In to add comment