Description
Amazon SQS Messenger version(s) affected: 5.3
Description
An exception is thrown when trying to setup non-existent queues. The exception is ''The Amazon SQS queue "<queue_name>" does not exists (or you don't have permissions on it), and can't be created when an account is provided.". It is thrown from line 276 of \Symfony\Component\Messenger\Bridge\AmazonSqs\Transport\Connection. Looking at the code in that area, if there is an account set you can't create queues....but the reasoning for this isn't clear.
How to reproduce
- Configure messenger to use an access and secret key with an sqs url with account number (like https://sqs.us-west-2.amazonaws.com/123457890/?access_key=ACCESS_KEY&secret_key=SECRET_KEY)
- Create a transport using Amazon SQS and configure a queue_name that doesn't yet exist in SQS.
- Run
bin/console messenger:setup
Possible Solution
I believe the thrown exception is unnecessary and can be removed.
Note updated
It seems like the error is thrown because of an assumption that if we have an account ID, then we must expect that the queue already exists. However, I don't think that is necessarily true. From what I'm seeing, the queue url is predictable and we can assume it takes the following form: https://sqs.<region>.amazonaws.com/<account>/<queue_name>
. From that, I don't think it hurts to ask if the queue exists, and if not, create it. That is basically what the setup function already does. But, perhaps there is a good reason not to trust that scheme?