This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 0fcd2a7048d2 CAMEL-27360: camel-aws2-eventbridge - the SQS queue the
consumer creates only accepts messages from its own EventBridge rule (#30577)
0fcd2a7048d2 is described below
commit 0fcd2a7048d2c49d2f8ae3d096b17ea954b3a9be
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Nov 22 11:28:53 2026 +0100
CAMEL-27360: camel-aws2-eventbridge - the SQS queue the consumer creates
only accepts messages from its own EventBridge rule (#30577)
With autoCreateQueue, the queue policy allowed events.amazonaws.com to send
to
the queue without a condition, so any EventBridge rule could send to it. The
consumer now looks up the rule ARN with DescribeRule (before it creates the
queue) and adds an ArnEquals aws:SourceArn condition with that ARN. A queue
given with queueUrl keeps its own policy.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---
.../catalog/docs/aws2-eventbridge-component.adoc | 5 +-
.../src/main/docs/aws2-eventbridge-component.adoc | 5 +-
.../aws2/eventbridge/EventbridgeConsumer.java | 31 +++++-
.../aws2/eventbridge/EventbridgeConsumerTest.java | 70 +++++++++++++
.../EventbridgeConsumerUserQueueTargetTest.java | 4 +
.../EventbridgeConsumerQueuePolicyIT.java | 111 +++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 11 ++
7 files changed, 231 insertions(+), 6 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-eventbridge-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-eventbridge-component.adoc
index 4f51a1054b33..658633df7c2d 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-eventbridge-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-eventbridge-component.adoc
@@ -615,7 +615,9 @@ This is the standard AWS pattern for programmatically
consuming EventBridge even
=== How It Works
1. On startup the consumer creates an SQS queue (unless you provide one via
`queueUrl`).
-2. It sets an SQS queue policy that allows EventBridge to send messages.
+2. It sets an SQS queue policy that allows only the EventBridge rule given by
`ruleName` to send messages (an
+`aws:SourceArn` condition with the ARN of the rule, which the consumer gets
with `DescribeRule`). A queue given with
+`queueUrl` keeps its own policy.
3. It adds the queue as a target of the EventBridge rule specified by
`ruleName`.
4. It polls the SQS queue on schedule, delivering each event into the Camel
route.
5. Successfully processed messages are deleted from the queue; failed messages
remain for retry.
@@ -827,6 +829,7 @@ YAML::
The consumer's IAM principal needs the following permissions:
- `events:PutTargets` and `events:RemoveTargets` on the EventBridge rule
+- `events:DescribeRule` on the EventBridge rule (if auto-creating)
- `sqs:CreateQueue`, `sqs:DeleteQueue`, `sqs:SetQueueAttributes`,
`sqs:GetQueueAttributes` (if auto-creating)
- `sqs:ReceiveMessage`, `sqs:DeleteMessage` on the SQS queue
diff --git
a/components/camel-aws/camel-aws2-eventbridge/src/main/docs/aws2-eventbridge-component.adoc
b/components/camel-aws/camel-aws2-eventbridge/src/main/docs/aws2-eventbridge-component.adoc
index 4f51a1054b33..658633df7c2d 100644
---
a/components/camel-aws/camel-aws2-eventbridge/src/main/docs/aws2-eventbridge-component.adoc
+++
b/components/camel-aws/camel-aws2-eventbridge/src/main/docs/aws2-eventbridge-component.adoc
@@ -615,7 +615,9 @@ This is the standard AWS pattern for programmatically
consuming EventBridge even
=== How It Works
1. On startup the consumer creates an SQS queue (unless you provide one via
`queueUrl`).
-2. It sets an SQS queue policy that allows EventBridge to send messages.
+2. It sets an SQS queue policy that allows only the EventBridge rule given by
`ruleName` to send messages (an
+`aws:SourceArn` condition with the ARN of the rule, which the consumer gets
with `DescribeRule`). A queue given with
+`queueUrl` keeps its own policy.
3. It adds the queue as a target of the EventBridge rule specified by
`ruleName`.
4. It polls the SQS queue on schedule, delivering each event into the Camel
route.
5. Successfully processed messages are deleted from the queue; failed messages
remain for retry.
@@ -827,6 +829,7 @@ YAML::
The consumer's IAM principal needs the following permissions:
- `events:PutTargets` and `events:RemoveTargets` on the EventBridge rule
+- `events:DescribeRule` on the EventBridge rule (if auto-creating)
- `sqs:CreateQueue`, `sqs:DeleteQueue`, `sqs:SetQueueAttributes`,
`sqs:GetQueueAttributes` (if auto-creating)
- `sqs:ReceiveMessage`, `sqs:DeleteMessage` on the SQS queue
diff --git
a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumer.java
b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumer.java
index 54a3450a8dfb..62d50802db3c 100644
---
a/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumer.java
+++
b/components/camel-aws/camel-aws2-eventbridge/src/main/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumer.java
@@ -38,6 +38,7 @@ import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.services.eventbridge.EventBridgeClient;
+import software.amazon.awssdk.services.eventbridge.model.DescribeRuleRequest;
import software.amazon.awssdk.services.eventbridge.model.PutTargetsRequest;
import software.amazon.awssdk.services.eventbridge.model.PutTargetsResponse;
import software.amazon.awssdk.services.eventbridge.model.RemoveTargetsRequest;
@@ -161,6 +162,10 @@ public class EventbridgeConsumer extends
ScheduledBatchPollingConsumer {
queueAutoCreated = false;
queueArn = getQueueArn(queueUrl);
} else if (config.isAutoCreateQueue()) {
+ // The queue policy only lets the rule of this consumer send to
the queue, so look up the rule first: a
+ // missing rule then fails before a queue is created
+ String ruleArn = getRuleArn(ruleName, config.getEventbusName());
+
// Auto-create queue
String queueName
= "camel-eventbridge-" + ruleName + "-" +
UUID.randomUUID().toString().substring(0, 8);
@@ -174,8 +179,8 @@ public class EventbridgeConsumer extends
ScheduledBatchPollingConsumer {
queueAutoCreated = true;
queueArn = getQueueArn(queueUrl);
- // Set queue policy to allow EventBridge to send messages
- String policy = buildQueuePolicy(queueArn);
+ // Set queue policy to allow the EventBridge rule to send messages
+ String policy = buildQueuePolicy(queueArn, ruleArn);
sqsClient.setQueueAttributes(
SetQueueAttributesRequest.builder()
.queueUrl(queueUrl)
@@ -296,12 +301,30 @@ public class EventbridgeConsumer extends
ScheduledBatchPollingConsumer {
return response.attributes().get(QueueAttributeName.QUEUE_ARN);
}
- private String buildQueuePolicy(String queueArn) {
+ private String getRuleArn(String ruleName, String eventBusName) {
+ String ruleArn = getEndpoint().getEventbridgeClient().describeRule(
+ DescribeRuleRequest.builder()
+ .name(ruleName)
+ .eventBusName(eventBusName)
+ .build())
+ .arn();
+ if (ObjectHelper.isEmpty(ruleArn)) {
+ throw new IllegalStateException("Cannot get the ARN of the
EventBridge rule " + ruleName);
+ }
+ return ruleArn;
+ }
+
+ /**
+ * The policy of an auto-created queue: only the EventBridge rule of the
consumer may send messages to the queue
+ * (aws:SourceArn), not every rule of every account.
+ */
+ static String buildQueuePolicy(String queueArn, String ruleArn) {
return "{\"Version\":\"2012-10-17\","
+ "\"Statement\":[{\"Sid\":\"AllowEventBridgeToSendMessage\","
+ "\"Effect\":\"Allow\","
+ "\"Principal\":{\"Service\":\"events.amazonaws.com\"},"
+ "\"Action\":\"sqs:SendMessage\","
- + "\"Resource\":\"" + queueArn + "\"}]}";
+ + "\"Resource\":\"" + queueArn + "\","
+ + "\"Condition\":{\"ArnEquals\":{\"aws:SourceArn\":\"" +
ruleArn + "\"}}}]}";
}
}
diff --git
a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumerTest.java
b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumerTest.java
index 32e254aaa1fd..71687e3e7ea0 100644
---
a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumerTest.java
+++
b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumerTest.java
@@ -25,6 +25,9 @@ import org.apache.camel.ExchangePropertyKey;
import org.apache.camel.Processor;
import org.apache.camel.spi.Synchronization;
import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.apache.camel.util.json.Jsoner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -33,11 +36,14 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import software.amazon.awssdk.services.eventbridge.EventBridgeClient;
+import software.amazon.awssdk.services.eventbridge.model.DescribeRuleRequest;
+import software.amazon.awssdk.services.eventbridge.model.DescribeRuleResponse;
import software.amazon.awssdk.services.eventbridge.model.PutTargetsRequest;
import software.amazon.awssdk.services.eventbridge.model.PutTargetsResponse;
import software.amazon.awssdk.services.eventbridge.model.PutTargetsResultEntry;
import software.amazon.awssdk.services.eventbridge.model.RemoveTargetsRequest;
import software.amazon.awssdk.services.eventbridge.model.RemoveTargetsResponse;
+import
software.amazon.awssdk.services.eventbridge.model.ResourceNotFoundException;
import software.amazon.awssdk.services.sqs.SqsClient;
import software.amazon.awssdk.services.sqs.model.CreateQueueRequest;
import software.amazon.awssdk.services.sqs.model.CreateQueueResponse;
@@ -63,6 +69,7 @@ public class EventbridgeConsumerTest extends CamelTestSupport
{
private static final String TEST_QUEUE_URL =
"https://sqs.us-east-1.amazonaws.com/123456789/camel-eventbridge-test";
private static final String TEST_QUEUE_ARN =
"arn:aws:sqs:us-east-1:123456789:camel-eventbridge-test";
+ private static final String TEST_RULE_ARN =
"arn:aws:events:us-east-1:123456789:rule/test-rule";
private static final String USER_QUEUE_URL =
"https://sqs.us-east-1.amazonaws.com/123456789/user-queue";
private static final String USER_QUEUE_ARN =
"arn:aws:sqs:us-east-1:123456789:user-queue";
@@ -109,6 +116,9 @@ public class EventbridgeConsumerTest extends
CamelTestSupport {
verify(sqsClient, never()).createQueue(any(CreateQueueRequest.class));
verify(sqsClient).getQueueAttributes(any(GetQueueAttributesRequest.class));
+ // a user-provided queue keeps its own policy
+ verify(sqsClient,
never()).setQueueAttributes(any(SetQueueAttributesRequest.class));
+ verify(eventBridgeClient,
never()).describeRule(any(DescribeRuleRequest.class));
ArgumentCaptor<PutTargetsRequest> captor =
ArgumentCaptor.forClass(PutTargetsRequest.class);
verify(eventBridgeClient).putTargets(captor.capture());
@@ -117,6 +127,64 @@ public class EventbridgeConsumerTest extends
CamelTestSupport {
consumer.stop();
}
+ @Test
+ public void testAutoCreatedQueuePolicyOnlyAllowsTheRuleOfTheConsumer()
throws Exception {
+ stubAutoCreateQueue();
+ stubPutTargetsSuccess();
+
+ EventbridgeConsumer consumer = createConsumer("test-rule", null, true,
true);
+ consumer.start();
+
+ ArgumentCaptor<DescribeRuleRequest> describe =
ArgumentCaptor.forClass(DescribeRuleRequest.class);
+ verify(eventBridgeClient).describeRule(describe.capture());
+ assertEquals("test-rule", describe.getValue().name());
+ assertEquals("default", describe.getValue().eventBusName());
+
+ ArgumentCaptor<SetQueueAttributesRequest> captor =
ArgumentCaptor.forClass(SetQueueAttributesRequest.class);
+ verify(sqsClient).setQueueAttributes(captor.capture());
+ assertEquals(TEST_QUEUE_URL, captor.getValue().queueUrl());
+ JsonObject policy = (JsonObject)
Jsoner.deserialize(captor.getValue().attributes().get(QueueAttributeName.POLICY));
+ JsonArray statements = policy.getCollection("Statement");
+ assertEquals(1, statements.size());
+ JsonObject statement = (JsonObject) statements.get(0);
+ assertEquals("Allow", statement.getString("Effect"));
+ assertEquals("events.amazonaws.com",
statement.getMap("Principal").get("Service"));
+ assertEquals("sqs:SendMessage", statement.getString("Action"));
+ assertEquals(TEST_QUEUE_ARN, statement.getString("Resource"));
+ // only the rule of the consumer may send to the queue, not every
EventBridge rule
+ JsonObject condition = (JsonObject) statement.getMap("Condition");
+ assertEquals(Map.of("ArnEquals", Map.of("aws:SourceArn",
TEST_RULE_ARN)), condition);
+
+ consumer.stop();
+ }
+
+ @Test
+ public void testMissingRuleFailsBeforeTheQueueIsCreated() throws Exception
{
+ when(eventBridgeClient.describeRule(any(DescribeRuleRequest.class)))
+ .thenThrow(ResourceNotFoundException.builder().message("Rule
test-rule does not exist.").build());
+
+ EventbridgeConsumer consumer = createConsumer("test-rule", null, true,
true);
+
+ assertThrows(ResourceNotFoundException.class, consumer::start);
+ verify(sqsClient, never()).createQueue(any(CreateQueueRequest.class));
+ verify(eventBridgeClient,
never()).putTargets(any(PutTargetsRequest.class));
+ }
+
+ @Test
+ public void testQueuePolicy() throws Exception {
+ String policy = EventbridgeConsumer.buildQueuePolicy(TEST_QUEUE_ARN,
TEST_RULE_ARN);
+ assertEquals("{\"Version\":\"2012-10-17\","
+ +
"\"Statement\":[{\"Sid\":\"AllowEventBridgeToSendMessage\","
+ + "\"Effect\":\"Allow\","
+ + "\"Principal\":{\"Service\":\"events.amazonaws.com\"},"
+ + "\"Action\":\"sqs:SendMessage\","
+ + "\"Resource\":\"" + TEST_QUEUE_ARN + "\","
+ + "\"Condition\":{\"ArnEquals\":{\"aws:SourceArn\":\"" +
TEST_RULE_ARN + "\"}}}]}",
+ policy);
+ // valid JSON
+ assertInstanceOf(JsonObject.class, Jsoner.deserialize(policy));
+ }
+
@Test
public void testAutoCreateDisabledWithoutQueueUrlFails() throws Exception {
EventbridgeComponent component =
context.getComponent("aws2-eventbridge", EventbridgeComponent.class);
@@ -470,6 +538,8 @@ public class EventbridgeConsumerTest extends
CamelTestSupport {
}
private void stubAutoCreateQueue() {
+ when(eventBridgeClient.describeRule(any(DescribeRuleRequest.class)))
+
.thenReturn(DescribeRuleResponse.builder().name("test-rule").arn(TEST_RULE_ARN).build());
when(sqsClient.createQueue(any(CreateQueueRequest.class)))
.thenReturn(CreateQueueResponse.builder().queueUrl(TEST_QUEUE_URL).build());
stubGetQueueAttributes(TEST_QUEUE_URL, TEST_QUEUE_ARN);
diff --git
a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumerUserQueueTargetTest.java
b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumerUserQueueTargetTest.java
index 7c271a2f2824..c25b978289c0 100644
---
a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumerUserQueueTargetTest.java
+++
b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/EventbridgeConsumerUserQueueTargetTest.java
@@ -24,6 +24,8 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import software.amazon.awssdk.services.eventbridge.EventBridgeClient;
+import software.amazon.awssdk.services.eventbridge.model.DescribeRuleRequest;
+import software.amazon.awssdk.services.eventbridge.model.DescribeRuleResponse;
import software.amazon.awssdk.services.eventbridge.model.PutTargetsRequest;
import software.amazon.awssdk.services.eventbridge.model.PutTargetsResponse;
import software.amazon.awssdk.services.eventbridge.model.RemoveTargetsRequest;
@@ -76,6 +78,8 @@ class EventbridgeConsumerUserQueueTargetTest extends
CamelTestSupport {
.thenReturn(CreateQueueResponse.builder().queueUrl(AUTO_QUEUE_URL).build());
when(sqsClient.setQueueAttributes(any(SetQueueAttributesRequest.class)))
.thenReturn(SetQueueAttributesResponse.builder().build());
+
when(eventBridgeClient.describeRule(any(DescribeRuleRequest.class))).thenReturn(
+
DescribeRuleResponse.builder().arn("arn:aws:events:us-east-1:123456789:rule/test-rule").build());
when(eventBridgeClient.putTargets(any(PutTargetsRequest.class))).thenAnswer(inv
-> {
PutTargetsRequest req = inv.getArgument(0);
for (Target target : req.targets()) {
diff --git
a/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgeConsumerQueuePolicyIT.java
b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgeConsumerQueuePolicyIT.java
new file mode 100644
index 000000000000..00dddaf910ef
--- /dev/null
+++
b/components/camel-aws/camel-aws2-eventbridge/src/test/java/org/apache/camel/component/aws2/eventbridge/localstack/EventbridgeConsumerQueuePolicyIT.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.eventbridge.localstack;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.aws.common.AWSConfigs;
+import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.apache.camel.util.json.Jsoner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import software.amazon.awssdk.services.eventbridge.EventBridgeClient;
+import software.amazon.awssdk.services.eventbridge.model.PutEventsRequestEntry;
+import software.amazon.awssdk.services.eventbridge.model.PutEventsResponse;
+import software.amazon.awssdk.services.sqs.SqsClient;
+import software.amazon.awssdk.services.sqs.model.QueueAttributeName;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * The queue that the consumer creates only accepts the events of its own rule
(aws:SourceArn), and still receives them.
+ */
+@DisabledOnOs(architectures = { "s390x", "ppc64le" },
+ disabledReason = "Needs EventBridge delivering to SQS, as Floci
does; these architectures use LocalStack")
+public class EventbridgeConsumerQueuePolicyIT extends Aws2EventbridgeBase {
+
+ private static final String RULE_NAME = "camel-policy-rule";
+
+ @EndpointInject("mock:result")
+ private MockEndpoint result;
+
+ private String ruleArn;
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ // the rule must exist before the consumer starts
+ try (EventBridgeClient ebClient =
AWSSDKClientUtils.newEventBridgeClient()) {
+ ruleArn = ebClient.putRule(b -> b.name(RULE_NAME)
+ .eventBusName("default")
+ .eventPattern("{\"source\":[\"camel.policy\"]}"))
+ .ruleArn();
+ }
+
+ Properties props = service.getConnectionProperties();
+ String uri = "aws2-eventbridge://default?ruleName=" + RULE_NAME
+ + "®ion=" + props.getProperty(AWSConfigs.REGION)
+ + "&accessKey=RAW(" +
props.getProperty(AWSConfigs.ACCESS_KEY) + ")"
+ + "&secretKey=RAW(" +
props.getProperty(AWSConfigs.SECRET_KEY) + ")"
+ + "&overrideEndpoint=true&uriEndpointOverride=" +
props.getProperty(AWSConfigs.PROTOCOL) + "://"
+ + props.getProperty(AWSConfigs.AMAZON_AWS_HOST)
+ + "&waitTimeSeconds=1&delay=500";
+
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from(uri).to("mock:result");
+ }
+ };
+ }
+
+ @Test
+ public void queueOfTheConsumerOnlyAllowsItsRuleAndReceivesItsEvents()
throws Exception {
+ try (SqsClient sqsClient = AWSSDKClientUtils.newSQSClient()) {
+ List<String> queueUrls = sqsClient.listQueues(b ->
b.queueNamePrefix("camel-eventbridge-" + RULE_NAME))
+ .queueUrls();
+ assertEquals(1, queueUrls.size(), "queues of the consumer: " +
queueUrls);
+ String policy = sqsClient.getQueueAttributes(b ->
b.queueUrl(queueUrls.get(0))
+ .attributeNames(QueueAttributeName.POLICY))
+ .attributes().get(QueueAttributeName.POLICY);
+
+ JsonObject statement = (JsonObject) ((JsonArray) ((JsonObject)
Jsoner.deserialize(policy))
+ .getCollection("Statement")).get(0);
+ assertEquals(ruleArn, ((JsonObject)
statement.getMap("Condition").get("ArnEquals")).getString("aws:SourceArn"));
+ }
+
+ result.expectedMessageCount(1);
+ result.message(0).body().contains("Policy test");
+
+ try (EventBridgeClient ebClient =
AWSSDKClientUtils.newEventBridgeClient()) {
+ PutEventsResponse response = ebClient.putEvents(b ->
b.entries(PutEventsRequestEntry.builder()
+ .eventBusName("default")
+ .source("camel.policy")
+ .detailType("CamelTestEvent")
+ .detail("{\"message\":\"Policy test\"}")
+ .build()));
+ assertEquals(0, response.failedEntryCount());
+ }
+
+ MockEndpoint.assertIsSatisfied(context);
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 5395c7bd2cb4..57f4ab3ac2a6 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -2600,6 +2600,17 @@ milliseconds per request, 14 to 17.5 seconds for 10,000
records), and a record t
next records of its request. A redelivery of the exchange still sends the
whole batch again: see the Batch Producer
section of xref:components::aws2-kinesis-component.adoc[AWS Kinesis].
+=== camel-aws2-eventbridge - the queue the consumer creates accepts only the
events of its rule
+
+With `autoCreateQueue` (the default when no `queueUrl` is given), the policy
of the SQS queue the consumer creates now
+allows `sqs:SendMessage` only for the EventBridge rule of the consumer (an
`aws:SourceArn` condition with the rule
+ARN). Before, the policy allowed `events.amazonaws.com` without a condition,
so any EventBridge rule could send to
+the queue.
+
+To get the rule ARN, the consumer calls `DescribeRule` before it creates the
queue, so the IAM principal of the
+consumer now also needs `events:DescribeRule` on the rule. A rule that does
not exist now fails the consumer start
+before a queue is created. A queue given with `queueUrl` keeps its own policy,
as before.
+
=== camel-azure-storage-blob - copyBlob validates the source account and
container name
`copyBlob` now rejects invalid source account or container names (headers
`CamelAzureStorageBlobSourceBlobAccountName`