AWS SQS event redrive Lambda

This repository contains one simple AWS Lambda function in Python to redrive AWS SQS events from source queue to destination queue. This script can be triggered periodically via cloudwatch as well if source queue contains too many events and you dont want to redrive them altogether.

  • batch_size can be passed as input which will move only X events in one execution cycle. Default batch size is 10 if no value is passed.
  • This script ensures that if same event is getting moved into DLQ again and again, it wont get retried more than 3 times.

Disclaimer: This script adds one additional field ‘RetryCounter’ to keep track of number of retries in SQS’s MessageAttributes. In 99.9% of cases, ideally this shouldn’t cause any break in consumer code, because this is just an additional field added in attributes (NOT in body), but please confirm the impact once before usage.
None of the existing data of SQS event is touched upon.

Sample Input

  "source_queue_url" : "AWS source sqs queue URL",
  "destination_queue_url" : "AWS destination sqs queue URL",
  "batch_size": 10


  • Only ‘batch_size’ is optional here. queue URLs are mandatory fields.
  • Resource URLs are expected in the input, not the ARNs.


GitHub - Akshay314/personalprojects at
Contribute to Akshay314/personalprojects development by creating an account on GitHub.