Add S3EventSource Not Possible with Existing Bucket
See original GitHub issueI have an existing bucket that I would like to trigger a lambda whenever a zip file is uploaded so that the lambda can unzip it and process the unzipped files.
However, I cannot add S3EventSource to an existing S3 bucket. For example, this fails to compile:
const filesBucket = s3.Bucket.fromBucketName(this, 'SBFilesBucket', props.s3Bucket);
fileUnzipAdaptor.addEventSource(new S3EventSource(filesBucket, {
events: [s3.EventType.OBJECT_CREATED],
filters: [{suffix: 'zip'}] // optional
}));
The error is:
error TS2345: Argument of type 'IBucket' is not assignable to parameter of type 'Bucket'.
Type 'IBucket' is missing the following properties from type 'Bucket': autoCreatePolicy, lifecycleRules, notifications, metrics, and 25 more.
Is this by design? If so, how else can I obtain the desired effect?
Reproduction Steps
const filesBucket = s3.Bucket.fromBucketName(this, 'SBFilesBucket', props.s3Bucket);
fileUnzipAdaptor.addEventSource(new S3EventSource(filesBucket, {
events: [s3.EventType.OBJECT_CREATED],
filters: [{suffix: 'zip'}] // optional
}));
Where props.s3Bucket
is the name of a existing S3 bucket.
Error Log
error TS2345: Argument of type 'IBucket' is not assignable to parameter of type 'Bucket'.
Type 'IBucket' is missing the following properties from type 'Bucket': autoCreatePolicy, lifecycleRules, notifications, metrics, and 25 more.
Environment
- CLI Version :
- Framework Version:
- OS :
- Language :
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:6 (1 by maintainers)
Top Results From Across the Web
AWS CDK - How to add an event notification to an existing S3 ...
I managed to get this working with a custom resource. It's TypeScript, but it should be easily translated to Python: const uploadBucket =...
Read more >class S3EventSource · AWS CDK
class S3EventSource. You are not viewing the latest version. ... Implements IEventSource. Use S3 bucket notifications as an event source for AWS Lambda....
Read more >awslabs/aws-cdk - Gitter
That doesn't work cause bucket is an IBucket type and it needs to be a Bucket type to be an accepted param for...
Read more >Leveraging existing event sources (S3 and CognitoUserPools)
Its very likely your organisation has had an S3 bucket or Cognito User Pool ... infrastructure changes, it not short of downsides as...
Read more >Triggering an AWS Lambda Function For S3 File Uploads
One possible event is the creation of S3 objects (e.g., ... Lambda code 07:53 Adding a unction trigger ( S3 event source )...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this feature should be supported from the beginning
I have same problem now. An stack overflow user solves this problem with
AwsCustomResource
. But I think it is not smart. I would be happy to solve this problem by updating CDK.