Search code examples
amazon-web-servicesamazon-sqs

How can I freeze an SQS queue against any reads?


I have an SQS queue (standard, not FIFO) I'm using as a task queue for multiple workers on a long-running process.

I'm trying to add a 'kill switch' that'll temporarily stop my workers from being able to receive/process any messages.

I don't want to delete the messages or stop any new messages from entering the queue, just stop any readers until I toggle the kill switch again.

Is this possible to do with the SDK? or with permissions?


Solution

  • I dont know of an sqs pause button, and I don't see any sqs API calls that seem promising.

    You could remove access from the iam policies allowing the readers to read.

    You could remove access to sqs public ips at a network level.

    But I hate those solutions; they blur failure scenarios with success and aren't really any more elegant or convenient than orchestrating within the application.

    I'd advise my engineers to use a feature flag for this, in dynamo, consul, or some other consistent key value store. Makes a lot more sense to me than allowing all the reads to fail continuously while the permission or net access is removed