Package software.amazon.awscdk.services.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:
import software.amazon.awscdk.services.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.
import software.amazon.awscdk.services.iotevents.*;
import software.amazon.awscdk.services.iotevents.actions.*;
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:
Deprecated: 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 https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.htmlimport software.amazon.awscdk.services.iam.*; import software.amazon.awscdk.services.iotevents.*; 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
ActionBindOptionsAn implementation forActionBindOptions(experimental) Properties for a AWS IoT Events action.A builder forActionConfigAn implementation forActionConfigA CloudFormationAWS::IoTEvents::AlarmModel.Specifies whether to get notified for alarm state changes.A builder forCfnAlarmModel.AcknowledgeFlowPropertyAn implementation forCfnAlarmModel.AcknowledgeFlowPropertySpecifies one of the following actions to receive notifications when the alarm state changes.A builder forCfnAlarmModel.AlarmActionPropertyAn implementation forCfnAlarmModel.AlarmActionPropertyContains the configuration information of alarm state changes.A builder forCfnAlarmModel.AlarmCapabilitiesPropertyAn implementation forCfnAlarmModel.AlarmCapabilitiesPropertyContains information about one or more alarm actions.A builder forCfnAlarmModel.AlarmEventActionsPropertyAn implementation forCfnAlarmModel.AlarmEventActionsPropertyDefines when your alarm is invoked.A builder forCfnAlarmModel.AlarmRulePropertyAn implementation forCfnAlarmModel.AlarmRulePropertyA structure that contains timestamp information.A builder forCfnAlarmModel.AssetPropertyTimestampPropertyAn implementation forCfnAlarmModel.AssetPropertyTimestampPropertyA structure that contains value information.A builder forCfnAlarmModel.AssetPropertyValuePropertyAn implementation forCfnAlarmModel.AssetPropertyValuePropertyA structure that contains an asset property value.A builder forCfnAlarmModel.AssetPropertyVariantPropertyAn implementation forCfnAlarmModel.AssetPropertyVariantPropertyA fluent builder forCfnAlarmModel.Defines an action to write to the Amazon DynamoDB table that you created.A builder forCfnAlarmModel.DynamoDBPropertyAn implementation forCfnAlarmModel.DynamoDBPropertyDefines an action to write to the Amazon DynamoDB table that you created.A builder forCfnAlarmModel.DynamoDBv2PropertyAn implementation forCfnAlarmModel.DynamoDBv2PropertySends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream.A builder forCfnAlarmModel.FirehosePropertyAn implementation forCfnAlarmModel.FirehosePropertySpecifies the default alarm state.A builder forCfnAlarmModel.InitializationConfigurationPropertyAn implementation forCfnAlarmModel.InitializationConfigurationPropertySends an AWS IoT Events input, passing in information about the detector model instance and the event that triggered the action.A builder forCfnAlarmModel.IotEventsPropertyAn implementation forCfnAlarmModel.IotEventsPropertySends information about the detector model instance and the event that triggered the action to a specified asset property in AWS IoT SiteWise .A builder forCfnAlarmModel.IotSiteWisePropertyAn implementation forCfnAlarmModel.IotSiteWisePropertyInformation required to publish the MQTT message through the AWS IoT message broker.A builder forCfnAlarmModel.IotTopicPublishPropertyAn implementation forCfnAlarmModel.IotTopicPublishPropertyCalls a Lambda function, passing in information about the detector model instance and the event that triggered the action.A builder forCfnAlarmModel.LambdaPropertyAn implementation forCfnAlarmModel.LambdaPropertyInformation needed to configure the payload.A builder forCfnAlarmModel.PayloadPropertyAn implementation forCfnAlarmModel.PayloadPropertyA rule that compares an input property value to a threshold value with a comparison operator.A builder forCfnAlarmModel.SimpleRulePropertyAn implementation forCfnAlarmModel.SimpleRulePropertyInformation required to publish the Amazon SNS message.A builder forCfnAlarmModel.SnsPropertyAn implementation forCfnAlarmModel.SnsPropertySends information about the detector model instance and the event that triggered the action to an Amazon SQS queue.A builder forCfnAlarmModel.SqsPropertyAn implementation forCfnAlarmModel.SqsPropertyProperties for defining aCfnAlarmModel.A builder forCfnAlarmModelPropsAn implementation forCfnAlarmModelPropsA CloudFormationAWS::IoTEvents::DetectorModel.An action to be performed when theconditionis TRUE.A builder forCfnDetectorModel.ActionPropertyAn implementation forCfnDetectorModel.ActionPropertyA structure that contains timestamp information.A builder forCfnDetectorModel.AssetPropertyTimestampPropertyAn implementation forCfnDetectorModel.AssetPropertyTimestampPropertyA structure that contains value information.A builder forCfnDetectorModel.AssetPropertyValuePropertyAn implementation forCfnDetectorModel.AssetPropertyValuePropertyA structure that contains an asset property value.A builder forCfnDetectorModel.AssetPropertyVariantPropertyAn implementation forCfnDetectorModel.AssetPropertyVariantPropertyA fluent builder forCfnDetectorModel.Information needed to clear the timer.A builder forCfnDetectorModel.ClearTimerPropertyAn implementation forCfnDetectorModel.ClearTimerPropertyInformation that defines how a detector operates.A builder forCfnDetectorModel.DetectorModelDefinitionPropertyAn implementation forCfnDetectorModel.DetectorModelDefinitionPropertyDefines an action to write to the Amazon DynamoDB table that you created.A builder forCfnDetectorModel.DynamoDBPropertyAn implementation forCfnDetectorModel.DynamoDBPropertyDefines an action to write to the Amazon DynamoDB table that you created.A builder forCfnDetectorModel.DynamoDBv2PropertyAn implementation forCfnDetectorModel.DynamoDBv2PropertySpecifies theactionsto be performed when theconditionevaluates to TRUE.A builder forCfnDetectorModel.EventPropertyAn implementation forCfnDetectorModel.EventPropertySends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream.A builder forCfnDetectorModel.FirehosePropertyAn implementation forCfnDetectorModel.FirehosePropertySends an AWS IoT Events input, passing in information about the detector model instance and the event that triggered the action.A builder forCfnDetectorModel.IotEventsPropertyAn implementation forCfnDetectorModel.IotEventsPropertySends information about the detector model instance and the event that triggered the action to a specified asset property in AWS IoT SiteWise .A builder forCfnDetectorModel.IotSiteWisePropertyAn implementation forCfnDetectorModel.IotSiteWisePropertyInformation required to publish the MQTT message through the AWS IoT message broker.A builder forCfnDetectorModel.IotTopicPublishPropertyAn implementation forCfnDetectorModel.IotTopicPublishPropertyCalls a Lambda function, passing in information about the detector model instance and the event that triggered the action.A builder forCfnDetectorModel.LambdaPropertyAn implementation forCfnDetectorModel.LambdaPropertyWhen entering this state, perform theseactionsif theconditionis TRUE.A builder forCfnDetectorModel.OnEnterPropertyAn implementation forCfnDetectorModel.OnEnterPropertyWhen exiting this state, perform theseactionsif the specifiedconditionisTRUE.A builder forCfnDetectorModel.OnExitPropertyAn implementation forCfnDetectorModel.OnExitPropertySpecifies the actions performed when theconditionevaluates to TRUE.A builder forCfnDetectorModel.OnInputPropertyAn implementation forCfnDetectorModel.OnInputPropertyInformation needed to configure the payload.A builder forCfnDetectorModel.PayloadPropertyAn implementation forCfnDetectorModel.PayloadPropertyInformation required to reset the timer.A builder forCfnDetectorModel.ResetTimerPropertyAn implementation forCfnDetectorModel.ResetTimerPropertyInformation needed to set the timer.A builder forCfnDetectorModel.SetTimerPropertyAn implementation forCfnDetectorModel.SetTimerPropertyInformation about the variable and its new value.A builder forCfnDetectorModel.SetVariablePropertyAn implementation forCfnDetectorModel.SetVariablePropertyInformation required to publish the Amazon SNS message.A builder forCfnDetectorModel.SnsPropertyAn implementation forCfnDetectorModel.SnsPropertySends information about the detector model instance and the event that triggered the action to an Amazon SQS queue.A builder forCfnDetectorModel.SqsPropertyAn implementation forCfnDetectorModel.SqsPropertyInformation that defines a state of a detector.A builder forCfnDetectorModel.StatePropertyAn implementation forCfnDetectorModel.StatePropertySpecifies the actions performed and the next state entered when aconditionevaluates to TRUE.A builder forCfnDetectorModel.TransitionEventPropertyAn implementation forCfnDetectorModel.TransitionEventPropertyProperties for defining aCfnDetectorModel.A builder forCfnDetectorModelPropsAn implementation forCfnDetectorModelPropsA CloudFormationAWS::IoTEvents::Input.The attributes from the JSON payload that are made available by the input.A builder forCfnInput.AttributePropertyAn implementation forCfnInput.AttributePropertyA fluent builder forCfnInput.The definition of the input.A builder forCfnInput.InputDefinitionPropertyAn implementation forCfnInput.InputDefinitionPropertyProperties for defining aCfnInput.A builder forCfnInputPropsAn implementation forCfnInputProps(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 forDetectorModelPropsAn implementation forDetectorModelProps(experimental) Specifies the actions to be performed when the condition evaluates totrue.A builder forEventAn 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 forInputPropsAn 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 forStatePropsAn implementation forStateProps(experimental) Properties for options of state transition.A builder forTransitionOptionsAn implementation forTransitionOptions