interface InputProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.IoTEvents.InputProps |
Java | software.amazon.awscdk.services.iotevents.InputProps |
Python | aws_cdk.aws_iotevents.InputProps |
TypeScript (source) | @aws-cdk/aws-iotevents » InputProps |
Properties for defining an AWS IoT Events input.
Example
import * as iotevents from '@aws-cdk/aws-iotevents';
import * as actions from '@aws-cdk/aws-iotevents-actions';
import * as lambda from '@aws-cdk/aws-lambda';
declare const func: lambda.IFunction;
const input = new iotevents.Input(this, 'MyInput', {
inputName: 'my_input', // optional
attributeJsonPaths: ['payload.deviceId', 'payload.temperature'],
});
const warmState = new iotevents.State({
stateName: 'warm',
onEnter: [{
eventName: 'test-enter-event',
condition: iotevents.Expression.currentInput(input),
actions: [new actions.LambdaInvokeAction(func)], // optional
}],
onInput: [{ // optional
eventName: 'test-input-event',
actions: [new actions.LambdaInvokeAction(func)],
}],
onExit: [{ // optional
eventName: 'test-exit-event',
actions: [new actions.LambdaInvokeAction(func)],
}],
});
const coldState = new iotevents.State({
stateName: 'cold',
});
// transit to coldState when temperature is less than 15
warmState.transitionTo(coldState, {
eventName: 'to_coldState', // optional property, default by combining the names of the States
when: iotevents.Expression.lt(
iotevents.Expression.inputAttribute(input, 'payload.temperature'),
iotevents.Expression.fromString('15'),
),
executing: [new actions.LambdaInvokeAction(func)], // optional
});
// transit to warmState when temperature is greater than or equal to 15
coldState.transitionTo(warmState, {
when: iotevents.Expression.gte(
iotevents.Expression.inputAttribute(input, 'payload.temperature'),
iotevents.Expression.fromString('15'),
),
});
new iotevents.DetectorModel(this, 'MyDetectorModel', {
detectorModelName: 'test-detector-model', // optional
description: 'test-detector-model-description', // optional property, default is none
evaluationMethod: iotevents.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,
});
Properties
Name | Type | Description |
---|---|---|
attribute | string[] | An expression that specifies an attribute-value pair in a JSON structure. |
input | string | The name of the input. |
attributeJsonPaths
Type:
string[]
An expression that specifies an attribute-value pair in a JSON structure.
Use this to specify an attribute from the JSON payload that is made available by the input. Inputs are derived from messages sent to AWS IoT Events (BatchPutMessage). Each such message contains a JSON payload. The attribute (and its paired value) specified here are available for use in the condition expressions used by detectors.
inputName?
Type:
string
(optional, default: CloudFormation will generate a unique name of the input)
The name of the input.