-
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
feat(iot): allow setting Actions of TopicRule #17110
Conversation
7388b1c
to
f68be0a
Compare
I met following error on
And I confirmed this error was suppressed when using the Shall we implement using the |
Yes, we should implement using |
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.
Putting in "Request changes" to clear this one from my To-Do list. @yamatatsu please re-request my review when this is ready!
f68be0a
to
9fcb358
Compare
Pull request has been modified.
This change adds `IAction` to aws-iot for preparing to implemamt AWS IoT Rule actions.
9fcb358
to
7a72b32
Compare
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.
Now that we have the @aws-cdk/aws-iot-actions
module on master
, let's add a single implementation of IAction
there, and use that in the ReadMe of @aws-cdk/aws-iot
, instead of an anonymous object.
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.
Looks great @yamatatsu! Minor suggestions before we merge this in.
constructor(private readonly lambdaFn: lambda.IFunction) {} | ||
|
||
bind(rule: iot.ITopicRule): iot.ActionConfig { | ||
this.lambdaFn.addPermission('invokedByAwsIotRule', { |
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.
Can you use function.grantInvoke()
instead?
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.
@skinny85 Thank you for your review!
In my understanding, using addPermission()
is better. Because a lambda resource policy created by using grantInvoke()
is more lax than using addPermission()
.
As described in this document, lambda resource policy fields sourceAccount
and sourceArn
are required (or recommended?). But functions.grantInvoke()
cannot add sourceAccount
and sourceArn
as this code.
For confirmation, I tried following code instead of this.func.addPermission()
:
this.func.grantInvoke({ grantPrincipal: new iam.ServicePrincipal('iot.amazonaws.com') });
Then there is template difference as following:
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.
OK, fair enough 🙂.
packages/@aws-cdk/aws-iot-actions/test/lambda/integ.lambda-action.ts
Outdated
Show resolved
Hide resolved
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.
This is almost perfect @yamatatsu! Change the account
in LambdaAction
, and rename it to LambdaFunctionAction
, and we'll merge this in!
*/ | ||
constructor(private readonly func: lambda.IFunction) {} | ||
|
||
bind(rule: iot.ITopicRule): iot.ActionConfig { |
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.
bind(rule: iot.ITopicRule): iot.ActionConfig { | |
bind(topicRule: iot.ITopicRule): iot.ActionConfig { |
* | ||
* @param rule The TopicRule that would trigger this action. | ||
*/ | ||
bind(rule: ITopicRule): ActionConfig; |
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.
bind(rule: ITopicRule): ActionConfig; | |
bind(topicRule: ITopicRule): ActionConfig; |
/** | ||
* The action to invoke an AWS Lambda function, passing in an MQTT message. | ||
*/ | ||
export class LambdaAction implements iot.IAction { |
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 rename this to LambdaFunctionAction
.
Co-authored-by: Adam Ruka <[email protected]>
Pull request has been modified.
@skinny85 I've addressed the comments!👍 |
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 perfect @yamatatsu, thanks for incorporating all of my comments!
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). |
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 |
I'm trying to implement aws-iot L2 Constructs. This PR is the next step of aws#16681 refar: - aws#16681 (comment) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
I'm trying to implement aws-iot L2 Constructs.
This PR is the next step of #16681
refar:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license