-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
(cognito): permissions for lambda triggers are created in the lambda's scope instead of the user pool's scope #22315
Comments
hi @abrgr, thanks for letting us know! Are you interested in picking this up? Would need a few tests in addition to the 1 line change to ensure that its all working smoothly. |
Happy to put up a PR. Just wanted to make sure that you're in agreement that the permission should be created in the UserPool's scope before I put up the change. It sounds like you're aligned with that? |
…user pools (#22444) Create the permission in the scope of the user pool instead of the lambda function. Integ tests contain destructive changes for the permissions because of the new logical IDs. This should not cause any downtime since the new permission is created first. Fixes #22315 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Thanks @jogold! |
…user pools (aws#22444) Create the permission in the scope of the user pool instead of the lambda function. Integ tests contain destructive changes for the permissions because of the new logical IDs. This should not cause any downtime since the new permission is created first. Fixes aws#22315 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
If you create a lambda in stack A and then use that lambda as a cognito UserPool trigger in stack B, you will get a circular reference error.
The problem stems from the fact that, when the UserPool calls fn.addPermission from UserPool.prototype.addLambdaPermission, it does not pass a scope on the permission. FunctionBase.prototype.addPermission uses the function's scope if no scope is present on the permission.
Expected Behavior
The permission should be added in the UserPool's scope, not in the lambda function's scope. If the scopes differ, adding the permission in the UserPool's scope guarantees a circular reference error.
Current Behavior
A circular reference is created because the permission is added in the IFunction's scope instead of the UserPool's scope.
Reproduction Steps
Possible Solution
In
aws-cdk/packages/@aws-cdk/aws-cognito/lib/user-pool.ts
Line 978 in e2deca0
scope
as a field on the permission passed toaddLambdaPermission
.Desired code:
Additional Information/Context
No response
CDK CLI Version
8.15.0
Framework Version
No response
Node.js Version
v16.17.0
OS
linux
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: