jleaman

Lambda PrintPayloadToLogs Function

Sep 2nd, 2016
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from __future__ import print_function
  2.  
  3. import json
  4. import urllib
  5. import boto3
  6.  
  7. print('Loading function')
  8.  
  9. def lambda_handler(event, context):
  10.     #print("Received event: " + json.dumps(event, indent=2))
  11.     print(event)
  12.     print(context)
  13.     return event
  14.  
  15. # Code commentary:
  16. # ·         I’m importing more than I have to, but I find that I use these often when testing.
  17. # ·         Using the ‘print()’ function, I’m writing directly to CloudWatch logs.  This is very helpful for troubleshooting.
  18. # ·         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’.
  19. # ·         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.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×