Skip to content

Commit 4d11dff

Browse files
author
cgohlke
committed
clarify s3 routing
1 parent b584cbc commit 4d11dff

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ If more than one route matches, only the **first** is used!
181181
182182
183183
Lambdas can be triggered by S3 events. The router now supports these events.
184-
With the router it is very easy and flexible to connect a lambda to different s3 sources (different buckets). The following possibilities are available:
184+
With the router it is very easy and flexible to connect a lambda to different s3 sources (different buckets). The following configurations are available:
185185
186-
- bucketName: By specifying a fixed _bucketName_ all s3 events with this bucket name are forwarded to a certain action. Instead of a fixed bucket a _RegExp_ is also possible.
186+
- bucketName: By specifying a fixed _bucketName_ all s3 records with this bucket name are forwarded to a certain action. Instead of a fixed bucket a _RegExp_ is also possible.
187187
- eventName: By configuring the [S3 event name](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types) the routing can be further restricted. A _RegExp_ is also possible here.
188188
- objectKeyPrefix: fixed string as an prefix of an object key (but not an RegExp). Is useful if you want to organize your bucket in subfolder.
189189
190-
A combination of bucketName, eventName and objectKeyPrefix is possible. If no _bucketName_, _eventName_ and _objectKeyPrefix_ is configured, all s3 events are forwarded to the action.
190+
A combination of bucketName, eventName and objectKeyPrefix is possible. If no _bucketName_, _eventName_ and _objectKeyPrefix_ is configured, all records of s3 events are forwarded to the action.
191191
192-
The action method will be called with the [S3Event Structure](https://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html)
192+
The action method will be called with the records of the [S3Event Structure](https://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html)
193193
194194
The following examples demonstrates the most use cases:
195195
@@ -201,55 +201,55 @@ exports.handler = router.handler({
201201
routes: [
202202
{
203203
//match every s3 record to this action
204-
action: (event, context) => console.log(event.s3.object.key, event.eventName)
204+
action: (record, context) => console.log(record.s3.object.key, record.eventName)
205205
},
206206
{
207207
//match s3 events which created, bucket name is whitelisted here
208208
eventName: 'ObjectCreated:Put',
209-
action: (event, context) => console.log(event.s3.object.key, event.eventName)
209+
action: (record, context) => console.log(record.s3.object.key, record.eventName)
210210
},
211211
{
212212
//event name is an regex: match 'ObjectCreated:Put' or 'ObjectCreated:Copy'
213213
eventName: /ObjectCreated:*/,
214-
action: (event, context) => console.log(event.s3.object.key, event.eventName)
214+
action: (record, context) => console.log(record.s3.object.key, record.eventName)
215215
},
216216
{
217217
//exact name of bucket 'myBucket', event name is whitelisted and will not be checked
218218
bucketName: 'myBucket',
219-
action: (event, context) => console.log(event.s3.object.key, event.eventName)
219+
action: (record, context) => console.log(record.s3.object.key, record.eventName)
220220
},
221221
{
222222
//regex of bucket name (all buckets started with 'bucket-dev-' will be machted
223223
bucketName: /^bucket-dev-.*/,
224-
action: (event, context) => console.log(event.s3.object.key, event.eventName)
224+
action: (record, context) => console.log(record.s3.object.key, record.eventName)
225225
},
226226
{
227227
//action only will be called if bucket and event matched to the given regex
228228
bucketName: /bucket-dev-.*/,
229229
eventName: /ObjectCreated:*/,
230-
action: (event, context) => console.log(event.s3.object.key, event.eventName)
230+
action: (record, context) => console.log(event.s3.object.key, record.eventName)
231231
},
232232
{
233233
//action only will be called if bucket and event matched to the given fixed string
234234
bucketName: 'bucket',
235235
eventName: 'ObjectRemoved:Delete',
236-
action: (event, context) => console.log(event.s3.object.key, event.eventName)
236+
action: (record, context) => console.log(event.s3.object.key, record.eventName)
237237
},
238238
{
239239
//match if s3 events comes from Bucket 'bucket' with event 'ObjectRemoved:Delete'
240240
// and the object key starts with /upload
241241
objectKeyPrefix: '/upload',
242242
bucketName: 'bucket',
243243
eventName: 'ObjectRemoved:Delete',
244-
action: (event, context) => console.log(event.s3.object.key, event.eventName)
244+
action: (record, context) => console.log(record.s3.object.key, record.eventName)
245245
}
246246
],
247247
debug: true
248248
}
249249
});
250250
```
251251
252-
Per s3 event there can be several entries per event. Than the action methods are called one after the other. The result is an array with objects insides.
252+
Per s3 event there can be several records per event. The action methods are called one after the other record. The result of the action method is an array with objects insides.
253253
254254
### Custom response
255255

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface S3Route {
4141
bucketName?: string | RegExp;
4242
eventName?: string | RegExp;
4343
objectKeyPrefix?: string;
44-
action: (s3Event: any[], context: any) => any;
44+
action: (s3Record: any[], context: any) => any;
4545
}
4646

4747
export interface S3Config {

0 commit comments

Comments
 (0)