-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(lambda): unlock use case for cross-account functions w/ preconfigured permissions #18979
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's maybe add an entry to the ReadMe file of the module, showing this option, and under what circumstances would you use it?
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…ured permissions (aws#18979) There have been a few reports of regressions after aws#18228 was merged in v1.139.0: aws#18781, aws#18967. AFAIK, aws#18228 fixed a bug in our environment configuring logic for `fromFunctionAttributes()`, so the environment is now being properly passed to the `functionBase` that CDK creates. The bug was being relied on by CDK customers for a particular use case: calling `grantInvoke()` on imported cross-account lambdas with pre-configured permissions. In general, `grantInvoke()` modifies the trust policy of the resource if it is not from the same environment. In the case of cross-account lambdas, this is impossible, and results in a synth-time error. CDK users know this and have modified the lambda permissions in question to have the correct permissions. These users do not need permissions added to the cross-account lambda, so it is not an error. To support this use case, I'm introducing `skipPermissions` as a property for `fromFunctionAttributes()`. When set, we skip this synth-time check all together. Beware, users who set this property are now on their own for the permissions of their cross-account lambda. ```ts const fn = lambda.Function.fromFunctionAttributes(stack, 'Function', { functionArn: 'arn:aws:lambda:us-east-1:123456789012:function:MyFn', skipPermissions: true, }); ``` Closes aws#18781. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
There have been a few reports of regressions after #18255 was merged in v1.139.0: #18781, #18967.
AFAIK, #18255 fixed a bug in our environment configuring logic for
fromFunctionAttributes()
, so the environment is now being properly passed to thefunctionBase
that CDK creates. The bug was being relied on by CDK customers for a particular use case: callinggrantInvoke()
on imported cross-account lambdas with pre-configured permissions. In general,grantInvoke()
modifies the trust policy of the resource if it is not from the same environment. In the case of cross-account lambdas, this is impossible, and results in a synth-time error. CDK users know this and have modified the lambda permissions in question to have the correct permissions. These users do not need permissions added to the cross-account lambda, so it is not an error.To support this use case, I'm introducing
skipPermissions
as a property forfromFunctionAttributes()
. When set, we skip this synth-time check all together. Beware, users who set this property are now on their own for the permissions of their cross-account lambda.Closes #18781.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license