# S3

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:

```typescript
await serverlessSpyListener.waitForS3MyBucket()
```

You can use conditions to wait for a particular event.

```typescript
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](./CDK_construct.md):**
```typescript
serverlessSpy.spy({
  spyS3: false,
});
```

Check [this test](https://github.com/ServerlessLife/serverless-spy/blob/main/test/cdk/test/lambdaToS3.test.ts){:target="_blank"}.