Package software.amazon.awscdk.services.iotevents.alpha
AWS::IoTEvents Construct Library
---
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.
import software.amazon.awscdk.services.iotevents.alpha.*; import software.amazon.awscdk.services.iotevents.actions.alpha.*; import software.amazon.awscdk.services.lambda.*; IFunction func; Input input = Input.Builder.create(this, "MyInput") .inputName("my_input") // optional .attributeJsonPaths(List.of("payload.deviceId", "payload.temperature")) .build(); State warmState = State.Builder.create() .stateName("warm") .onEnter(List.of(Event.builder() .eventName("test-enter-event") .condition(Expression.currentInput(input)) .actions(List.of(new LambdaInvokeAction(func))) .build())) .onInput(List.of(Event.builder() // optional .eventName("test-input-event") .actions(List.of(new LambdaInvokeAction(func))).build())) .onExit(List.of(Event.builder() // optional .eventName("test-exit-event") .actions(List.of(new LambdaInvokeAction(func))).build())) .build(); State coldState = State.Builder.create() .stateName("cold") .build(); // transit to coldState when temperature is less than 15 warmState.transitionTo(coldState, TransitionOptions.builder() .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(List.of(new LambdaInvokeAction(func))) .build()); // transit to warmState when temperature is greater than or equal to 15 coldState.transitionTo(warmState, TransitionOptions.builder() .when(Expression.gte(Expression.inputAttribute(input, "payload.temperature"), Expression.fromString("15"))) .build()); DetectorModel.Builder.create(this, "MyDetectorModel") .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) .build();
To grant permissions to put messages in the input,
you can use the grantWrite()
method:
import software.amazon.awscdk.services.iam.*; import software.amazon.awscdk.services.iotevents.alpha.*; IGrantable grantable; IInput input = Input.fromInputName(this, "MyInput", "my_input"); input.grantWrite(grantable);
-
ClassDescription(experimental) Options when binding a Action to a detector model.A builder for
ActionBindOptions
An implementation forActionBindOptions
(experimental) Properties for a AWS IoT Events action.A builder forActionConfig
An implementation forActionConfig
(experimental) Defines an AWS IoT Events detector model in this stack.(experimental) A fluent builder forDetectorModel
.(experimental) Properties for defining an AWS IoT Events detector model.A builder forDetectorModelProps
An implementation forDetectorModelProps
(experimental) Specifies the actions to be performed when the condition evaluates totrue
.A builder forEvent
An implementation forEvent
(experimental) Information about the order in which events are evaluated and how actions are executed.(experimental) Expression for events in Detector Model state.(experimental) An abstract action for DetectorModel.Internal default implementation forIAction
.A proxy class which represents a concrete javascript instance of this type.(experimental) Represents an AWS IoT Events detector model.Internal default implementation forIDetectorModel
.A proxy class which represents a concrete javascript instance of this type.(experimental) Represents an AWS IoT Events input.Internal default implementation forIInput
.A proxy class which represents a concrete javascript instance of this type.(experimental) Defines an AWS IoT Events input in this stack.(experimental) A fluent builder forInput
.(experimental) Properties for defining an AWS IoT Events input.A builder forInputProps
An implementation forInputProps
(experimental) Defines a state of a detector.(experimental) A fluent builder forState
.(experimental) Properties for defining a state of a detector.A builder forStateProps
An implementation forStateProps
(experimental) Properties for options of state transition.A builder forTransitionOptions
An implementation forTransitionOptions