Asish Asish - 4 months ago 31
Node.js Question

Log post data using AWS Lambda

I am new to AWS Lambda. I got a working model of lambda function which logs the json data to cloudwatch and also S3 bucket.

This is the function :

exports.handler = function(event, context) {
var s3 = new AWS.S3();
var param = {Bucket: 'test', Key: 'test123', Body:};
console.log("EVENT DATA :" + param.Body);
s3.upload(param, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response

console.log('actually done!');

This is my json data :

"name": "XYZ ABC",
"value": 123

How should I push the whole JSON data given above to S3 and CloudFront logs rather than just



Change to JSON.stringify(event). If you get [object Object] somewhere, change it to JSON.stringify(event, null, 2)