Unable To Trigger Aws Sqs From Aws Lambda Function

I have an aws lambda function that needs to trigger an aws sqs but I always get the following message:

Fail Send MessageAccessDenied: Access to the resource is denied

This is my lambda:

var QUEUE_URL = '*****/*****'
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{
      context.done(null,'');  // SUCCESS

Anybody any idea what the problem could be or a good resource for the aws.sqs? Do I need to pass credentials, and how do I set my queue url in aws.sqs?



Do you have an execution role assigned to your Lambda function that allows it to send a message to the SQS queue? This article details how to do it, specifically the section, Setting up the IAM Role.