Skip to content

Instantly share code, notes, and snippets.

@joepindar
Created February 4, 2018 18:10
Show Gist options
  • Save joepindar/f443b056d229cbbe7ea53902d5f7d8e6 to your computer and use it in GitHub Desktop.
Save joepindar/f443b056d229cbbe7ea53902d5f7d8e6 to your computer and use it in GitHub Desktop.
AWS Lambda reflector function - prints and returns whatever it is sent from API Gateway
+# Uses Python3
+import json
+
+# Generate a response for the browser
+def _generate_response(status, body):
+ return {
+ 'statusCode': status,
+ 'headers': {
+ 'Access-Control-Allow-Origin': '*',
+ 'X-Requested-With': '*',
+ 'Content-Type': 'application/json'
+ },
+ 'body': json.dumps(body)
+ }
+
+def lambda_handler(event, context=None):
+ print("event: {}".format(event))
+ print("context: {}".format(context))
+ _generate_response(200, event)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment