-
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
fix(iot): unable to add the same lambda function to two TopicRule Actions #17521
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.
Looks good @yamatatsu, a few tiny suggestions!
packages/@aws-cdk/aws-iot-actions/test/lambda/lambda-function-action.test.ts
Outdated
Show resolved
Hide resolved
@@ -12,7 +13,7 @@ export class LambdaFunctionAction implements iot.IAction { | |||
constructor(private readonly func: lambda.IFunction) {} | |||
|
|||
bind(topicRule: iot.ITopicRule): iot.ActionConfig { | |||
this.func.addPermission('invokedByAwsIotRule', { | |||
this.func.addPermission(`${Names.nodeUniqueId(topicRule.node)}:Permission`, { |
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.
I would make the "Permission"
part more module-specific. Something like:
this.func.addPermission(`${Names.nodeUniqueId(topicRule.node)}:Permission`, { | |
this.func.addPermission(`${Names.nodeUniqueId(topicRule.node)}:IotLambdaFunctionAction`, { |
sql: iot.IotSql.fromStringAsVer20160323("SELECT topic(2) as device_id FROM 'device/+/data'"), | ||
actions: [action], | ||
})).not.toThrow(); | ||
}); |
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.
How about we actually assert that two different permissions are created, instead of just asserting the lack of an exception being thrown?
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.
It's good!
…action.test.ts Co-authored-by: Adam Ruka <[email protected]>
Pull request has been modified.
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.
Awesome, thanks for the fix @yamatatsu!
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). |
fix: #17508
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license