-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(iam): cdk synth Throws Error When Adding SQS Event Source to Imported Lambda Function #12607
Comments
Same result when trying to add to DynamoEventSource |
This seems to a bug in the grant APIs. Transferring to IAM. |
Please is there a workaround for this? Maybe using Cfn resources? EDIT: I think this can be used https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.EventSourceMapping.html. But it probably requires to manually update the lambda exection role:
|
@rix0rrr can you propose a workaround until this is resolved? |
I would have to dive into the specifics, but you can try using That feels like it should do it. |
I found an example in other issue #10342 (comment)
But it sucks you need to know the execution role arn :/ |
Using the role arn to fetch the role of the function is really nasty. Because the role is mostly a generated value . Would be must helpful if the role is just retrieved along with the function. |
Is it already fixed or planned to be fixed? |
any updates on this? |
… function (#21970) If an SQS event sources is added to an imported function it will throw an error if the function is not imported with an IAM role. This PR updates the logic to only attempt to add permissions to the principal if the role exists, otherwise it will add a warning indicating that permissions were not added. fixes #12607 ---- ### All Submissions: * [ ] 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 * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] 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*
|
… function (aws#21970) If an SQS event sources is added to an imported function it will throw an error if the function is not imported with an IAM role. This PR updates the logic to only attempt to add permissions to the principal if the role exists, otherwise it will add a warning indicating that permissions were not added. fixes aws#12607 ---- ### All Submissions: * [ ] 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 * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] 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*
cdk synth throws an error when addEventSource is used to add an SQS event source on an imported lambda function.
Reproduction Steps
What did you expect to happen?
cdk synth succeeds when an SQS event source is added to an imported lambda function.
What actually happened?
The following error occurred while calling cdk synth
Error: Cannot get policy fragment of CdkLambdaImportErrorStack/imported-function, resource imported without a role
Environment
Other
Related issue: #4613
The above referenced issue fixed a similar issue with the same error message but as part of the CodeBuild module. Maybe this issue has the same underlying root cause and a similar fix?
Stack trace for this issue:
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: