Skip to main content

The CDK Construct Library for AWS::IoTEvents (Stability: Experimental)

Total Downloads
118.4K
118,393
Published
Oct 20, 2026
yesterday

Get Started

dotnet add package Amazon.CDK.AWS.IoTEvents.Alpha --version 2.274.0-alpha.0
ProductVersions
.NET
net6.0

README

AWS::IoTEvents Construct Library


cdk-constructs: Experimental

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.


AWS IoT Events enables you to monitor your equipment or device fleets for failures or changes in operation, and to trigger actions when such events occur.

DetectorModel

The following example creates an AWS IoT Events detector model to your stack. The detector model need a reference to at least one AWS IoT Events input. AWS IoT Events inputs enable the detector to get MQTT payload values from IoT Core rules.

You can define built-in actions to use a timer or set a variable, or send data to other AWS resources. See also @aws-cdk/aws-iotevents-actions-alpha for other actions.

using Amazon.CDK.AWS.IoTEvents.Alpha;
using Amazon.CDK.AWS.IoTEvents.Actions.Alpha;
using Amazon.CDK.AWS.Lambda;

IFunction func;


var input = new Input(this, "MyInput", new InputProps {
    InputName = "my_input",  // optional
    AttributeJsonPaths = new [] { "payload.deviceId", "payload.temperature" }
});

var warmState = new State(new StateProps {
    StateName = "warm",
    OnEnter = new [] { new Event {
        EventName = "test-enter-event",
        Condition = Expression.CurrentInput(input),
        Actions = new [] { new LambdaInvokeAction(func) }
    } },
    OnInput = new [] { new Event {  // optional
        EventName = "test-input-event",
        Actions = new [] { new LambdaInvokeAction(func) } } },
    OnExit = new [] { new Event {  // optional
        EventName = "test-exit-event",
        Actions = new [] { new LambdaInvokeAction(func) } } }
});
var coldState = new State(new StateProps {
    StateName = "cold"
});

// transit to coldState when temperature is less than 15
warmState.TransitionTo(coldState, new TransitionOptions {
    EventName = "to_coldState",  // optional property, default by combining the names of the States
    When = Expression.Lt(Expression.InputAttribute(input, "payload.temperature"), Expression.FromString("15")),
    Executing = new [] { new LambdaInvokeAction(func) }
});
// transit to warmState when temperature is greater than or equal to 15
coldState.TransitionTo(warmState, new TransitionOptions {
    When = Expression.Gte(Expression.InputAttribute(input, "payload.temperature"), Expression.FromString("15"))
});

new DetectorModel(this, "MyDetectorModel", new DetectorModelProps {
    DetectorModelName = "test-detector-model",  // optional
    Description = "test-detector-model-description",  // optional property, default is none
    EvaluationMethod = EventEvaluation.SERIAL,  // optional property, default is iotevents.EventEvaluation.BATCH
    DetectorKey = "payload.deviceId",  // optional property, default is none and single detector instance will be created and all inputs will be routed to it
    InitialState = warmState
});

To grant permissions to put messages in the input, you can use the grantWrite() method:

using Amazon.CDK.AWS.IAM;
using Amazon.CDK.AWS.IoTEvents.Alpha;

IGrantable grantable;

var input = Input.FromInputName(this, "MyInput", "my_input");

input.GrantWrite(grantable);

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.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.