Skip to content

Instantly share code, notes, and snippets.

@chrismay
Created June 21, 2018 09:40
Show Gist options
  • Save chrismay/70be1d97521314c74bf78854322bc830 to your computer and use it in GitHub Desktop.
Save chrismay/70be1d97521314c74bf78854322bc830 to your computer and use it in GitHub Desktop.
A lambda to unpack the POST body (assumed to be JSON) and log it to cloudwatch
exports.handler = async (event, ctx, callback) => {
console.log({app:"unknown", env: "unknown", ...(JSON.parse(event.body))});
var response = {
"statusCode": 200,
"body": JSON.stringify({result:"ok"}),
"isBase64Encoded": false
};
callback(null,response);
};
@chrismay
Copy link
Author

... should probably handle malformed requests a bit more sensibly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment