(aws-lambda-event-sources): `S3EventSource` should take `IBucket` instead of `Bucket`
See original GitHub issueReproduction Steps
Cannot import an existing s3 bucket when creating Lambda s3 events:
aws_s3.Bucket.from_bucket_name(...)
oraws_s3.Bucket.from_bucket_arn(...)
, etc. returnsaws_s3.IBucket
type- However,
aws_lambda_event_sources.S3EventSource
only takesaws_s3.Bucket
type as a parameter - Note:
aws_s3.Bucket
implementsaws_s3.IBucket
Error Log
File "/usr/local/lib/python3.6/site-packages/jsii/_runtime.py", line 66, in __call__
inst = super().__call__(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/aws_cdk/aws_lambda_event_sources/__init__.py", line 199, in __init__
jsii.create(S3EventSource, self, [bucket, props])
File "/usr/local/lib/python3.6/site-packages/jsii/_kernel/__init__.py", line 208, in create
overrides=overrides,
File "/usr/local/lib/python3.6/site-packages/jsii/_kernel/providers/process.py", line 331, in create
return self._process.send(request, CreateResponse)
File "/usr/local/lib/python3.6/site-packages/jsii/_kernel/providers/process.py", line 316, in send
raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Object of type @aws-cdk/aws-s3.IBucket is not convertible to @aws-cdk/aws-s3.Bucket
Environment
- CLI Version : v1.10.1
- Framework Version: v1.10.1
- OS : Mac OS
- Language : Python
Other
aws_lambda_event_sources.S3EventSource
should take aws_s3.IBucket
as a parameter’s type.
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 4 years ago
- Reactions:27
- Comments:34 (8 by maintainers)
Top Results From Across the Web
Lookup S3 Bucket and add a trigger to invoke a lambda
This is why the event source uses s3.Bucket instead of s3.IBucket. You could use onPutObject: const bucket = s3.Bucket.
Read more >class S3EventSource · AWS CDK
Use S3 bucket notifications as an event source for AWS Lambda. Example. import * as eventsources from '@aws-cdk/aws-lambda- ...
Read more >aws-cdk/aws-lambda-event-sources module
You can write Lambda functions to process S3 bucket events, such as the object-created or object-deleted events. For example, when a user uploads...
Read more >Using AWS Lambda with Amazon S3
You can use Lambda to process event notifications from Amazon Simple Storage ... You configure notification settings on a bucket, and grant Amazon...
Read more >aws-cdk/aws-s3 module - AWS Documentation
Most of the time, you won't have to manipulate the bucket policy directly. Instead, buckets have "grant" methods called to give prepackaged sets...
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
Since cdk 1.110.0, this is possible for existing buckets using
IBucket.add_event_notification
as @ThomasKiec mentioned.Here’s an example for reference:
The enhancement for this was merged in this PR: https://github.com/aws/aws-cdk/pull/15158
Any update for this issue?