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: event.name};
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!');
context.done();
});
console.log('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 event.name?
Thanks.