davsclaus opened a new pull request, #30577: URL: https://github.com/apache/camel/pull/30577
_Claude Code on behalf of davsclaus_ JIRA: [CAMEL-27360](https://issues.apache.org/jira/browse/CAMEL-27360) ## Problem With `autoCreateQueue`, the EventBridge consumer creates an SQS queue, adds it as a target of the rule, and sets a queue policy (`EventbridgeConsumer.buildQueuePolicy`). That policy allows `events.amazonaws.com` to call `sqs:SendMessage` with no `Condition`, so any EventBridge rule may send to the queue, not only the consumer's own rule. AWS recommends limiting a service principal with `aws:SourceArn`: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-use-resource-based.html#eb-sqs-permissions This was found while adding the `aws-eventbridge-source` Kamelet (apache/camel-kamelets#3334). ## Fix - Before it creates the queue, the consumer gets the rule ARN with `DescribeRule` (rule name + event bus). - The policy then gets `"Condition":{"ArnEquals":{"aws:SourceArn":"<rule arn>"}}`. - A rule that does not exist now fails the start before any queue is created. - A queue given with `queueUrl` keeps its own policy: no `DescribeRule`, no `SetQueueAttributes`. - Docs: the "How It Works" step and the IAM permissions now list `events:DescribeRule`, which is needed when auto-creating. The catalog copy of the page is updated too. - Upgrade guide 4.24 entry: the new policy condition, the new `events:DescribeRule` permission, and a missing rule now failing the start. ## Tests - `EventbridgeConsumerTest`: - The policy JSON of an auto-created queue has the `ArnEquals` / `aws:SourceArn` condition with the ARN from `DescribeRule`. - `DescribeRule` gets the rule name and the event bus. - A missing rule fails before `CreateQueue` and `PutTargets`. - A user-provided queue gets no `DescribeRule` and no `SetQueueAttributes`. - A plain unit test of `buildQueuePolicy`. - The new assertions fail without the fix. - `EventbridgeConsumerUserQueueTargetTest`: stubs `DescribeRule` for the auto-created queue case. - New `EventbridgeConsumerQueuePolicyIT` (Floci): - Creates the rule before the route starts, checks the policy of the auto-created queue, and checks that the queue still receives an event of the rule. - Disabled on s390x/ppc64le, where the test infra uses LocalStack. - The existing `EventbridgeConsumerIT` stays `@Disabled`: its routes start before its tests create the rules, so it fails at `PutTargets` with "Rule not found", with or without this change. Run locally: the module's unit tests (38, all pass) and `EventbridgeConsumerQueuePolicyIT` on Floci 2.4.0 (passes). 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
