File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ type S3EventRecord struct {
2525 ResponseElements map [string ]string `json:"responseElements"`
2626 S3 S3Entity `json:"s3"`
2727 GlacierEventData * S3GlacierEventData `json:"glacierEventData,omitempty"`
28+ RestoreEventData * S3RestoreEventData `json:"restoreEventData,omitempty"`
2829 ReplicationEventData * S3ReplicationEventData `json:"replicationEventData,omitempty"`
2930}
3031
Original file line number Diff line number Diff line change @@ -87,6 +87,31 @@ func TestS3GlacierEventMarshaling(t *testing.T) {
8787 assert .JSONEq (t , string (inputJSON ), string (outputJSON ))
8888}
8989
90+ func TestS3RestoreEventMarshaling (t * testing.T ) {
91+ // 1. read JSON from file
92+ inputJSON := test .ReadJSONFromFile (t , "./testdata/s3-restore-event.json" )
93+
94+ // 2. de-serialize into Go object
95+ var inputEvent S3Event
96+ if err := json .Unmarshal (inputJSON , & inputEvent ); err != nil {
97+ t .Errorf ("could not unmarshal event. details: %v" , err )
98+ }
99+
100+ // 3. verify restoreEventData is correctly parsed
101+ if inputEvent .Records [0 ].RestoreEventData == nil {
102+ t .Error ("restoreEventData should not be nil" )
103+ }
104+
105+ // 4. serialize to JSON
106+ outputJSON , err := json .Marshal (inputEvent )
107+ if err != nil {
108+ t .Errorf ("could not marshal event. details: %v" , err )
109+ }
110+
111+ // 5. check result
112+ assert .JSONEq (t , string (inputJSON ), string (outputJSON ))
113+ }
114+
90115func TestS3ReplicationEventMarshaling (t * testing.T ) {
91116 // 1. read JSON from file
92117 inputJSON := test .ReadJSONFromFile (t , "./testdata/s3-replication-event.json" )
Original file line number Diff line number Diff line change 1+ {
2+ "Records" : [
3+ {
4+ "eventVersion" : " 2.1" ,
5+ "eventSource" : " aws:s3" ,
6+ "awsRegion" : " us-west-2" ,
7+ "eventTime" : " 2023-05-10T15:00:00.123Z" ,
8+ "eventName" : " s3:ObjectRestore:Completed" ,
9+ "userIdentity" : {
10+ "principalId" : " EXAMPLE"
11+ },
12+ "requestParameters" : {
13+ "sourceIPAddress" : " 127.0.0.1"
14+ },
15+ "responseElements" : {
16+ "x-amz-request-id" : " EXAMPLE123456789" ,
17+ "x-amz-id-2" : " EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH"
18+ },
19+ "s3" : {
20+ "s3SchemaVersion" : " 1.0" ,
21+ "configurationId" : " testConfigRule" ,
22+ "bucket" : {
23+ "name" : " example-bucket" ,
24+ "ownerIdentity" : {
25+ "principalId" : " EXAMPLE"
26+ },
27+ "arn" : " arn:aws:s3:::example-bucket"
28+ },
29+ "object" : {
30+ "key" : " glacier%2Dtest.txt" ,
31+ "urlDecodedKey" : " glacier-test.txt" ,
32+ "size" : 1024 ,
33+ "versionId" : " abcdeH0Xp66ep__QDjR76LK7Gc9X4wKO" ,
34+ "eTag" : " 0123456789abcdef0123456789abcdef" ,
35+ "sequencer" : " 0A1B2C3D4E5F678901"
36+ }
37+ },
38+ "restoreEventData" : {
39+ "lifecycleRestorationExpiryTime" : " 2023-05-17T15:00:00.456Z" ,
40+ "lifecycleRestoreStorageClass" : " STANDARD"
41+ }
42+ }
43+ ]
44+ }
You can’t perform that action at this time.
0 commit comments