title: Listening to remote AWS SQS from local using serverless
body: <p>I want to execute the lambda function locally , on SQS event which is on my AWS account. I have defined the required event but this not getting triggered. </p>
  
  <p>How can this be achieved?</p>
  
  <p>I am able to send the messages to the same queue using cron event from my local.</p>
  
  <p>Here are few things I tried... but didnt work for me .</p>
  
  <pre><code>
  functions:
    account-data-delta-test:
      handler: functions/test/data/dataDeltatestGenerator.handler
      name: ${self:provider.stage}-account-data-delta-test
      description: account delta update  - ${self:provider.stage}-account-data-delta-test
      tags:
        Name: ${self:provider.stage}-account-data-delta-test
      # keeping 5 minute function timeout just in case large volume of data.
      timeout: 300
      events:
        - sqs:
            arn:
              Fn::GetAtt: [ testGenerationQueue, Arn ]
            batchSize: 10
  
  ----------
  
        Policies:
          - PolicyName: ${self:provider.stage}-test-sqs-policy
            PolicyDocument:
              Version: '2012-10-17'
              Statement:
              - Effect: Allow
                Action:
                - sqs:ReceiveMessage
                - sqs:DeleteMessage
                - sqs:GetQueueAttributes
                - sqs:ChangeMessageVisibility
                - sqs:SendMessage
                - sqs:GetQueueUrl
                - sqs:ListQueues
                Resource: "*"     
  
  ---------------
  
  ---
  Resources:
    testGenerationQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: ${self:provider.stage}-account-test-queue
        VisibilityTimeout: 60
        Tags:
          -
            Key: Name
            Value: ${self:provider.stage}-account-test-queue  
  
  -------------
  
  const sqs = new AWS.SQS({
      region: process.env.REGION,
  });
  
  
  exports.handler = async (event) =&gt; {
      console.error('------------ &gt;&gt;&gt;&gt;CRON:START: Test delta Job run.', event);
      log.error('------------ &gt;&gt;&gt;&gt;CRON:START: Test delta Job run.', event);
  }); 
  
  
  </code></pre>