Reputation: 909
Getting the message - MessageAccessDenied: Access to the resource https://sqs.us-west-2.amazonaws.com/ is denied while sending the message to SQS from lamda function. What i am doing wrong?
var QUEUE_URL = 'QUEUE_URL';
var AWS = require('aws-sdk');
var sqs = new AWS.SQS({region : 'us-west-2'});
exports.handler = function(event, context) {
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
}
});
}
Upvotes: 0
Views: 1679
Reputation: 200562
This is an issue with the IAM role you have assigned to the AWS Lambda function. You need to add permission to that IAM role to put messages in the SQS queue.
Upvotes: 2