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

fix(iot): unable to add the same lambda function to two TopicRule Actions #17521

Merged
merged 7 commits into from
Nov 18, 2021

Conversation

yamatatsu
Copy link
Contributor

fix: #17508


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Nov 16, 2021

@github-actions github-actions bot added the @aws-cdk/aws-iot Related to AWS IoT label Nov 16, 2021
Copy link
Contributor

@skinny85 skinny85 left a 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!

@@ -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`, {
Copy link
Contributor

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:

Suggested change
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();
});
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good!

@mergify mergify bot dismissed skinny85’s stale review November 17, 2021 13:48

Pull request has been modified.

Copy link
Contributor

@skinny85 skinny85 left a 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!

@skinny85 skinny85 changed the title fix(iot): Unable to bind two TopicRule with the same action of a lambda function fix(iot): unable to add the same lambda function to two TopicRule Actions Nov 18, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2021

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 12c8d81
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit eda1640 into aws:master Nov 18, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 18, 2021

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).

@yamatatsu yamatatsu deleted the fix-17508 branch November 18, 2021 21:40
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…ions (aws#17521)

fix: aws#17508

----

*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-iot Related to AWS IoT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-iot-actions): Unable to bind two TopicRule with the same action of a lambda function
3 participants