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

Bucket multiple notifications #8538

Closed
IndikaUdagedara opened this issue Jun 14, 2020 · 1 comment · Fixed by #8741
Closed

Bucket multiple notifications #8538

IndikaUdagedara opened this issue Jun 14, 2020 · 1 comment · Fixed by #8741
Assignees
Labels
@aws-cdk/aws-s3-notifications bug This issue is a bug. in-progress This issue is being actively worked on. p1

Comments

@IndikaUdagedara
Copy link

IndikaUdagedara commented Jun 14, 2020

I'm trying to subscribe a lambda function to multiple prefixes in a single bucket. But bucket.addEventNotification() throws the following error. Bucket and lambda functions are created in the same stack.

Reproduction Steps

    const bucket = new s3.Bucket(...)
    const lambda = new lambda.SingletonFunction(...)
    
    const lambdaDestination = new s3n.LambdaDestination(lambda);
    
    bucket.addEventNotification(s3.EventType.OBJECT_CREATED, lambdaDestination, { prefix: "v1/"})
    bucket.addEventNotification(s3.EventType.OBJECT_CREATED, lambdaDestination, { prefix: "v2/"})

Error Log

cdk synth returns the error:

There is already a Construct with name 'AllowBucketNotificationsFromBucket3E8F7BBA' in Function [SingletonLambda8d4cbf0bc03e4460b43ab4696174d04b

Verbose output:

$ npm run build && npm run cdk synth -- -v

  CDK_OUTDIR: 'cdk.out',
  CDK_CLI_ASM_VERSION: '5.0.0',
  CDK_CLI_VERSION: '1.45.0' }
There is already a Construct with name 'AllowBucketNotificationsFromBucket3E8F7BBA' in Function [SingletonLambda8d4cbf0bc03e4460b43ab4696174d04b]
Subprocess exited with error 1
Error: Subprocess exited with error 1
    at ChildProcess.proc.on.code (/mnt/c/Repos/geku/RedenlabPlatform/deploy/cdk/node_modules/aws-cdk/lib/api/cxapp/exec.ts:118:23)
    at ChildProcess.emit (events.js:198:13)
    at ChildProcess.EventEmitter.emit (domain.js:448:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)

Environment

  • **CLI Version :**1.45
  • **Framework Version:**1.45
  • Node.js Version: 10.20
  • **OS :**Linux
  • Language (Version): TypeScript

Other

It's not clear why multiple notifications aren't allowed. Seems the error is due the same lambda permission being created for both notifications. I suppose I could work around this by creating 2 lambda functions with the same code (didn't try) but I'd prefer to have a single lambda function so monitoring etc. becomes simpler.


This is 🐛 Bug Report

@IndikaUdagedara IndikaUdagedara added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 14, 2020
@IndikaUdagedara IndikaUdagedara changed the title Bucket multiple notifcations Bucket multiple notifications Jun 14, 2020
@SomayaB SomayaB added the @aws-cdk/aws-s3 Related to Amazon S3 label Jun 15, 2020
@iliapolo
Copy link
Contributor

Hi @IndikaUdagedara - Thanks for reporting this!

Definitely looks like a bug. Adding to our docket 👍

@iliapolo iliapolo added p1 @aws-cdk/aws-s3-notifications and removed needs-triage This issue or PR still needs to be triaged. @aws-cdk/aws-s3 Related to Amazon S3 labels Jun 25, 2020
@iliapolo iliapolo added the in-progress This issue is being actively worked on. label Jun 25, 2020
@mergify mergify bot closed this as completed in #8741 Jun 26, 2020
mergify bot pushed a commit that referenced this issue Jun 26, 2020
#8741)

A lambda function has a special `permissionsNode` property that should be used when adding or querying permissions.

When using a `LambdaDestination`, we used `fn.node` for the permissions query, while the `fn.addPermission` function was adding the permissions to the `permissionsNode`.

Fixes #8538

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3-notifications bug This issue is a bug. in-progress This issue is being actively worked on. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants