Skip to content

SqsTransportNameResolver cannot resolve transports for non-aws partitions (e.g. AWS European Sovereign Cloud, arn:aws-eusc:…) #2157

Description

@thedomeffm

Version(s) affected

I am using 1.4.1

Description

SqsTransportNameResolver maps the Lambda event's eventSourceARN back to a configured Messenger transport, but both of its matching strategies assume the standard aws partition:

// Rebuild SQS ARN from https://sqs.eu-west-3.amazonaws.com/0123456789/messages?key=value
if (preg_match('/^https:\/\/sqs\.([^.]+)\.amazonaws\.com\/([^\/]+)\/([^?]+)/', (string) $dsn, $matches)) { ... }
  • The regex only matches amazonaws.com queue URLs — the AWS European Sovereign Cloud (partition aws-eusc, region eusc-de-east-1) uses amazonaws.eu (and the China partition uses amazonaws.com.cn).
  • The rebuilt ARN hardcodes the arn:aws: prefix, while the incoming event carries the actual partition, e.g. arn:aws-eusc:sqs:eusc-de-east-1:123456789012:my-queue. So even if the URL regex matched, the comparison would still fail for any non-aws partition (including aws-cn and aws-us-gov).

Result when a message is consumed:

InvalidArgumentException: No transport found for eventSource
"sqs://arn:aws-eusc:sqs:eusc-de-east-1:123456789012:my-queue".
(src/Service/Sqs/SqsTransportNameResolver.php:44)

The exact-match strategy ($dsn === 'sqs://' . $eventSourceArn) can't be used as an escape hatch either, because an ARN-shaped sqs:// DSN is not parseable by symfony/amazon-sqs-messenger on the sending side.

How to reproduce

  1. Deploy a Symfony app with bref/symfony-messenger in an AWS partition other than aws — e.g. the European Sovereign Cloud (eusc-de-east-1).
  2. Configure the SQS transport DSN (queue URL form or sqs://host/account/queue?region=… form) and wire the queue to SqsConsumer as usual.
  3. Send any message to the queue → the consumer throws No transport found for eventSource "sqs://arn:aws-eusc:…".

Possible solution

Instead of rebuilding a full ARN with a hardcoded partition, compare the components: extract (region, account, queue) from the eventSourceARN (arn:<partition>:sqs:<region>:<account>:<queue>) and from the DSN, and match on those. That makes the resolver partition-agnostic and also covers future partitions/URL suffixes without further regex maintenance. Alternatively, relax the URL regex to any suffix and take the arn:<partition>: prefix from the event's own ARN.

Workaround

Pin the transport name explicitly so the resolver is never consulted (works when the app has a single SQS transport):

# config/services.yaml
Bref\Symfony\Messenger\Service\Sqs\SqsConsumer:
    public: true
    autowire: true
    arguments:
        $transportName: "async"

Additional context

The sending side has the same partition assumption in symfony/amazon-sqs-messenger (AmazonSqsTransportFactory::supports() and Connection::fromDsn() only accept amazonaws.com); reported separately to symfony/symfony.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions