-
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
(iotevents): add aws-iotevents DetectorModel L2 Construct #17711
Comments
I will contribute! |
Thanks for the feature request for an l2 @yamatatsu! Excited to see what comes from this :) @skinny85 will you be able to help review the design here? |
@skinny85 |
@skinny85 |
Thanks @yamatatsu. My comments:
Just my quick thoughts based on the first reading of the proposal 🙂. |
My sample code is too simple. 😅 An event can be specified a condition which the event to be triggerd or not.
The code will be written as following: onEnterEvents: [
{
eventName: 'setTimer',
actions: [
timer.set(), // (A)
{ // (B)
variableName: 'countOfEnterThisState',
value: 'isUndefined($variable.countOfEnterThisState) && 1 || $variable.countOfEnterThisState + 1',
},
],
},
{
eventName: 'firstEnter',
condition: '$variable.countOfEnterThisState == 1',
actions: [
{ // (C)
lambda: { // CFn page: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iotevents-detectormodel-lambda.html
functionArn: 'notification-lambda-arn',
},
}
],
},
],
Oh.. sorry! const timer = new iotevents.Timer('heartbeatTimer', 60); And I've fix also above description code.
I intend to implement const timer = new iotevents.Timer('heartbeatTimer', 60);
timer.set()
// => {
// SetTimer: {
// TimerName: "heartbeatTimer",
// Seconds: 60,
// }
// }
timer.reset()
// => {
// ResetTimer: {
// TimerName: "heartbeatTimer",
// }
// }
timer.clear()
// => {
// ClearTimer: {
// TimerName: "heartbeatTimer",
// }
// }
timer.timeout()
// => 'timeout("heartbeatTimer")'
Sounds good! Thank you!
Sounds good! 👍 |
OK, makes sense 🙂. Looks good to me, feel free to start working on the implementation based on that design. |
I've craete an PR that I implemented
Following refference that refer to const input = new iotevents.Input(this, 'input', {
attributeJsonPaths: ['payload.temperature'],
});
const onlineState = new iotevents.State({
stateName: 'online',
onEnterEvents: [{
eventName: 'test-event',
condition: `currentInput("${input.inputName}")`, // this reference is needed for deploying
}],
});
new iotevents.DetectorModel(this, 'MyDetectorModel', {
initialState: onlineState,
}); |
This is proposed by #17711. This PR was created for implemeting `Input` L2 Construct. Implementing it is needed before `DetectorModel`. The reason is described in here: #17711 (comment) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR is proposed by #17711. The first step of the roadmap in #17711 is implemented in this PR. > 1. implement DetectorModel and State with only required properties > - It will not be able to have multiple states yet. If this PR is merged, the simplest detector model can be created as following: ![image](https://user-images.githubusercontent.com/11013683/146365658-248bba67-743c-4ba3-a195-56223146525f.png) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR is proposed by aws#17711. The first step of the roadmap in aws#17711 is implemented in this PR. > 1. implement DetectorModel and State with only required properties > - It will not be able to have multiple states yet. If this PR is merged, the simplest detector model can be created as following: ![image](https://user-images.githubusercontent.com/11013683/146365658-248bba67-743c-4ba3-a195-56223146525f.png) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@yamatatsu I believe this was done in #18049 - can we close this issue? |
@skinny85 This issue have the roadmap and we have rest works. |
The Roadmap is here, and I've reach to No.2 Roadmap
|
Nah, let's just keep this open then, no need to create new issues for this 🙂. |
This PR allow IoT Events detector model to transit to multiple states. This PR is in roadmap of #17711. <img width="561" alt="スクリーンショット 2022-02-02 0 38 10" src="https://user-images.githubusercontent.com/11013683/151999891-45afa8e8-57ed-4264-a323-16b84ed35348.png"> Following image is the graph displayed on AWS console when this integ test deployed. [Compared to the previous version](#18049), you can see that the state transitions are now represented. ![image](https://user-images.githubusercontent.com/11013683/151999116-5b3b36b0-d2b9-4e3a-9483-824dc0618f4b.png) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This is proposed by aws#17711. This PR was created for implemeting `Input` L2 Construct. Implementing it is needed before `DetectorModel`. The reason is described in here: aws#17711 (comment) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR is proposed by aws#17711. The first step of the roadmap in aws#17711 is implemented in this PR. > 1. implement DetectorModel and State with only required properties > - It will not be able to have multiple states yet. If this PR is merged, the simplest detector model can be created as following: ![image](https://user-images.githubusercontent.com/11013683/146365658-248bba67-743c-4ba3-a195-56223146525f.png) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR allow IoT Events detector model to transit to multiple states. This PR is in roadmap of aws#17711. <img width="561" alt="スクリーンショット 2022-02-02 0 38 10" src="https://user-images.githubusercontent.com/11013683/151999891-45afa8e8-57ed-4264-a323-16b84ed35348.png"> Following image is the graph displayed on AWS console when this integ test deployed. [Compared to the previous version](aws#18049), you can see that the state transitions are now represented. ![image](https://user-images.githubusercontent.com/11013683/151999116-5b3b36b0-d2b9-4e3a-9483-824dc0618f4b.png) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR allow IoT Events detector model to perform actions as [this documentation](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-supported-actions.html). This PR is in roadmap of #17711. ![スクリーンショット 2022-02-08 22 43 33](https://user-images.githubusercontent.com/11013683/152999288-81721f15-fefb-4108-b34b-aab3f88a7ab8.png) With this fix, all the interfaces of the DetectorModel are now implemented! And next works is implementing expressions and actions. The exapmle in readme became not simple, so also this PR has sorted explanation of readme. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…19249) This PR allow states in IoT Events detector model to set event on input and exit. This PR is in roadmap of #17711. <img width="530" alt="スクリーンショット 2022-03-05 13 40 57" src="https://user-images.githubusercontent.com/11013683/156868196-a37f5926-05e2-4d3b-a881-17520b465518.png"> ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR allow IoT Events detector model to perform actions as [this documentation](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-supported-actions.html). This PR is in roadmap of aws#17711. ![スクリーンショット 2022-02-08 22 43 33](https://user-images.githubusercontent.com/11013683/152999288-81721f15-fefb-4108-b34b-aab3f88a7ab8.png) With this fix, all the interfaces of the DetectorModel are now implemented! And next works is implementing expressions and actions. The exapmle in readme became not simple, so also this PR has sorted explanation of readme. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…ws#19249) This PR allow states in IoT Events detector model to set event on input and exit. This PR is in roadmap of aws#17711. <img width="530" alt="スクリーンショット 2022-03-05 13 40 57" src="https://user-images.githubusercontent.com/11013683/156868196-a37f5926-05e2-4d3b-a881-17520b465518.png"> ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR is a part of roadmap in #17711. And if this PR is merged, I will close this issue and create some good first issues to implement rest actions and expressions. This PR supports the timer actions (`SetTimerAction`, `ResetTimerAction` and `ClearTimerAction`) and `timeout()` expression. These allow to embed a timer to the state machine of the detector model. Below figure illustrate the state machine [Device Heartbeat](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-examples-dhb.html). This detector model is used to alert if the message is interrupted for a certain period of time. The integ-test included in this PR is example of creating Device Heartbeat detector model. ```mermaid stateDiagram-v2 [*] --> Online: set a timer on input message Online --> Online: reset the timer\non input messages Online --> Offline: timeout the timer Offline --> Online: input messages ``` ---- ### 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 is a part of roadmap in aws#17711. And if this PR is merged, I will close this issue and create some good first issues to implement rest actions and expressions. This PR supports the timer actions (`SetTimerAction`, `ResetTimerAction` and `ClearTimerAction`) and `timeout()` expression. These allow to embed a timer to the state machine of the detector model. Below figure illustrate the state machine [Device Heartbeat](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-examples-dhb.html). This detector model is used to alert if the message is interrupted for a certain period of time. The integ-test included in this PR is example of creating Device Heartbeat detector model. ```mermaid stateDiagram-v2 [*] --> Online: set a timer on input message Online --> Online: reset the timer\non input messages Online --> Offline: timeout the timer Offline --> Online: input messages ``` ---- ### 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 issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Description
Now,
@aws-cdk/aws-iotevents
has no L2 Construct. I will implements L2 Constructs.Use Case
When users create IoT Events DetectorModel, This Cunstruct will support it.
Proposed Solution
We can create L2 constructs for aws-iotevents.
Other information
I'm starting to design.
And in first PR, I'm going to commit
DetectorModel
andState
with only required properties.Acknowledge
Design
ref: CloudFormation
usage:
DetectorModel:
State:
graph:
Roadmap
DetectorModel
andState
with only required propertiesstate.transitionTo()
IAction
aws-iotevents-actions
onInput
andonExit
The text was updated successfully, but these errors were encountered: