-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
33 lines (27 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//Orbis Ventures SAC
//Developed by: Roberto Carlos Reyes Fernández
// For development/testing purposes
var xray = require("aws-xray-sdk");
var aws = xray.captureAWS(require("aws-sdk"));
var dynamodb = new aws.DynamoDB();
var s3Object = null;
exports.handler = (event, context, callback) => {
s3Object = event.Records[0].s3;
var object = s3Object.bucket.name + "/" + s3Object.object.key;
var demo_segment = xray.getSegment().addNewSubsegment("demo");
demo_segment.addAnnotation("Object", object);
demo_segment.addMetadata(object, s3Object);
dynamodb.putItem({
TableName: process.env["my_table"],
Item: {
"id": { S: object },
"metadata": { S: JSON.stringify(s3Object) }
}
}, (err,data) => {
if (err) console.log(err, err.stack);
else {
demo_segment.close();
callback(null, "done");
}
});
};