(iotevents): add aws-iotevents DetectorModel L2 Construct
See original GitHub issueDescription
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
and State
with only required properties.
Acknowledge
- I may be able to implement this feature request
- This feature might incur a breaking change
Design
ref: CloudFormation
usage:
const timer = new iotevents.Timer("heartbeatTimer", 60);
// Define nodes of the state machine
const onlineState = new iotevents.State({
stateName: "online",
onEnterEvents: [
{
eventName: "setTimer",
actions: [timer.set()], // `timer.set()` return `SetTimerAction`
},
],
onInputEvents: [
{
eventName: "resetTimer",
condition: 'currentInput("HeartbeatInputData")',
actions: [timer.reset()], // `timer.reset()` return `ResetTimerAction`
},
],
});
const offlineState = new iotevents.State({
stateName: "offline",
});
// Define edges of the state machine
onlineState.transitionTo({
eventName: "to_offline",
condition: timer.timeout(), // `timer.timeout()` return just string
nextState: offlineState,
});
offlineState.transitionTo({
eventName: "to_online",
condition: 'currentInput("HeartbeatInputData")',
nextState: onlineState,
});
// Define the state machine
new iotevents.DetectorModel(this, "DetectorModel", {
initialState: onlineState,
});
DetectorModel:
class DetectorModel {
constructor(private readonly initialState: State) {}
private getDefinition() {
const stateSet = this.initialState.getGraphStates();
return {
initialState: this.initialState.stateName,
states: Array.from(stateSet).map((state) => state.toCfn()),
};
}
}
State:
class State {
constructor(private readonly props: StateProps) {}
/**
* get states recursively
*/
getGraphStates(stateSet: Set<State> = new Set<State>()): Set<State> {
if (stateSet.has(this)) {
return stateSet;
}
stateSet.add(this);
const nextStates = initialState.transitionEvents.forEach((te) => {
te.nextState.getGraphStates(stateSet);
});
return stateSet;
}
}
graph:
Roadmap
- implement
DetectorModel
andState
with only required properties- It will not be able to have multiple states yet.
- implement
state.transitionTo()
- It will be able to have multiple states and to transit.
- It will not be able to have events that is without transition.
- It will not be able to perform actions.
- implement
IAction
- create new repository
aws-iotevents-actions
- Note: AWS IoT Events has many actions like AWS IoT TopicRule. https://docs.aws.amazon.com/iotevents/latest/apireference/API_Action.html
- implement
onInput
andonExit
- implement rest Expressions
- implement some actions (separate PRs for each actions)
- It will be able to perform actions.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
class DetectorModel (construct) · AWS CDK
Defines an AWS IoT Events detector model in this stack. Example. import * as iotevents from '@aws-cdk/aws-iotevents ...
Read more >[NEW LAUNCH!] Introducing AWS IoT Events (IOT367)
AWS IoT Events is a new IoT-managed service that allows enterprises with large operations dependent on IoT devices to continuously monitor ...
Read more >IoTEvents — Boto3 Docs 1.26.30 documentation - Amazon AWS
For more information, see Create an alarm model in the AWS IoT Events ... Sends an AWS IoT Events input, passing in information...
Read more >A No-Nonsense Guide To AWS Cloud Development Kit (CDK)
The next level, curated or L2, provides constructs with common ... addLifeCycleRule() , which adds a lifecycle rule to the bucket.
Read more >Lab 70 - AWS IoT Events
Log into the AWS IoT Events Console; Click on Create detector model. Create detector ... In the Add OnEnter event page, enter Event...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Nah, let’s just keep this open then, no need to create new issues for this 🙂.
OK, makes sense 🙂. Looks good to me, feel free to start working on the implementation based on that design.