File tree Expand file tree Collapse file tree 3 files changed +52
-2
lines changed
Expand file tree Collapse file tree 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({
88} ) ;
99
1010const S3RequestParameters = z . object ( {
11- sourceIPAddress : z . string ( ) . ip ( ) ,
11+ sourceIPAddress : z . union ( [ z . string ( ) . ip ( ) , z . literal ( 's3.amazonaws.com' ) ] ) ,
1212} ) ;
1313
1414const S3ResponseElements = z . object ( {
@@ -24,7 +24,7 @@ const S3Message = z.object({
2424 size : z . number ( ) . optional ( ) ,
2525 urlDecodedKey : z . string ( ) . optional ( ) ,
2626 eTag : z . string ( ) . optional ( ) ,
27- sequencer : z . string ( ) ,
27+ sequencer : z . string ( ) . optional ( ) , // Only present in PUT and DELETE events
2828 versionId : z . optional ( z . string ( ) ) ,
2929 } ) ,
3030 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', () => {
9797 expect ( result ) . toStrictEqual ( event ) ;
9898 } ) ;
9999
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+
100114 it ( 'parses an S3 Object Lambda with an IAM user' , ( ) => {
101115 // Prepare
102116 const event = structuredClone ( baseLambdaEvent ) ;
You can’t perform that action at this time.
0 commit comments