访问SQS时拒绝访问权限
获取消息 - Messageaccessdenied:访问资源 https://sqs.us-west-2.amazonaws.coms.coms.com /被拒绝 从LAMDA函数发送消息时,将消息发送到SQS。 我做错了什么?
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
}
});
}
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
}
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您分配给AWS lambda功能的IAM角色的问题。您需要添加该IAM角色的权限才能将消息输入SQS队列。
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.