The S3 event

In the previous chapter, we configured S3 to trigger a Lambda function when a new file is added to a bucket and its name matches certain rules. The same configuration can be applied here using the following configuration in our serverless.yml file:

    functions:
processLog:
handler: handler.processLog
events:
- s3:
bucket: my-bucket-name
event: s3:ObjectCreated:*
rules:
- prefix: logs/
- suffix: .txt
The bucket name needs to be a new one. Due to limitations, you can't add events to an existing bucket.