Search code examples
amazon-web-servicesaws-lambdaamazon-sqsamazon-cloudwatch

cloudwatch rule from sqs to lambda


I have defined a trigger to my lambda from SQS queue. I want the Lambda to get invoked after every 2 hours and pick 15k messages from the queue.

Is it possible?

If yes, then how. Thanks!


Solution

  • This is very possible. You can write a Lambda function that uses the AWS SQS API to retrieve messages from a queue. Then you can use scheduled events to define when a Lambda function is invoked. You can use a CRON expression to set the schedule. If you are not familiar with using CRON Expressions to define when a Lambda function is invoked, see this example.

    This is implemented in Java - but you can still set a schedule event regardless of what programming language is used to develop the Lambda function:

    https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases/creating_scheduled_events