AWS Messaging Plugin (SNS and SQS)
The AWS Messaging plugin gives Drift the ability to publish to Amazon SNS topics and to publish to and consume from Amazon SQS queues. It is used alongside the AsyncAPI plugin to verify message-based APIs whose AsyncAPI document declares the sns or sqs protocol.
Drift connects to the real service and exchanges real messages, whether that is AWS itself or a local emulator such as LocalStack.
Property | Value |
|---|---|
Plugin name |
|
Purpose | Amazon SNS and SQS transport for AsyncAPI operations |
Protocols |
|
Used with |
|
Supports | Asynchronous interactions only |
Enabling the Plugin
plugins: - name: asyncapi - name: aws-messaging - name: json
Use aws-messaging in place of the kafka plugin. One plugin covers both SNS and SQS, and Drift selects the right service per operation.
Supported Execution Modes
SNS and SQS support asynchronous interactions only - fire-and-forget flows where a message travels one way.
Mode | Supported | What Drift does |
|---|---|---|
| Yes | Consumes from the queue and captures the message your service publishes |
| Yes | Publishes the message, then runs your probe |
| Yes | Subscribes to a probe queue, publishes, then captures the harness result |
| No | Not available on SNS or SQS |
Choosing Between SNS and SQS
Drift determines the service per operation from the channel address, falling back to the server protocol.
Channel address | Service |
|---|---|
Starts with | SNS |
Starts with | SQS |
An SQS queue URL | SQS |
Neither, with | Taken from the protocol |
Drift can both publish and consume on either service, so all three asynchronous execution modes are available whichever one your AsyncAPI document declares.
Channel Addresses
Use an ARN or an SQS queue URL as the AsyncAPI channel address:
channels:
inventoryAdjusted:
address: arn:aws:sqs:us-east-1:123456789012:inventory-adjusted
orderNotifications:
address: arn:aws:sns:us-east-1:123456789012:order-notificationsservers:
aws:
host: sqs.us-east-1.amazonaws.com
protocol: sqsCredentials
Drift reads AWS credentials from standard environment variables and signs every request with SigV4.
Variable | Required | Purpose |
|---|---|---|
| Yes | Access key |
| Yes | Secret key |
| No | Session token for temporary credentials |
export AWS_ACCESS_KEY_ID="AKIA..." export AWS_SECRET_ACCESS_KEY="..." export AWS_SESSION_TOKEN="..." # only for temporary credentials drift verify -f drift/inventory.testcases.yaml
Drift fails with a clear message if AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY is not set.
Do not commit credentials to your test case files. Use environment variables in local development and your CI system's secret store in pipelines. For general Drift authentication options, see Configuring Authentication.
Region Resolution
Drift resolves the region in this order. The first match wins.
Priority | Source | Example |
|---|---|---|
1 (highest) | The region test case parameter |
|
2 | Parsed from the server host |
|
3 |
|
|
4 (lowest) | Built-in default |
|
parameters: region: eu-west-2
Overriding the Endpoint
Set an aws.endpoint-url parameter to send requests somewhere other than the public AWS endpoint. This is how you run against LocalStack or another emulator.
parameters:
aws:
endpoint-url: http://localhost:4566
region: us-east-1When no override is given, Drift builds the endpoint from the service and region as https://<service>.<region>.amazonaws.com.
Running Against LocalStack
LocalStack is the recommended local setup. It is fast, disposable, and costs nothing.
services:
localstack:
image: localstack/localstack:latest
ports:
- "4566:4566"
environment:
SERVICES: sqs,snsexport AWS_ACCESS_KEY_ID=test export AWS_SECRET_ACCESS_KEY=test export AWS_REGION=us-east-1 aws --endpoint-url=http://localhost:4566 sqs create-queue \ --queue-name inventory-adjusted
parameters:
aws:
endpoint-url: http://localhost:4566Correlation
Drift carries the correlation identifier as a message attribute on publish, and filters captured messages by that attribute.
Declare the location in your AsyncAPI message. This is required - it is what enables correlation.
components:
messages:
inventoryAdjusted:
correlationId:
location: "$message.header#/correlation-id"The value is optional. Drift takes it from the AsyncAPI document, then from the correlation-id parameter, and generates a UUID when neither supplies one.
parameters: correlation-id: receive-inventory-adjusted-001
Set the value yourself when a probe command or an expectation needs the same identifier. Where you do set it, give each operation a distinct value.
Capture Behavior
Drift captures from SQS using long polling, which keeps latency low without busy-waiting.
Setting | Where | Default | Purpose |
|---|---|---|---|
| Test case parameter | 30000 | How long Drift waits for a matching message |
poll-interval-ms | Plugin configuration | 500 | Interval between receive attempts |
parameters: timeout-ms: 10000
Allow more time than you would for a local Kafka broker. Network round trips to AWS add latency, and SQS visibility behavior can delay delivery.
Creating Queues and Topics
Drift does not create queues or topics. Create every queue, topic, and probe queue in your AsyncAPI document before the run, using the AWS CLI, your infrastructure-as-code tool, or LocalStack setup scripts.
Limitations
Request/reply is not supported. Use Kafka for those interactions.
Drift does not create queues or topics.
Drift captures the first message matching the correlation ID. It does not verify ordering, including FIFO queue ordering guarantees.
Drift does not verify visibility timeouts, dead-letter queue routing, redrive policies, or retry behavior.
Drift does not verify SNS subscription filter policies.
Troubleshooting
Symptom | Likely cause |
|---|---|
| Credentials are not exported in the shell or CI job running Drift |
Signature or authorization error | Wrong region. Check the resolution order above - a region parsed from the server host overrides |
Requests reach AWS instead of LocalStack |
|
Queue does not exist | Create the queue before the run. Drift does not create it. |
Capture timeout, message was published | The message attribute carries a different correlation ID, or Drift is polling a different queue |
Mode error on request/reply | SNS and SQS support asynchronous interactions only |
See Debugging Test Cases.