File tree 3 files changed +52
-2
lines changed
3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const S3Identity = z.object({
8
8
} ) ;
9
9
10
10
const S3RequestParameters = z . object ( {
11
- sourceIPAddress : z . string ( ) . ip ( ) ,
11
+ sourceIPAddress : z . union ( [ z . string ( ) . ip ( ) , z . literal ( 's3.amazonaws.com' ) ] ) ,
12
12
} ) ;
13
13
14
14
const S3ResponseElements = z . object ( {
@@ -24,7 +24,7 @@ const S3Message = z.object({
24
24
size : z . number ( ) . optional ( ) ,
25
25
urlDecodedKey : z . string ( ) . optional ( ) ,
26
26
eTag : z . string ( ) . optional ( ) ,
27
- sequencer : z . string ( ) ,
27
+ sequencer : z . string ( ) . optional ( ) , // Only present in PUT and DELETE events
28
28
versionId : z . optional ( z . string ( ) ) ,
29
29
} ) ,
30
30
bucket : z . object ( {
Original file line number Diff line number Diff line change
1
+ {
2
+ "Records" : [
3
+ {
4
+ "eventVersion" : " 2.3" ,
5
+ "eventSource" : " aws:s3" ,
6
+ "awsRegion" : " us-west-2" ,
7
+ "eventTime" : " 1970-01-01T00:00:00.000Z" ,
8
+ "eventName" : " LifecycleExpiration:Delete" ,
9
+ "userIdentity" : {
10
+ "principalId" : " s3.amazonaws.com"
11
+ },
12
+ "requestParameters" : {
13
+ "sourceIPAddress" : " s3.amazonaws.com"
14
+ },
15
+ "responseElements" : {
16
+ "x-amz-request-id" : " C3D13FE58DE4C810" ,
17
+ "x-amz-id-2" : " FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD"
18
+ },
19
+ "s3" : {
20
+ "s3SchemaVersion" : " 1.0" ,
21
+ "configurationId" : " testConfigRule" ,
22
+ "bucket" : {
23
+ "name" : " amzn-s3-demo-bucket" ,
24
+ "ownerIdentity" : {
25
+ "principalId" : " A3NL1KOZZKExample"
26
+ },
27
+ "arn" : " arn:aws:s3:::amzn-s3-demo-bucket"
28
+ },
29
+ "object" : {
30
+ "key" : " expiration/delete" ,
31
+ "sequencer" : " 0055AED6DCD90281E5"
32
+ }
33
+ }
34
+ }
35
+ ]
36
+ }
Original file line number Diff line number Diff line change @@ -97,6 +97,20 @@ describe('Schema: S3', () => {
97
97
expect ( result ) . toStrictEqual ( event ) ;
98
98
} ) ;
99
99
100
+ it ( 'parses an S3 LifeCycle event with a deleted object' , ( ) => {
101
+ // Prepare
102
+ const event = getTestEvent < S3Event > ( {
103
+ eventsPath,
104
+ filename : 's3-lifecycle-event' ,
105
+ } ) ;
106
+
107
+ // Act
108
+ const result = S3Schema . parse ( event ) ;
109
+
110
+ // Assess
111
+ expect ( result ) . toStrictEqual ( event ) ;
112
+ } ) ;
113
+
100
114
it ( 'parses an S3 Object Lambda with an IAM user' , ( ) => {
101
115
// Prepare
102
116
const event = structuredClone ( baseLambdaEvent ) ;
You can’t perform that action at this time.
0 commit comments