mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(s3): emit API reasons and bucket resources in EventBridge events (#9141)
* fix(s3): emit API reasons and bucket resources in EventBridge events * test(s3): clean up EventBridge fixtures after failures * fix(s3): map deletion and annotation events and reuse queue fixture
This commit is contained in:
1 parent
0400332432
commit
1037f592fe
4 files changed
+251
-24
No files matched your search
@@ -7399,13 +7399,14 @@ public class S3Service implements Resettable, ResourceProvider {
|
||||
|
||||
if (config.isEventBridgeEnabled() && eventBridgeService != null) {
|
||||
try {
|
||||
String detailType = eventName.startsWith("ObjectCreated") ? "Object Created"
|
||||
: eventName.startsWith("ObjectAnnotation") ? "Object Annotation"
|
||||
: "Object Deleted";
|
||||
Map<String, Object> entry = new java.util.HashMap<>();
|
||||
entry.put("Source", "aws.s3");
|
||||
entry.put("DetailType", detailType);
|
||||
entry.put("Detail", buildS3EventBridgeDetail(bucketName, key, eventName, obj, region));
|
||||
String detailType = switch (eventName) {
|
||||
case "ObjectAnnotation:Put" -> "Object Annotation Created";
|
||||
case "ObjectAnnotation:Delete" -> "Object Annotation Removed";
|
||||
default -> eventName.startsWith("ObjectCreated") ? "Object Created" : "Object Deleted";
|
||||
};
|
||||
Map<String, Object> entry = EventBridgeService.serviceEventEntry("aws.s3", detailType,
|
||||
buildS3EventBridgeDetail(bucketName, key, eventName, obj, region),
|
||||
S3ResourceArns.bucket(bucketPartition(bucketName), bucketName));
|
||||
eventBridgeService.putEvents(List.of(entry), region);
|
||||
LOG.debugv("Fired S3 event {0} to EventBridge default bus", eventName);
|
||||
} catch (Exception e) {
|
||||
@@ -7450,9 +7451,18 @@ public class S3Service implements Resettable, ResourceProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/** The EventBridge {@code reason}: {@code Lifecycle Expiration} for a deletion by a lifecycle rule. */
|
||||
/** EventBridge names the API rather than the classic notification event. */
|
||||
private static String eventBridgeReason(String eventName) {
|
||||
return isLifecycleEvent(eventName) ? "Lifecycle Expiration" : eventName;
|
||||
return switch (eventName) {
|
||||
case "ObjectCreated:Put" -> "PutObject";
|
||||
case "ObjectCreated:Post" -> "POST Object";
|
||||
case "ObjectCreated:Copy" -> "CopyObject";
|
||||
case "ObjectCreated:CompleteMultipartUpload" -> "CompleteMultipartUpload";
|
||||
case "ObjectRemoved:Delete", "ObjectRemoved:DeleteMarkerCreated" -> "DeleteObject";
|
||||
case "ObjectAnnotation:Put" -> "PutObjectAnnotation";
|
||||
case "ObjectAnnotation:Delete" -> "DeleteObjectAnnotation";
|
||||
default -> isLifecycleEvent(eventName) ? "Lifecycle Expiration" : eventName;
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean isLifecycleEvent(String eventName) {
|
||||
|
||||
Reference in new issue
Block a user