Receipt Detector Model actions for AWS IoT Events (Stability: Experimental)
Get Started
| Product | Versions |
|---|---|
| .NET |
README
Actions for AWS::IoTEvents Detector Model
The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
This library contains integration classes to specify actions of state events of Detector Model in @aws-cdk/aws-iotevents-alpha.
Instances of these classes should be passed to State defined in @aws-cdk/aws-iotevents-alpha
You can define built-in actions to use a timer or set a variable, or send data to other AWS resources.
This library contains integration classes to use a timer or set a variable, or send data to other AWS resources. AWS IoT Events can trigger actions when it detects a specified event or transition event.
Currently supported are:
- Use timer
- Set variable to detector instance
- Invoke a Lambda function
Use timer
The code snippet below creates an Action that creates the timer with duration in seconds.
// Example automatically generated from non-compiling source. May contain errors.
using Amazon.CDK.AWS.IoTEvents.Alpha;
using Amazon.CDK.AWS.IoTEvents.Actions.Alpha;
IInput input;
var state = new State(new StateProps {
StateName = "MyState",
OnEnter = new [] { new Event {
EventName = "test-event",
Condition = Expression.CurrentInput(input),
Actions = new [] {
new SetTimerAction("MyTimer", new Dictionary<string, object> {
{ "duration", cdk.Duration.Seconds(60) }
}) }
} }
});
Setting duration by IoT Events Expression:
// Example automatically generated from non-compiling source. May contain errors.
new actions.SetTimerAction("MyTimer", new Struct {
DurationExpression = iotevents.Expression.InputAttribute(input, "payload.durationSeconds")
});
And the timer can be reset and cleared. Below is an example of general Device HeartBeat Detector Model:
// Example automatically generated from non-compiling source. May contain errors.
var online = new iotevents.State(new Struct {
StateName = "Online",
OnEnter = new [] { new Struct {
EventName = "enter-event",
Condition = iotevents.Expression.CurrentInput(input),
Actions = new [] {
new actions.SetTimerAction("MyTimer", new Struct {
Duration = cdk.Duration.Seconds(60)
}) }
} },
OnInput = new [] { new Struct {
EventName = "input-event",
Condition = iotevents.Expression.CurrentInput(input),
Actions = new [] {
new actions.ResetTimerAction("MyTimer") }
} },
OnExit = new [] { new Struct {
EventName = "exit-event",
Actions = new [] {
new actions.ClearTimerAction("MyTimer") }
} }
});
var offline = new iotevents.State(new Struct { StateName = "Offline" });
online.TransitionTo(offline, new Struct { When = iotevents.Expression.Timeout("MyTimer") });
offline.TransitionTo(online, new Struct { When = iotevents.Expression.CurrentInput(input) });
Set variable to detector instance
The code snippet below creates an Action that set variable to detector instance when it is triggered.
using Amazon.CDK.AWS.IoTEvents.Alpha;
using Amazon.CDK.AWS.IoTEvents.Actions.Alpha;
IInput input;
var state = new State(new StateProps {
StateName = "MyState",
OnEnter = new [] { new Event {
EventName = "test-event",
Condition = Expression.CurrentInput(input),
Actions = new [] {
new SetVariableAction("MyVariable", Expression.InputAttribute(input, "payload.temperature")) }
} }
});
Invoke a Lambda function
The code snippet below creates an Action that invoke a Lambda function when it is triggered.
using Amazon.CDK.AWS.IoTEvents.Alpha;
using Amazon.CDK.AWS.IoTEvents.Actions.Alpha;
using Amazon.CDK.AWS.Lambda;
IInput input;
IFunction func;
var state = new State(new StateProps {
StateName = "MyState",
OnEnter = new [] { new Event {
EventName = "test-event",
Condition = Expression.CurrentInput(input),
Actions = new [] { new LambdaInvokeAction(func) }
} }
});
Downloads by Version
Similar & Alternative Packages
Hand-picked matching NuGet libraries based on tags & ecosystem
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.