diff --git a/src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java b/src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java index dede10cecc..b3f5d6abaa 100644 --- a/src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java +++ b/src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java @@ -1626,7 +1626,7 @@ public class S3Service { for (QueueNotification qn : config.getQueueConfigurations()) { if (qn.events().stream().anyMatch(p -> matchesEvent(p, eventName)) && qn.matchesKey(key)) { try { - sqsService.sendMessage(sqsUrlFromArn(qn.queueArn()), eventJson, 0); + sqsService.sendMessage(sqsUrlFromArn(qn.queueArn()), eventJson, 0, extractRegionFromArn(qn.queueArn())); LOG.debugv("Fired S3 event {0} to SQS {1}", eventName, qn.queueArn()); } catch (Exception e) { LOG.warnv("Failed to deliver S3 event to SQS {0}: {1}", qn.queueArn(), e.getMessage()); diff --git a/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java index 1c8b75baab..23097ef3e1 100644 --- a/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java @@ -1343,6 +1343,72 @@ class S3IntegrationTest { @Test @Order(94) + void notificationDeliveredToQueueInDifferentRegion() { + String sqsAuth = "Credential=AKID/20260507/ap-southeast-2/s3/aws4_request"; + + String queueUrl = given() + .header("Authorization", sqsAuth) + .contentType("application/x-www-form-urlencoded") + .formParam("Action", "CreateQueue") + .formParam("QueueName", "notif-test-queue") + .when() + .post("/") + .then() + .statusCode(200) + .extract().xmlPath().getString("CreateQueueResponse.CreateQueueResult.QueueUrl"); + + try { + given() + .contentType("application/xml") + .queryParam("notification", "") + .body(""" + + + sqs-notif + arn:aws:sqs:ap-southeast-2:000000000000:notif-test-queue + s3:ObjectCreated:* + + + """) + .when() + .put("/notif-test-bucket") + .then() + .statusCode(200); + + given() + .contentType("text/plain") + .body("hello") + .when() + .put("/notif-test-bucket/file.txt") + .then() + .statusCode(200); + + given() + .header("Authorization", sqsAuth) + .contentType("application/x-www-form-urlencoded") + .formParam("Action", "ReceiveMessage") + .formParam("QueueUrl", queueUrl) + .formParam("MaxNumberOfMessages", "1") + .when() + .post("/") + .then() + .statusCode(200) + .body( + "ReceiveMessageResponse.ReceiveMessageResult.Message.Body", + allOf(containsString("notif-test-bucket"), containsString("file.txt")) + ); + } finally { + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", sqsAuth) + .formParam("Action", "DeleteQueue") + .formParam("QueueUrl", queueUrl) + .post("/"); + } + } + + @Test + @Order(95) void cleanupNotificationBucket() { given().delete("/notif-test-bucket"); }