I am trying to set up a stream from one dynamo stream so it can put data into another dynamo table, but the data does not seem to be put into the dynamo target table
The code executes fine, and cloudwatch does not show any errors. It has enough permissions to access the dynamo table it is trying to write to.
var AWS = require("aws-sdk");
const dynamoDb = new AWS.DynamoDB.DocumentClient();
exports.handler = async (event, context) => {
event.Records.forEach((record) => {
if (record.eventName != 'INSERT') {
console.log('Ignored ' + record.eventName + ' stream event.');
return;
}
var input = record.dynamodb.NewImage;
var id = input.pageId.S;
console.log(input);
console.log(id);
const params = {
TableName: "target-table",
Key: {
"targetId": id,
},
Item: {"targetId": id},
};
dynamoDb.put(params).promise();
console.log("put put the put put")
});
}
I am expecting data I enter in one table to be replicated into the target, but nothing seems to happen.