new-immo-group / messenger-transport-sqs-iam
aws connector handling ini IAM files to access IAM roles
Requires
- php: >=7.4
- ext-json: *
- aws/aws-sdk-php: ^3
- psr/log: *
- symfony/messenger: >4.4|>=5.4
Requires (Dev)
- ext-ctype: *
- ext-iconv: *
- friendsofphp/php-cs-fixer: ^3.9
- g1a/composer-test-scenarios: ^3.2
- maglnet/composer-require-checker: ^3.8
- nig-devteam/messenger-serializers: ^1.5
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
- symfony/console: 5.4.*
- symfony/dotenv: 5.4.*
- symfony/flex: ^1.17|^2
- symfony/framework-bundle: 5.4.*
- symfony/phpunit-bridge: ^6.1
- symfony/runtime: 5.4.*
- symfony/serializer: 5.4.*
- symfony/yaml: 5.4.*
Conflicts
- dev-main
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.11.0
- v1.10.1
- v1.10.0
- v1.9.0
- v1.8.1
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.11
- v1.1.10
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-renovate/symfony
- dev-renovate/phpstan-phpstan-1.x-lockfile
- dev-renovate/aws-aws-sdk-php-3.x-lockfile
- dev-renovate/lock-file-maintenance
- dev-renovate/phpunit-phpunit-12.x
- dev-renovate/phpstan-phpstan-2.x
- dev-renovate/phpunit-phpunit-9.x-lockfile
- dev-renovate/nig-devteam-messenger-serializers-1.x-lockfile
- dev-renovate/new-immo-group-devops-ci-cd-template-8.x
- dev-feat/CA-2277-proper-queue-creation
- dev-fix/visibility_timeout
- dev-renovate/friendsofphp-php-cs-fixer-3.x-lockfile
- dev-test-idem
This package is auto-updated.
Last update: 2025-03-09 22:21:28 UTC
README
This lib allows a simpler integration of AWS's SQS queues through IAM authentication.
It will register a new Messenger Transport for any DSN matching ^https://sqs.
.
Installation
$ composer require new-immo-group/messenger-transport-sqs-iam
Configuration
Env variables
These env variables will be required:
AWS_REGION= # in my case, eu-west-3
AWS_VERSION= # generically latest
AWS_SDK_LOAD_NONDEFAULT_CONFIG=true # whether to load .aws/config
AWS_PROFILE= # profile in $HOME/.aws/config you want to load
AWS_ACCOUNT_ID=
MESSENGER_TRANSPORT_DSN=https://sqs.${AWS_REGION}.amazonaws.com/${AWS_ACCOUNT_ID}
AWS SDK
The files $HOME/.aws/config
and $HOME/.aws/credentials
must exists on the host.
Note that if the env variable AWS_SDK_LOAD_NONDEFAULT_CONFIG
is set,
when loading .aws/credentials
the AWS-SDK will also load .aws/config
.
If there is an active open_basedir()
restriction, make sure to add $HOME/.aws
to the allowed path list.
Symfony
Register the SQS transport
services:
NewImmoGroup\AwsBroker\SqsTransportFactory:
class: NewImmoGroup\AwsBroker\SqsTransportFactory
tags: [messenger.transport_factory]
arguments:
$defaultOptions:
auto_setup: true
queue_prefix: 'some-prefix-'
queue_tags:
queue_env: "%env(APP_ENV)%"
We can provide the factory optional default option values:
auto_setup
: It controls, at the Transport level, whether the queue is created automatically when a message is sent. Default tofalse
.queue_prefix
: Define a prefix that will be added to the queue name.queue_tags
: A list of tags that will be set on all created queues.
Any of these options can be overridden at the queue level (see below).
Queue configuration example
framework:
messenger:
transports:
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
serializer: messenger_serializer
options:
queue_name: "my-queue-name-here"
auto_setup: false
queue_prefix: 'some-prefix-'
queue_tags:
env: "%env(APP_ENV)%"
The auto_setup
, queue_prefix
and queue_tags
parameters are optional. They override the factory defaults, if any.
CI/Tests
PHP7.4-CLI and PHP8.1-CLI are required.
The end-to-end/functional test will require a valid AWS configuration (which usually expires after a few hours).
make test # Symfony5/PHP7.4
make test@php8 # Symfony5/PHP8.1
make test@sf6 # Symfony6/PHP8.1
AWS.SQS Permissions
Provided user should be able to call :
- GetQueueUrl
- CreateQueue
- SendMessage
- DeleteMessage
- GetQueueAttribute