feat(iot-actions): support for sending messages to iot-events#19953
feat(iot-actions): support for sending messages to iot-events#19953mergify[bot] merged 9 commits intoaws:mainfrom
Conversation
TheRealAmazonKendra
left a comment
There was a problem hiding this comment.
Same comment as #19949, unfortunately changing to the new branch made this messy.
c99cb36 to
f4f2061
Compare
Pull request has been modified.
|
I’ve rebased it! |
TheRealAmazonKendra
left a comment
There was a problem hiding this comment.
Overall this is great work! Just a few comments inline.
| * | ||
| * When batchMode is true and the rule SQL statement evaluates to an Array, | ||
| * each Array element is treated as a separate message when Events by calling BatchPutMessage. | ||
| * The resulting array can't have more than 10 messages. |
There was a problem hiding this comment.
If the array does have more than 10 messages how/when does this fail? What's the user experience here? We should probably have some enforcement here, if possible.
There was a problem hiding this comment.
Not explained in the documentation, I've experimented it with the below command:
aws iot-data publish --topic device/mydevice/data --qos 1 --payload (echo '[{"payload":{"deviceId":"001"}},{"payload":{"deviceId":"002"}},{"payload":{"deviceId":"003"}},{"payload":{"deviceId":"004"}},{"payload":{"deviceId":"005"}},{"payload":{"deviceId":"006"}},{"payload":{"deviceId":"007"}},{"payload":{"deviceId":"008"}},{"payload":{"deviceId":"009"}},{"payload":{"deviceId":"010"}},{"payload":{"deviceId":"011"}}]' | base64) --region us-east-1
and get below error message:
Failed to send message to Iot Events. The payload containing 11 messages cannot have more than 10 messages when batchMode=true..
I thing it is not possible to restrict it, because it depends to published payloads (instead of SQL) that is out of CDK.
WDYT?
| export class IotEventsPutMessageAction implements iot.IAction { | ||
| private readonly batchMode?: boolean; | ||
| private readonly messageId?: string; | ||
| private readonly role?: iam.IRole; |
There was a problem hiding this comment.
What's the behavior if a role is not set?
There was a problem hiding this comment.
If a role is not set, a new role will be created and be granted some policies needed.
It's explained in CommonActionProps.
packages/@aws-cdk/aws-iot-actions/lib/iotevents-put-message-action.ts
Outdated
Show resolved
Hide resolved
Pull request has been modified.
TheRealAmazonKendra
left a comment
There was a problem hiding this comment.
I'm going to put this back into changes requested since the build is failing, that way I'll get notified when it's been updated.
Pull request has been modified.
TheRealAmazonKendra
left a comment
There was a problem hiding this comment.
Just one more comment. I don't really want to add exclusions to our lint rules.
| }, | ||
| "awslint": { | ||
| "exclude": [ | ||
| "no-unused-type:@aws-cdk/aws-iot.ActionConfig" |
There was a problem hiding this comment.
What's causing this violation? I generally don't think we should be adding lint exclusions but instead should make sure the code aligns to them.
There was a problem hiding this comment.
@TheRealAmazonKendra
I've researched it.
It was caused by addind @internal to method IAction._bind(), the message is:
error: [awslint:no-unused-type:@aws-cdk/aws-iot.ActionConfig] type or enum is not used by exported classes (declared at lib/action.ts:20)
It appears that IAction._bind() is no longer listed in Type.ownMethods.
This caused ActionConfig to be markded as unused-type.
Changing ActionConfig to not export will suppress this violation. However, if we do so, ActionConfig will not be able to be used in aws-iot-actions.
Like this, when an interfaces is extended across packages, adding lint exclusions seems reasonable.
WDYT?
|
Thank you for contributing! Your pull request will be updated from main 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 main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
) This PR includes to support the action for sending messages to IoT Events. This feature is described [this documentation](https://docs.aws.amazon.com/iot/latest/developerguide/iotevents-rule-action.html). I actually confirmed that the behavior of the action deployed by integ-test is all right. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [x] 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*
This PR includes to support the action for sending messages to IoT Events.
This feature is described this documentation.
I actually confirmed that the behavior of the action deployed by integ-test is all right.
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integto deploy the infrastructure and generate the snapshot (i.e.yarn integwithout--dry-run)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license