What are some possible reasons why the following is not working for me?
- Create a DynamoDB table
card_auth_eventswith at least anidfield. - Create a trigger that calls a lambda. Here is the lambda:
console.log('Loading publishCardAuthEvent...');
var QUEUE_URL = 'https://sqs.us-west2.amazonaws.com/XXXXXXXXXXXX/CardAuthEvents';
var AWS = require('aws-sdk');
var sqs = new AWS.SQS({region : 'us-west-2'});
var http = require('https');
exports.handler = function(event, context) {
event.Records.forEach(function(record) {
console.log(record.eventID);
console.log(record.eventName);
console.log('DynamoDB Record: %j', record.dynamodb);
sendToQueue(record);
});
context.succeed("Successfully processed " + event.Records.length + " records.");
};
function sendToQueue(message){
//Send SQS message with details of file uploaded to S3.
var params = {
MessageBody: JSON.stringify(event),
QueueUrl: QUEUE_URL
};
sqs.sendMessage(params, function(err,data){
if (err) {
console.log('error:',"Fail Send Message" + err);
context.done('error', "ERROR Put SQS"); // ERROR with message
} else {
console.log('data:',data.MessageId);
context.done(null,''); // SUCCESS
}
});
}
Configure the Lambda to have a role with
AmazonSQSFullAccess,AmazonDynamoDBFullAccess, andAmazonAppStreamFullAccess.Create the Queue in SQS
Insert a record into the table.
The trigger is getting called, but why is the message not put in the Queue???
There are no messages in the queue and no errors in Cloud Watch. Is there some secret I am missing?