我有一个aws lambda函数,需要触发aws sqs,但我总是收到以下消息:
Fail Send MessageAccessDenied: Access to the resource https://sqs.eu-west-1.amazonaws.com/ is denied
这是我的lambda:
var QUEUE_URL = 'https://sqs.eu-west-1.amazonaws.com/*****/*****'
var AWS = require('aws-sdk');
var sqs = new AWS.SQS({region : 'eu-west-1'});
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
}
});
}
有人知道问题可能是什么或aws.sqs的好资源吗?我是否需要传递凭据,以及如何在aws.sqs中设置队列URL?