S3 - ServerlessSpy


S3 integration subscribes to S3 notification and intercept events. The event has the following properties:

  • eventName (s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectRemoved:Delete, …)
  • key - file name

You can not receive file content (it could be gigabytes 🚚). You have to read it yourself.

Basic example:

await serverlessSpyListener.waitForS3MyBucket()

You can use conditions to wait for a particular event.

await serverlessSpyListener.waitForS3MyBucket({
  condition: (d) => d.key === `${id}.json`,

⚠️Warning: DynamoDB can have only one Lambda subscribed to notification. If your primary stack already uses it, you can not use S3 interception. You should exclude S3 interception in your CDK stack:

  spyS3: false,

Check this test.