Asish Asish - 2 years ago 143
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


Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download