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-kamelets.git


The following commit(s) were added to refs/heads/main by this push:
     new 4140d390e chore: aws-eventbridge-source needs events:DescribeRule, its 
queue only accepts its rule, and deleteQueueOnShutdown keeps the queue 
(CAMEL-27360, CAMEL-27378) (#3353)
4140d390e is described below

commit 4140d390e87208dbefb821657914caf73693b00f
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Nov 22 15:49:36 2026 +0100

    chore: aws-eventbridge-source needs events:DescribeRule, its queue only 
accepts its rule, and deleteQueueOnShutdown keeps the queue (CAMEL-27360, 
CAMEL-27378) (#3353)
    
    * chore: aws-eventbridge-source needs events:DescribeRule without queueURL, 
and its queue only accepts the events of its rule (CAMEL-27360)
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
    
    * chore: aws-eventbridge-source deleteQueueOnShutdown keeps its queue, 
which collects the events while it does not run (CAMEL-27378)
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
    
    * chore: the keep-queue test lets Citrus not stop the first run, and checks 
that the second run got the event
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
    
    ---------
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 kamelets/aws-eventbridge-source.kamelet.yaml       | 10 ++-
 .../main/resources/META-INF/kamelets-index.json    |  2 +-
 .../kamelets/aws-eventbridge-source.kamelet.yaml   | 10 ++-
 .../aws-eventbridge-source-keep-route.yaml         | 38 ++++++++++
 ... => aws-eventbridge-source-keep.citrus.it.yaml} | 85 +++++++++++++++-------
 .../aws-eventbridge-source.citrus.it.yaml          |  8 +-
 .../resources/aws/eventbridge/keptQueue.groovy     | 62 ++++++++++++++++
 .../aws/eventbridge/verifyQueuePolicy.groovy       | 42 +++++++++++
 8 files changed, 226 insertions(+), 31 deletions(-)

diff --git a/kamelets/aws-eventbridge-source.kamelet.yaml 
b/kamelets/aws-eventbridge-source.kamelet.yaml
index cb014da2f..f06219897 100644
--- a/kamelets/aws-eventbridge-source.kamelet.yaml
+++ b/kamelets/aws-eventbridge-source.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
 
       Output: the body is the whole EventBridge event, as JSON text: `id` (the 
ID that EventBridge gave the event), `detail-type`, `source`, `account`, 
`time`, `region`, `resources` and `detail`, which holds what the sender of the 
event put in it, such as `{"orderId": "A-1"}`. The 
`CamelAwsEventbridgeMessageId` header is the ID of the SQS message that carried 
the event, and `CamelAwsEventbridgeReceiptHandle` its receipt handle.
 
-      Good to know: the rule must exist on the event bus before the Kamelet 
starts, or it fails to start; its event pattern decides which events arrive. 
Create it in the EventBridge console or with `aws events put-rule`. Without 
`queueURL`, it creates a queue named `camel-eventbridge-` followed by the rule 
name and a random part, and adds it to the rule; when it stops, it removes the 
queue from the rule and deletes it, so the events of the time it does not run 
are lost, and each replica  [...]
+      Good to know: the rule must exist on the event bus before the Kamelet 
starts, or it fails to start, and no queue is created; its event pattern 
decides which events arrive. Create it in the EventBridge console or with `aws 
events put-rule`. Without `queueURL`, it creates a queue whose policy lets only 
this rule send events to it, and adds it to the rule. By default the queue is 
named `camel-eventbridge-` followed by the rule name and a random part, and 
when the Kamelet stops, it rem [...]
     required:
       - eventbusNameOrArn
       - ruleName
@@ -59,9 +59,14 @@ spec:
         pattern: "^[.\\-_A-Za-z0-9]+$"
       queueURL:
         title: Queue URL
-        description: The full address of an SQS queue of your own to receive 
the events through, as the SQS console shows it. Its access policy must let 
EventBridge (`events.amazonaws.com`) send messages to it. It stays a target of 
the rule when the Kamelet stops. When it is not set, a queue is created when 
the Kamelet starts and deleted when it stops.
+        description: The full address of an SQS queue of your own to receive 
the events through, as the SQS console shows it. Its access policy must let 
EventBridge (`events.amazonaws.com`) send messages to it. It stays a target of 
the rule when the Kamelet stops. When it is not set, a queue is created when 
the Kamelet starts, and deleted when it stops unless `deleteQueueOnShutdown` is 
false.
         example: https://sqs.eu-west-1.amazonaws.com/123456789012/orders-events
         type: string
+      deleteQueueOnShutdown:
+        title: Delete Queue On Stop
+        description: Only used without `queueURL`. If true, the queue that the 
Kamelet creates is removed from the rule and deleted when the Kamelet stops, so 
the events of the time it does not run are lost. If false, the queue has a name 
made from the event bus and the rule name and stays a target of the rule, so it 
collects the events while the Kamelet does not run, and the next start reuses 
it.
+        type: boolean
+        default: true
       accessKey:
         title: Access Key
         description: The access key ID of an IAM user, which you create in the 
AWS console under IAM, Users, Security credentials. Use it together with 
`secretKey`. Leave both out when `useDefaultCredentialsProvider` or 
`useProfileCredentialsProvider` is true.
@@ -189,6 +194,7 @@ spec:
       parameters:
         ruleName: "{{ruleName}}"
         queueUrl: "{{?queueURL}}"
+        deleteQueueOnShutdown: "{{deleteQueueOnShutdown}}"
         accessKey: "RAW({{?accessKey}})"
         secretKey: "RAW({{?secretKey}})"
         region: "{{region}}"
diff --git 
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json 
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index 51cec959a..2e1fe6a09 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -125,7 +125,7 @@
     "supportLevel" : "Stable",
     "title" : "AWS Eventbridge Source",
     "summary" : "Receives the events that an Amazon EventBridge rule matches 
on an event bus, one message per event, through an SQS queue that it adds to 
the rule as a target.",
-    "description" : "Receives the events that an Amazon EventBridge rule 
matches on an event bus, one message per event, through an SQS queue that it 
adds to the rule as a target.\n\nUse it to react to the events of your 
applications or of AWS services, such as `Order Shipped` from a shop or a 
change of state of an EC2 instance, without setting up a queue yourself. To 
publish events, use `aws-eventbridge-sink`. For the events of an S3 bucket, 
`aws-s3-event-based-source` reads a queue tha [...]
+    "description" : "Receives the events that an Amazon EventBridge rule 
matches on an event bus, one message per event, through an SQS queue that it 
adds to the rule as a target.\n\nUse it to react to the events of your 
applications or of AWS services, such as `Order Shipped` from a shop or a 
change of state of an EC2 instance, without setting up a queue yourself. To 
publish events, use `aws-eventbridge-sink`. For the events of an S3 bucket, 
`aws-s3-event-based-source` reads a queue tha [...]
     "group" : "AWS Eventbridge",
     "namespace" : "AWS",
     "provider" : "Apache Software Foundation"
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/aws-eventbridge-source.kamelet.yaml
 
b/library/camel-kamelets/src/main/resources/kamelets/aws-eventbridge-source.kamelet.yaml
index cb014da2f..f06219897 100644
--- 
a/library/camel-kamelets/src/main/resources/kamelets/aws-eventbridge-source.kamelet.yaml
+++ 
b/library/camel-kamelets/src/main/resources/kamelets/aws-eventbridge-source.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
 
       Output: the body is the whole EventBridge event, as JSON text: `id` (the 
ID that EventBridge gave the event), `detail-type`, `source`, `account`, 
`time`, `region`, `resources` and `detail`, which holds what the sender of the 
event put in it, such as `{"orderId": "A-1"}`. The 
`CamelAwsEventbridgeMessageId` header is the ID of the SQS message that carried 
the event, and `CamelAwsEventbridgeReceiptHandle` its receipt handle.
 
-      Good to know: the rule must exist on the event bus before the Kamelet 
starts, or it fails to start; its event pattern decides which events arrive. 
Create it in the EventBridge console or with `aws events put-rule`. Without 
`queueURL`, it creates a queue named `camel-eventbridge-` followed by the rule 
name and a random part, and adds it to the rule; when it stops, it removes the 
queue from the rule and deletes it, so the events of the time it does not run 
are lost, and each replica  [...]
+      Good to know: the rule must exist on the event bus before the Kamelet 
starts, or it fails to start, and no queue is created; its event pattern 
decides which events arrive. Create it in the EventBridge console or with `aws 
events put-rule`. Without `queueURL`, it creates a queue whose policy lets only 
this rule send events to it, and adds it to the rule. By default the queue is 
named `camel-eventbridge-` followed by the rule name and a random part, and 
when the Kamelet stops, it rem [...]
     required:
       - eventbusNameOrArn
       - ruleName
@@ -59,9 +59,14 @@ spec:
         pattern: "^[.\\-_A-Za-z0-9]+$"
       queueURL:
         title: Queue URL
-        description: The full address of an SQS queue of your own to receive 
the events through, as the SQS console shows it. Its access policy must let 
EventBridge (`events.amazonaws.com`) send messages to it. It stays a target of 
the rule when the Kamelet stops. When it is not set, a queue is created when 
the Kamelet starts and deleted when it stops.
+        description: The full address of an SQS queue of your own to receive 
the events through, as the SQS console shows it. Its access policy must let 
EventBridge (`events.amazonaws.com`) send messages to it. It stays a target of 
the rule when the Kamelet stops. When it is not set, a queue is created when 
the Kamelet starts, and deleted when it stops unless `deleteQueueOnShutdown` is 
false.
         example: https://sqs.eu-west-1.amazonaws.com/123456789012/orders-events
         type: string
+      deleteQueueOnShutdown:
+        title: Delete Queue On Stop
+        description: Only used without `queueURL`. If true, the queue that the 
Kamelet creates is removed from the rule and deleted when the Kamelet stops, so 
the events of the time it does not run are lost. If false, the queue has a name 
made from the event bus and the rule name and stays a target of the rule, so it 
collects the events while the Kamelet does not run, and the next start reuses 
it.
+        type: boolean
+        default: true
       accessKey:
         title: Access Key
         description: The access key ID of an IAM user, which you create in the 
AWS console under IAM, Users, Security credentials. Use it together with 
`secretKey`. Leave both out when `useDefaultCredentialsProvider` or 
`useProfileCredentialsProvider` is true.
@@ -189,6 +194,7 @@ spec:
       parameters:
         ruleName: "{{ruleName}}"
         queueUrl: "{{?queueURL}}"
+        deleteQueueOnShutdown: "{{deleteQueueOnShutdown}}"
         accessKey: "RAW({{?accessKey}})"
         secretKey: "RAW({{?secretKey}})"
         region: "{{region}}"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source-keep-route.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source-keep-route.yaml
new file mode 100644
index 000000000..81fb63693
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source-keep-route.yaml
@@ -0,0 +1,38 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+# Receives the events of the rule with aws-eventbridge-source through a queue 
that it keeps when it stops, and
+# passes them on to the Citrus HTTP server. The test runs it twice.
+- route:
+    from:
+      uri: "kamelet:aws-eventbridge-source"
+      parameters:
+        eventbusNameOrArn: "{{aws.eventbridge.eventbusName}}"
+        ruleName: "{{aws.eventbridge.ruleName}}"
+        deleteQueueOnShutdown: false
+        overrideEndpoint: true
+        uriEndpointOverride: "{{aws.uriEndpointOverride}}"
+        accessKey: "{{aws.accessKey}}"
+        secretKey: "{{aws.secretKey}}"
+        region: "{{aws.region}}"
+        waitTimeSeconds: 1
+      steps:
+        - setHeader:
+            name: X-Run
+            constant: "{{run.name}}"
+        - to:
+            uri: "{{http.sink.url}}/kept"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source.citrus.it.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source-keep.citrus.it.yaml
similarity index 51%
copy from 
tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source.citrus.it.yaml
copy to 
tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source-keep.citrus.it.yaml
index 47ba76247..557f65f90 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source.citrus.it.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source-keep.citrus.it.yaml
@@ -15,9 +15,9 @@
 # limitations under the License.
 # ---------------------------------------------------------------------------
 
-name: aws-eventbridge-source-test
-# aws-eventbridge-source receives the event that the rule matches, as the 
whole EventBridge event in JSON text,
-# and not the event that the rule does not match, which was put on the bus 
first
+name: aws-eventbridge-source-keep-test
+# aws-eventbridge-source with deleteQueueOnShutdown false keeps its queue, and 
the queue stays a target of the rule,
+# when it stops: the queue collects the event put on the bus while it does not 
run, and the next start reuses it
 variables:
   - name: "aws.eventbridge.eventbusName"
     value: "orders"
@@ -26,7 +26,6 @@ variables:
   - name: "aws.eventbridge.eventSource"
     value: "com.example.shop"
 actions:
-  # Create AWS infrastructure (Floci container)
   - testcontainers:
       start:
         localstack:
@@ -38,53 +37,82 @@ actions:
       http:
         url: "${CITRUS_TESTCONTAINERS_LOCALSTACK_SERVICE_URL}"
 
-  # The event bus and the rule, which matches the events of type Order Shipped
   - groovy:
       script:
         file: "aws/eventbridge/setupEventBridgeRule.groovy"
 
+  # The first run creates the queue, then stops (the test stops it, so Citrus 
must not stop it at the end)
   - camel:
       cli:
         run:
+          autoRemove: false
           integration:
-            file: "aws/eventbridge/aws-eventbridge-source-route.yaml"
+            name: "eventbridge-keep-first"
+            file: "aws/eventbridge/aws-eventbridge-source-keep-route.yaml"
             systemProperties:
               properties:
+                - name: "run.name"
+                  value: "first"
                 - name: "aws.eventbridge.eventbusName"
                   value: "${aws.eventbridge.eventbusName}"
                 - name: "aws.eventbridge.ruleName"
                   value: "${aws.eventbridge.ruleName}"
-                - name: "aws.eventbridge.eventSource"
-                  value: "${aws.eventbridge.eventSource}"
               file: "aws/floci.properties"
+  - camel:
+      cli:
+        verify:
+          integration: "eventbridge-keep-first"
+          logMessage: "Auto-created SQS queue"
+  - camel:
+      cli:
+        stop:
+          integration: "eventbridge-keep-first"
 
-  # The first event that arrives is the one the rule matches: the body is the 
whole event, as JSON text
+  # The queue is still there, and still a target of the rule: an event put on 
the bus now goes into it
+  - createVariables:
+      variables:
+        - name: "putEvent"
+          value: "true"
+  - groovy:
+      script:
+        file: "aws/eventbridge/keptQueue.groovy"
+
+  # The second run reuses the queue, and gets the event put while no 
integration ran
+  - camel:
+      cli:
+        run:
+          integration:
+            name: "eventbridge-keep-second"
+            file: "aws/eventbridge/aws-eventbridge-source-keep-route.yaml"
+            systemProperties:
+              properties:
+                - name: "run.name"
+                  value: "second"
+                - name: "aws.eventbridge.eventbusName"
+                  value: "${aws.eventbridge.eventbusName}"
+                - name: "aws.eventbridge.ruleName"
+                  value: "${aws.eventbridge.ruleName}"
+              file: "aws/floci.properties"
+  - camel:
+      cli:
+        verify:
+          integration: "eventbridge-keep-second"
+          logMessage: "Auto-created SQS queue"
   - http:
       server: "awsSinkServer"
       receiveRequest:
         POST:
-          path: "/result"
+          path: "/kept"
+          # the second run got it, not the first one while it stopped
           headers:
-            - name: "X-Body-Type"
-              value: 'java.lang.String'
-            - name: "X-Content-Type"
-              value: 'ct='
-            - name: "X-Message-Id"
-              value: '@matches(''[0-9a-f-]{36}'')@'
-            - name: "X-Receipt-Handle"
-              value: '@matches(''.+'')@'
+            - name: "X-Run"
+              value: "second"
         validate:
           - jsonPath:
-              - expression: '$.id'
-                value: '@matches(''[0-9a-f-]{36}'')@'
               - expression: '$[''detail-type'']'
                 value: 'Order Shipped'
-              - expression: '$.source'
-                value: '${aws.eventbridge.eventSource}'
-              - expression: '$.resources[0]'
-                value: 'arn:aws:s3:::orders'
               - expression: '$.detail.orderId'
-                value: 'A-1'
+                value: 'A-2'
   - http:
       server: "awsSinkServer"
       sendResponse:
@@ -94,3 +122,10 @@ actions:
           version: "HTTP/1.1"
           body:
             data: "OK"
+  - createVariables:
+      variables:
+        - name: "putEvent"
+          value: "false"
+  - groovy:
+      script:
+        file: "aws/eventbridge/keptQueue.groovy"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source.citrus.it.yaml
 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source.citrus.it.yaml
index 47ba76247..3d88d2edb 100644
--- 
a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source.citrus.it.yaml
+++ 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/aws-eventbridge-source.citrus.it.yaml
@@ -17,7 +17,8 @@
 
 name: aws-eventbridge-source-test
 # aws-eventbridge-source receives the event that the rule matches, as the 
whole EventBridge event in JSON text,
-# and not the event that the rule does not match, which was put on the bus 
first
+# and not the event that the rule does not match, which was put on the bus 
first; the queue it created only
+# accepts the events of the rule
 variables:
   - name: "aws.eventbridge.eventbusName"
     value: "orders"
@@ -94,3 +95,8 @@ actions:
           version: "HTTP/1.1"
           body:
             data: "OK"
+
+  # The queue that the Kamelet created only accepts the events of its rule
+  - groovy:
+      script:
+        file: "aws/eventbridge/verifyQueuePolicy.groovy"
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/keptQueue.groovy
 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/keptQueue.groovy
new file mode 100644
index 000000000..2d4cd8d1f
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/keptQueue.groovy
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+// The queue that aws-eventbridge-source keeps (deleteQueueOnShutdown false): 
there is exactly one queue for the
+// rule, it is still a target of the rule, and, when the variable 
aws.eventbridge.keptQueue is set, it is that
+// queue. Sets aws.eventbridge.keptQueue to its URL. With putEvent set to 
true, it then puts an event that the
+// rule matches on the bus.
+
+import org.citrusframework.api.actions.testcontainers.aws2.AwsService
+import org.citrusframework.testcontainers.aws2.LocalStackContainer
+import software.amazon.awssdk.services.eventbridge.EventBridgeClient
+import software.amazon.awssdk.services.eventbridge.model.PutEventsRequestEntry
+import software.amazon.awssdk.services.sqs.SqsClient
+import software.amazon.awssdk.services.sqs.model.QueueAttributeName
+
+LocalStackContainer container = 
context.getReferenceResolver().resolve(LocalStackContainer.class)
+EventBridgeClient eventBridgeClient = 
container.getClient(AwsService.EVENT_BRIDGE)
+SqsClient sqsClient = container.getClient(AwsService.SQS)
+
+def queueUrls = sqsClient.listQueues(b -> 
b.queueNamePrefix('camel-eventbridge-${aws.eventbridge.ruleName}-')).queueUrls()
+if (queueUrls.size() != 1) {
+    throw new IllegalStateException('Expected one queue for the rule but got: 
' + queueUrls)
+}
+def queueUrl = queueUrls[0]
+if (context.getVariables().containsKey('aws.eventbridge.keptQueue') && 
context.getVariable('aws.eventbridge.keptQueue') != queueUrl) {
+    throw new IllegalStateException('Expected the queue ' + 
context.getVariable('aws.eventbridge.keptQueue') + ' but got: ' + queueUrl)
+}
+context.setVariable('aws.eventbridge.keptQueue', queueUrl)
+
+def queueArn = sqsClient.getQueueAttributes(b -> 
b.queueUrl(queueUrl).attributeNames(QueueAttributeName.QUEUE_ARN))
+        .attributes().get(QueueAttributeName.QUEUE_ARN)
+def targets = eventBridgeClient.listTargetsByRule(b -> 
b.rule('${aws.eventbridge.ruleName}')
+        .eventBusName('${aws.eventbridge.eventbusName}')).targets().collect { 
it.arn() }
+if (targets != [queueArn]) {
+    throw new IllegalStateException('Expected the target ' + queueArn + ' on 
the rule but got: ' + targets)
+}
+
+if (context.getVariables().containsKey('putEvent') && 
context.getVariable('putEvent') == 'true') {
+    def response = eventBridgeClient.putEvents(b -> 
b.entries(PutEventsRequestEntry.builder()
+            .eventBusName('${aws.eventbridge.eventbusName}')
+            .source('${aws.eventbridge.eventSource}')
+            .detailType('Order Shipped')
+            .detail('{"orderId": "A-2"}')
+            .build()))
+    if (response.failedEntryCount() != 0) {
+        throw new IllegalStateException('Failed to put the event: ' + 
response.entries())
+    }
+}
diff --git 
a/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/verifyQueuePolicy.groovy
 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/verifyQueuePolicy.groovy
new file mode 100644
index 000000000..bdb309c03
--- /dev/null
+++ 
b/tests/camel-kamelets-itest/src/test/resources/aws/eventbridge/verifyQueuePolicy.groovy
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+// The queue that aws-eventbridge-source created for the rule has a policy 
that lets only that rule send to it:
+// an aws:SourceArn condition with the ARN of the rule.
+
+import org.citrusframework.api.actions.testcontainers.aws2.AwsService
+import org.citrusframework.testcontainers.aws2.LocalStackContainer
+import software.amazon.awssdk.services.eventbridge.EventBridgeClient
+import software.amazon.awssdk.services.sqs.SqsClient
+import software.amazon.awssdk.services.sqs.model.QueueAttributeName
+
+LocalStackContainer container = 
context.getReferenceResolver().resolve(LocalStackContainer.class)
+EventBridgeClient eventBridgeClient = 
container.getClient(AwsService.EVENT_BRIDGE)
+SqsClient sqsClient = container.getClient(AwsService.SQS)
+
+def ruleArn = eventBridgeClient.describeRule(b -> 
b.name('${aws.eventbridge.ruleName}')
+        .eventBusName('${aws.eventbridge.eventbusName}')).arn()
+
+def queueUrls = sqsClient.listQueues(b -> 
b.queueNamePrefix('camel-eventbridge-${aws.eventbridge.ruleName}-')).queueUrls()
+if (queueUrls.size() != 1) {
+    throw new IllegalStateException('Expected one queue for the rule but got: 
' + queueUrls)
+}
+def policy = sqsClient.getQueueAttributes(b -> 
b.queueUrl(queueUrls[0]).attributeNames(QueueAttributeName.POLICY))
+        .attributes().get(QueueAttributeName.POLICY)
+if (policy == null || !policy.contains('"aws:SourceArn":"' + ruleArn + '"')) {
+    throw new IllegalStateException('The queue policy does not limit the 
senders to the rule ' + ruleArn + ': ' + policy)
+}

Reply via email to