Skip to content

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

Merged
mergify[bot] merged 7 commits intoaws:masterfrom
yamatatsu:fix-17508
Nov 18, 2021
Merged

fix(iot): unable to add the same lambda function to two TopicRule Actions#17521
mergify[bot] merged 7 commits intoaws:masterfrom
yamatatsu:fix-17508

Conversation

@yamatatsu
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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!


bind(topicRule: iot.ITopicRule): iot.ActionConfig {
this.func.addPermission('invokedByAwsIotRule', {
this.func.addPermission(`${Names.nodeUniqueId(topicRule.node)}:Permission`, {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

yamatatsu and others added 2 commits November 17, 2021 22:47
…action.test.ts

Co-authored-by: Adam Ruka <adamruka85@gmail.com>
@mergify mergify bot dismissed skinny85’s stale review November 17, 2021 13:48

Pull request has been modified.

@yamatatsu yamatatsu requested a review from skinny85 November 17, 2021 21:59
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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