Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_s3.Bucket: add_event_notification example doesn't work #27038

Closed
bencaldwell opened this issue Sep 7, 2023 · 5 comments
Closed

aws_s3.Bucket: add_event_notification example doesn't work #27038

bencaldwell opened this issue Sep 7, 2023 · 5 comments
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. documentation This is a problem with documentation. effort/small Small work item – less than a day of effort p2

Comments

@bencaldwell
Copy link

Describe the issue

This is the example from the docs:

# my_lambda: lambda.Function
bucket = s3.Bucket(self, "MyBucket")
bucket.add_event_notification(s3.EventType.OBJECT_CREATED, s3n.LambdaDestination(my_lambda), prefix="home/myusername/*")

cdk synth throws an error from this: TypeError: BucketBase.add_event_notification() got an unexpected keyword argument 'prefix'

The below is what I ended up having to use. Perhaps the example should be changed to something like this:

# my_lambda: lambda.Function
bucket = s3.Bucket(self, "MyBucket")
bucket.add_event_notification(s3.EventType.OBJECT_CREATED, s3n.LambdaDestination(my_lambda), s3.NotificationKeyFilter(prefix="home/myusername/*"))

Links

https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_s3/Bucket.html

@bencaldwell bencaldwell added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Sep 7, 2023
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Sep 7, 2023
@msambol
Copy link
Contributor

msambol commented Sep 7, 2023

Weird, the comment is correct here. Maybe whatever is rending the Python docs has a bug?

@bencaldwell
Copy link
Author

That link just has {prefix: 'home/myusername/*'} - perhaps that doesn't tell what is rendering the python docs that it needs to be a list of s3.NotificationKeyFilter() objects.

@msambol
Copy link
Contributor

msambol commented Sep 7, 2023

@bencaldwell Take a look here: #8100. They mention limitations in Python doc generation.

@khushail khushail added p2 effort/small Small work item – less than a day of effort documentation This is a problem with documentation. and removed documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Sep 7, 2023
@khushail
Copy link
Contributor

khushail commented Sep 7, 2023

Hi @bencaldwell , python and other language docs are generated by jsii-codegen and our original documentation is written in typescript.

Thanks @msambol , you are correct. That's a limitation correctly mentioned.

Here is an actual example of adding event notification in typescript- https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Bucket.html#addwbreventwbrnotificationevent-dest-filters -

public addEventNotification(event: EventType, dest: IBucketNotificationDestination, ...filters: NotificationKeyFilter[]): void

Hope that helps!

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. documentation This is a problem with documentation. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

No branches or pull requests

4 participants