Thanks to visit codestin.com
Credit goes to github.com

Skip to content

localstack eventsbridge with SQS as target, doesn't adhere to the rules condition #3132

Closed
@Salman-K

Description

@Salman-K

Type of request: Bug

[x] bug report
[ ] feature request

Detailed description

When using eventsbridge on localstack with SQS as target, the rules are completely ignored and the messages are always pushed to the queue regardless.

Expected behavior

Messages are dropped if condition in rule isn't met.

Actual behavior

Message appears on the queue even though it clearly doesn't match the criteria of the rule pattern.

Steps to reproduce

1. Setup localstack using docker
2. Create Queue
3. Create EventBus
4. Set Queue attributes to allow eventbridge access
5. Put target on eventbridge
6. Put new event onto eventbus
7. Check queue for message

Command used to start LocalStack

docker run -d -p "4567-4587:4567-4587" -p "4592-4593:4592-4593" -p 80:8080 -v /var/run/docker.sock:/var/run/docker.sock -e LAMBDA_EXECUTOR=docker --name aws localstack/localstack:0.11.2

Client code (AWS SDK code snippet, or sequence of "awslocal" commands)

$AWS_REGION = 'us-east-1'
$LOCALSTACK_ENDPOINT = 'http://localhost'

aws --endpoint-url=${LOCALSTACK_ENDPOINT}:4576 sqs create-queue --queue-name orderTestQueue

aws --endpoint-url=${LOCALSTACK_ENDPOINT}:4587 --region ${AWS_REGION} events create-event-bus --name orderTestBus

aws --endpoint-url=${LOCALSTACK_ENDPOINT}:4587 --region ${AWS_REGION} events put-rule --name orderTestRuleMatchSource --event-bus-name orderTestBus --event-pattern file://rule-filter.json

aws --endpoint-url=${LOCALSTACK_ENDPOINT}:4576 sqs set-queue-attributes --queue-url "http://localhost:4576/queue/orderTestQueue" --attributes file://sqs-policy.json

aws --endpoint-url=${LOCALSTACK_ENDPOINT}:4587 --region ${AWS_REGION} events put-targets --rule orderTestRuleMatchSource --event-bus-name orderTestBus --targets file://rule-queue-arn.json

aws --endpoint-url=${LOCALSTACK_ENDPOINT}:4587 --region ${AWS_REGION} events put-events --entries file://order-data.json

aws --endpoint-url=${LOCALSTACK_ENDPOINT}:4576 sqs receive-message --queue-url "http://localstack:4576/queue/orderTestQueue"

rule-filter.json

{"source": [ "UpdateOrder" ]}

order-data.json

[{
"EventBusName": "orderTestBus",
"Source": "NewOrder",
"DetailType": "OrderAdded",
"Detail": "{"order_id":"a787ecb","quantity":"1","customer_id":"alpha"}"
}]

sqs-policy.json

{"Policy":"{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"*"},"Action":"sqs:SendMessage","Resource":"arn:aws:sqs:us-east-1:000000000000:orderTestQueue","Condition":{"ArnEquals":{"aws:SourceArn":"arn:aws:events:us-east-1:000000000000:rule/orderTestRuleMatchSource"}}}]}"}

rules-queue-arn.json

[{"Id": "orderTestQueueCommand", "Arn": "arn:aws:sqs:us-east-1:000000000000:orderTestQueue", "InputPath": "$.detail"}]

As you can see above i am looking to filter the messages with source UpdateOrder, where as posting order-data.json with the content displayed also ends up on the queue, which shouldn't.

Unfortunately i can't use the latest version due to dependencies, could you please confirm if this was resolved, or what am i doing wrong here.

Referenced files are attached.
Many Thanks

rule-queue-arn.zip

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions