Namespace Amazon.CDK.AWS.IoTEvents
AWS::IoTEvents Construct Library
---AWS CDK v1 has reached End-of-Support on 2023-06-01.
This package is no longer being updated, and users should migrate to AWS CDK v2.
For more information on how to migrate, see the Migrating to AWS CDK v2 guide.
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.
Installation
Install the module:
$ npm i @aws-cdk/aws-iotevents
Import it into your code:
using Amazon.CDK.AWS.IoTEvents;
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 for other actions.
using Amazon.CDK.AWS.IoTEvents;
using Amazon.CDK.AWS.IoTEvents.Actions;
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;
IGrantable grantable;
var input = Input.FromInputName(this, "MyInput", "my_input");
input.GrantWrite(grantable);
Classes
ActionBindOptions | (experimental) Options when binding a Action to a detector model. |
ActionConfig | (experimental) Properties for a AWS IoT Events action. |
CfnAlarmModel | A CloudFormation |
CfnAlarmModel.AcknowledgeFlowProperty | Specifies whether to get notified for alarm state changes. |
CfnAlarmModel.AlarmActionProperty | Specifies one of the following actions to receive notifications when the alarm state changes. |
CfnAlarmModel.AlarmCapabilitiesProperty | Contains the configuration information of alarm state changes. |
CfnAlarmModel.AlarmEventActionsProperty | Contains information about one or more alarm actions. |
CfnAlarmModel.AlarmRuleProperty | Defines when your alarm is invoked. |
CfnAlarmModel.AssetPropertyTimestampProperty | A structure that contains timestamp information. For more information, see TimeInNanos in the AWS IoT SiteWise API Reference . |
CfnAlarmModel.AssetPropertyValueProperty | A structure that contains value information. For more information, see AssetPropertyValue in the AWS IoT SiteWise API Reference . |
CfnAlarmModel.AssetPropertyVariantProperty | A structure that contains an asset property value. |
CfnAlarmModel.DynamoDBProperty | Defines an action to write to the Amazon DynamoDB table that you created. |
CfnAlarmModel.DynamoDBv2Property | Defines an action to write to the Amazon DynamoDB table that you created. |
CfnAlarmModel.FirehoseProperty | Sends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream. |
CfnAlarmModel.InitializationConfigurationProperty | Specifies the default alarm state. |
CfnAlarmModel.IotEventsProperty | Sends an AWS IoT Events input, passing in information about the detector model instance and the event that triggered the action. |
CfnAlarmModel.IotSiteWiseProperty | Sends information about the detector model instance and the event that triggered the action to a specified asset property in AWS IoT SiteWise . |
CfnAlarmModel.IotTopicPublishProperty | Information required to publish the MQTT message through the AWS IoT message broker. |
CfnAlarmModel.LambdaProperty | Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action. |
CfnAlarmModel.PayloadProperty | Information needed to configure the payload. |
CfnAlarmModel.SimpleRuleProperty | A rule that compares an input property value to a threshold value with a comparison operator. |
CfnAlarmModel.SnsProperty | Information required to publish the Amazon SNS message. |
CfnAlarmModel.SqsProperty | Sends information about the detector model instance and the event that triggered the action to an Amazon SQS queue. |
CfnAlarmModelProps | Properties for defining a |
CfnDetectorModel | A CloudFormation |
CfnDetectorModel.ActionProperty | An action to be performed when the |
CfnDetectorModel.AssetPropertyTimestampProperty | A structure that contains timestamp information. For more information, see TimeInNanos in the AWS IoT SiteWise API Reference . |
CfnDetectorModel.AssetPropertyValueProperty | A structure that contains value information. For more information, see AssetPropertyValue in the AWS IoT SiteWise API Reference . |
CfnDetectorModel.AssetPropertyVariantProperty | A structure that contains an asset property value. |
CfnDetectorModel.ClearTimerProperty | Information needed to clear the timer. |
CfnDetectorModel.DetectorModelDefinitionProperty | Information that defines how a detector operates. |
CfnDetectorModel.DynamoDBProperty | Defines an action to write to the Amazon DynamoDB table that you created. |
CfnDetectorModel.DynamoDBv2Property | Defines an action to write to the Amazon DynamoDB table that you created. |
CfnDetectorModel.EventProperty | Specifies the |
CfnDetectorModel.FirehoseProperty | Sends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream. |
CfnDetectorModel.IotEventsProperty | Sends an AWS IoT Events input, passing in information about the detector model instance and the event that triggered the action. |
CfnDetectorModel.IotSiteWiseProperty | Sends information about the detector model instance and the event that triggered the action to a specified asset property in AWS IoT SiteWise . |
CfnDetectorModel.IotTopicPublishProperty | Information required to publish the MQTT message through the AWS IoT message broker. |
CfnDetectorModel.LambdaProperty | Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action. |
CfnDetectorModel.OnEnterProperty | When entering this state, perform these |
CfnDetectorModel.OnExitProperty | When exiting this state, perform these |
CfnDetectorModel.OnInputProperty | Specifies the actions performed when the |
CfnDetectorModel.PayloadProperty | Information needed to configure the payload. |
CfnDetectorModel.ResetTimerProperty | Information required to reset the timer. |
CfnDetectorModel.SetTimerProperty | Information needed to set the timer. |
CfnDetectorModel.SetVariableProperty | Information about the variable and its new value. |
CfnDetectorModel.SnsProperty | Information required to publish the Amazon SNS message. |
CfnDetectorModel.SqsProperty | Sends information about the detector model instance and the event that triggered the action to an Amazon SQS queue. |
CfnDetectorModel.StateProperty | Information that defines a state of a detector. |
CfnDetectorModel.TransitionEventProperty | Specifies the actions performed and the next state entered when a |
CfnDetectorModelProps | Properties for defining a |
CfnInput | A CloudFormation |
CfnInput.AttributeProperty | The attributes from the JSON payload that are made available by the input. |
CfnInput.InputDefinitionProperty | The definition of the input. |
CfnInputProps | Properties for defining a |
DetectorModel | (experimental) Defines an AWS IoT Events detector model in this stack. |
DetectorModelProps | (experimental) Properties for defining an AWS IoT Events detector model. |
Event | (experimental) Specifies the actions to be performed when the condition evaluates to |
EventEvaluation | (experimental) Information about the order in which events are evaluated and how actions are executed. |
Expression | (experimental) Expression for events in Detector Model state. |
Input | (experimental) Defines an AWS IoT Events input in this stack. |
InputProps | (experimental) Properties for defining an AWS IoT Events input. |
State | (experimental) Defines a state of a detector. |
StateProps | (experimental) Properties for defining a state of a detector. |
TransitionOptions | (experimental) Properties for options of state transition. |
Interfaces
CfnAlarmModel.IAcknowledgeFlowProperty | Specifies whether to get notified for alarm state changes. |
CfnAlarmModel.IAlarmActionProperty | Specifies one of the following actions to receive notifications when the alarm state changes. |
CfnAlarmModel.IAlarmCapabilitiesProperty | Contains the configuration information of alarm state changes. |
CfnAlarmModel.IAlarmEventActionsProperty | Contains information about one or more alarm actions. |
CfnAlarmModel.IAlarmRuleProperty | Defines when your alarm is invoked. |
CfnAlarmModel.IAssetPropertyTimestampProperty | A structure that contains timestamp information. For more information, see TimeInNanos in the AWS IoT SiteWise API Reference . |
CfnAlarmModel.IAssetPropertyValueProperty | A structure that contains value information. For more information, see AssetPropertyValue in the AWS IoT SiteWise API Reference . |
CfnAlarmModel.IAssetPropertyVariantProperty | A structure that contains an asset property value. |
CfnAlarmModel.IDynamoDBProperty | Defines an action to write to the Amazon DynamoDB table that you created. |
CfnAlarmModel.IDynamoDBv2Property | Defines an action to write to the Amazon DynamoDB table that you created. |
CfnAlarmModel.IFirehoseProperty | Sends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream. |
CfnAlarmModel.IInitializationConfigurationProperty | Specifies the default alarm state. |
CfnAlarmModel.IIotEventsProperty | Sends an AWS IoT Events input, passing in information about the detector model instance and the event that triggered the action. |
CfnAlarmModel.IIotSiteWiseProperty | Sends information about the detector model instance and the event that triggered the action to a specified asset property in AWS IoT SiteWise . |
CfnAlarmModel.IIotTopicPublishProperty | Information required to publish the MQTT message through the AWS IoT message broker. |
CfnAlarmModel.ILambdaProperty | Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action. |
CfnAlarmModel.IPayloadProperty | Information needed to configure the payload. |
CfnAlarmModel.ISimpleRuleProperty | A rule that compares an input property value to a threshold value with a comparison operator. |
CfnAlarmModel.ISnsProperty | Information required to publish the Amazon SNS message. |
CfnAlarmModel.ISqsProperty | Sends information about the detector model instance and the event that triggered the action to an Amazon SQS queue. |
CfnDetectorModel.IActionProperty | An action to be performed when the |
CfnDetectorModel.IAssetPropertyTimestampProperty | A structure that contains timestamp information. For more information, see TimeInNanos in the AWS IoT SiteWise API Reference . |
CfnDetectorModel.IAssetPropertyValueProperty | A structure that contains value information. For more information, see AssetPropertyValue in the AWS IoT SiteWise API Reference . |
CfnDetectorModel.IAssetPropertyVariantProperty | A structure that contains an asset property value. |
CfnDetectorModel.IClearTimerProperty | Information needed to clear the timer. |
CfnDetectorModel.IDetectorModelDefinitionProperty | Information that defines how a detector operates. |
CfnDetectorModel.IDynamoDBProperty | Defines an action to write to the Amazon DynamoDB table that you created. |
CfnDetectorModel.IDynamoDBv2Property | Defines an action to write to the Amazon DynamoDB table that you created. |
CfnDetectorModel.IEventProperty | Specifies the |
CfnDetectorModel.IFirehoseProperty | Sends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream. |
CfnDetectorModel.IIotEventsProperty | Sends an AWS IoT Events input, passing in information about the detector model instance and the event that triggered the action. |
CfnDetectorModel.IIotSiteWiseProperty | Sends information about the detector model instance and the event that triggered the action to a specified asset property in AWS IoT SiteWise . |
CfnDetectorModel.IIotTopicPublishProperty | Information required to publish the MQTT message through the AWS IoT message broker. |
CfnDetectorModel.ILambdaProperty | Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action. |
CfnDetectorModel.IOnEnterProperty | When entering this state, perform these |
CfnDetectorModel.IOnExitProperty | When exiting this state, perform these |
CfnDetectorModel.IOnInputProperty | Specifies the actions performed when the |
CfnDetectorModel.IPayloadProperty | Information needed to configure the payload. |
CfnDetectorModel.IResetTimerProperty | Information required to reset the timer. |
CfnDetectorModel.ISetTimerProperty | Information needed to set the timer. |
CfnDetectorModel.ISetVariableProperty | Information about the variable and its new value. |
CfnDetectorModel.ISnsProperty | Information required to publish the Amazon SNS message. |
CfnDetectorModel.ISqsProperty | Sends information about the detector model instance and the event that triggered the action to an Amazon SQS queue. |
CfnDetectorModel.IStateProperty | Information that defines a state of a detector. |
CfnDetectorModel.ITransitionEventProperty | Specifies the actions performed and the next state entered when a |
CfnInput.IAttributeProperty | The attributes from the JSON payload that are made available by the input. |
CfnInput.IInputDefinitionProperty | The definition of the input. |
IAction | (experimental) An abstract action for DetectorModel. |
IActionBindOptions | (experimental) Options when binding a Action to a detector model. |
IActionConfig | (experimental) Properties for a AWS IoT Events action. |
ICfnAlarmModelProps | Properties for defining a |
ICfnDetectorModelProps | Properties for defining a |
ICfnInputProps | Properties for defining a |
IDetectorModel | (experimental) Represents an AWS IoT Events detector model. |
IDetectorModelProps | (experimental) Properties for defining an AWS IoT Events detector model. |
IEvent | (experimental) Specifies the actions to be performed when the condition evaluates to |
IInput | (experimental) Represents an AWS IoT Events input. |
IInputProps | (experimental) Properties for defining an AWS IoT Events input. |
IStateProps | (experimental) Properties for defining a state of a detector. |
ITransitionOptions | (experimental) Properties for options of state transition. |