EventBridge: Add support for InputPath on targets
Type of request: This is a ...
[ ] bug report [x] feature request
Detailed description
Add support for the attribute InputPath in EventBridge targets.
awslocal events put-targets \
--rule test-rule \
--event-bus-name test-bus \
--targets "Id"="test-rule","Arn"="arn:aws:sqs:us-east-1:000000000000:test-queue","InputPath"="$.detail"
Expected behavior
I expect the InputPath rule to be applied on the body of the message when it is send to a target.
Actual behavior
InputPath property is ignored on the awslocal events put-targets operation and an EventBridge event is passed to the target.
See https://github.com/localstack/localstack/blob/a63dcd30c475d5c2cf035703e40783c4cb5e3e9e/localstack/services/events/events_starter.py#L132
Steps to reproduce
Command used to start LocalStack
Started via docker
Client code (AWS SDK code snippet, or sequence of "awslocal" commands)
awslocal events create-event-bus \
--name test-bus
awslocal sqs create-queue \
--queue-name test-queue
awslocal events put-rule \
--name test-rule \
--event-bus-name test-bus
awslocal events put-targets \
--rule test-rule \
--event-bus-name test-bus \
--targets "Id"="test-rule","Arn"="arn:aws:sqs:us-east-1:000000000000:test-queue","InputPath"="$.detail"
awslocal events put-events --entries '[{"DetailType": "Test", "Source": "aws.test", "Detail": "{ }", "EventBusName": "test-bus"}]'
awslocal sqs receive-message --queue-url http://localhost:4566/000000000000/test-queue
{
"Messages": [
{
"MessageId": "ee455cc6-6a98-9bbf-8ef5-337891dadbeb",
"ReceiptHandle": "dlpafjicvwhfstcteltquetozrhntchpmokmhirhtsjcyvxywkvuiawygqpgrrxhgaiuxobizsedcqcxhmxcomgdpsvaqpmdqyclaclfdeppfishdvbhnhutcethhiezdyouufebbwchwsrlmjmodulmlxshyevniwkzmalbfptsipwgjtwzyejnj",
"MD5OfBody": "5fe365d3d41a8119be1a20ed9239e795",
"Body": "{\"version\": \"0\", \"id\": \"0608d2c7-0f42-419e-b057-f591da1fb99a\", \"detail-type\": \"Test\", \"source\": \"aws.test\", \"account\": \"000000000000\", \"time\": \"2020-10-02T15:14:17Z\", \"region\": \"us-east-1\", \"resources\": [], \"detail\": {}}",
"Attributes": {
"SenderId": "AIDAIT2UOQQY3AUEKVGXU",
"SentTimestamp": "1601651657141",
"ApproximateReceiveCount": "1",
"ApproximateFirstReceiveTimestamp": "1601651659519"
}
}
]
}
You can see that the content of the message send to SQS is the whole Event received in EventBridge, when only the content of the Detail field is expected (based on the test-rule). I expect the Body of the SQS message to be equal to "{}".
Thanks for reporting @jesmiatka . This should be fixed in #3063 - can you please give it another try with the latest version of the Docker image? Please report here if the problem persists. Thanks
Hi @whummer,
I've pulled the latest docker image and can confirm this feature is working as expected now. Thanks for the quick addition.