Setup
Require the modules package with Composer (it pulls inaws/aws-sdk-php):
configFile is a file path relative to your config directory or an absolute path.
sqs-config.yml
Named connections define how to reach AWS SQS (region, credentials, and so on). At runtime you refer to a connection by name and pass the queue name separately.Autowired services
SqsService
SqsService is the primary service for sending messages and managing queues. Inject it with #[Autowired]:
SqsConnections
SqsConnections holds all registered connections indexed by name. Use it when you need direct access to a specific connection:
SqsConnection (individual bean)
Each named connection is also registered as an individual bean with the suffix_connection. You can autowire a specific connection by name:
Connection properties
Using IAM roles (no keys required)
When your application runs on AWS infrastructure (EKS, EC2, Lambda, ECS, and so on), you do not need to specifycredentials. The AWS SDK automatically picks up the IAM role through the default credential chain.
EKS IRSA example
- Create an IAM role with the required SQS permissions.
- Annotate your Kubernetes ServiceAccount with the role ARN:
eks.amazonaws.com/role-arn: arn:aws:iam::123456789:role/my-sqs-role - Omit the
credentialsblock. The SDK uses the IRSA-provided credentials automatically.
Consumer properties
How to write a consumer worker
Implement theConsumer interface (or extend AbstractConsumer):