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

[S3] add event notification creates BucketNotificationsHandler lambda #9890

Closed
RishiKapadia20 opened this issue Aug 21, 2020 · 2 comments
Closed
Assignees
Labels
@aws-cdk/aws-s3 Related to Amazon S3 closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@RishiKapadia20
Copy link

❓ General Issue

The Question

I am trying to add a event notification to my s3 bucket which will cause a lambda to be invoked, however looking what resources that are created I can see that it's creating a new lambda called BucketNotificationsHandler. I don't understand why this resource is being made. How can I just point my buckets to just trigger an existing lambda without creating random resources?

Code:

        bucket = aws_s3.Bucket(
            self,
            id=self.id,
            bucket_name=self.bucket_name,
            encryption=aws_s3.BucketEncryption.S3_MANAGED
        )

        lambda_function = aws_lambda.Function.from_function_arn(
            self,
            id=lambda_name,
            function_arn=f"arn:aws:lambda:{aws_region}:{aws_account}:function:{lambda_name}"
        )

        lambda_destination = aws_s3_notifications.LambdaDestination(lambda_function)

        bucket.add_event_notification(
            aws_s3.EventType.OBJECT_CREATED,
            lambda_destination,
            aws_s3.NotificationKeyFilter(suffix=suffix_value)
        )

Resources being created:

[+] AWS::S3::Bucket 
[+] Custom::S3BucketNotifications 
[+] AWS::IAM::Role BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Role BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC 
[+] AWS::IAM::Policy BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Role/DefaultPolicy BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleDefaultPolicy2CF63D36 
[+] AWS::Lambda::Function BucketNotificationsHandler050a0587b7544547bf325f094a3db834 BucketNotificationsHandler050a0587b7544547bf325f094a3db8347ECC3691 

Environment

  • CDK CLI Version: 1.46.0
  • Module Version:
  • Node.js Version: v12.6.0
  • OS: OSX Mojave
  • Language (Version): Python (3.7)
@RishiKapadia20 RishiKapadia20 added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Aug 21, 2020
@SomayaB SomayaB changed the title [module] S3 add event notification creates BucketNotificationsHandler lambda [S3] add event notification creates BucketNotificationsHandler lambda Aug 22, 2020
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Aug 22, 2020
@iliapolo
Copy link
Contributor

Hi @RishiKapadia20

The BucketNotificationsHandler lambda is an internal CDK lambda needed to apply bucket notification configurations.
Have a look at this for some more detail.

We might need some clarifications around this in the docs.

Thanks

@iliapolo iliapolo added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 23, 2020
@github-actions
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Aug 31, 2020
@github-actions github-actions bot closed this as completed Sep 4, 2020
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 closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants