title: Read SQS queue from AWS Lambda
body: <p>I have the following infrastructure:</p>
  
  <p>I have an EC2 instance with a NodeJS+Express process listening on a port for messages (<em>process 1</em>). Every time the process receives a message it sends it to an SQS queue. Then I have another process in the same machine reading the queue using long polling (<em>process 2</em>). When it finds a message in the queue it inserts the data in a MariaDB database sitting on an RDS instance. </p>
  
  <p>(<em>Just to clarify, messages are generated by users, they send a chunk of data which can contain arbitrary information to the endpoint where the process 1 is listening</em>)</p>
  
  <p>Now I want to put the process that reads the SQS (<em>process 2</em>) in a Lambda function so that the process that writes to the queue and the one that reads from the queue are completely independent. The problem is that I don't know if this is possible. </p>
  
  <p>I know that Lambda function are invoked in response to an event, and the events supported at the moment are S3, SNS, SES, DynamoDB, Kinesis, Cognito, CloudWatch and Cloudformation but <strong>NOT SQS</strong>.</p>
  
  <p>I was thinking in using SNS notifications to invoke the Lambda function so that every time a message is pushed to the queue, an SNS notification is fired and invokes the Lambda function but after playing a bit with it I've realised that is not possible to create an SNS notification from SQS, it's only possible to write SNS notifications to the queue.</p>
  
  <p>Right now I'm a bit stuck because I don't know how to continue. I have the feeling that is not possible to create this infrastructure due to the current limitations in the AWS services. Is there another way to do what I want or am I in a dead-end?</p>
  
  <p>Just to extend my question with some research I've made, this github repo shows how to read an SQS queu from a Lambda function <strong>but</strong> the lambda function works only if is fired from the command line:</p>
  
  <p><a href="https://github.com/robinjmurphy/sqs-to-lambda">https://github.com/robinjmurphy/sqs-to-lambda</a></p>
  
  <p>In the readme, the author mentions the following:</p>
  
  <blockquote>
    <p>Update: Lambda now supports SNS notifications as an event source,
    which makes this hack entirely unneccessary for SNS notifcations. You
    might still find it useful if you like the idea of using a Lambda
    function to process jobs on an SQS queue.</p>
  </blockquote>
  
  <p>But I think this doesn't solve my problem, an SNS notification can invoke the Lambda function but I don't see how I can create a notification when a message is received in the SQS queue.</p>
  
  <p>Thanks</p>