Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

[ aws . iotevents ]

update-detector-model

Description

Updates a detector model. Detectors (instances) spawned by the previous version are deleted and then re-created as new inputs arrive.

See also: AWS API Documentation

See 'aws help' for descriptions of global parameters.

Synopsis

  update-detector-model
--detector-model-name <value>
--detector-model-definition <value>
[--detector-model-description <value>]
--role-arn <value>
[--evaluation-method <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

Options

--detector-model-name (string)

The name of the detector model that is updated.

--detector-model-definition (structure)

Information that defines how a detector operates.

JSON Syntax:

{
  "states": [
    {
      "stateName": "string",
      "onInput": {
        "events": [
          {
            "eventName": "string",
            "condition": "string",
            "actions": [
              {
                "setVariable": {
                  "variableName": "string",
                  "value": "string"
                },
                "sns": {
                  "targetArn": "string"
                },
                "iotTopicPublish": {
                  "mqttTopic": "string"
                },
                "setTimer": {
                  "timerName": "string",
                  "seconds": integer
                },
                "clearTimer": {
                  "timerName": "string"
                },
                "resetTimer": {
                  "timerName": "string"
                },
                "lambda": {
                  "functionArn": "string"
                },
                "iotEvents": {
                  "inputName": "string"
                },
                "sqs": {
                  "queueUrl": "string",
                  "useBase64": true|false
                },
                "firehose": {
                  "deliveryStreamName": "string",
                  "separator": "string"
                }
              }
              ...
            ]
          }
          ...
        ],
        "transitionEvents": [
          {
            "eventName": "string",
            "condition": "string",
            "actions": [
              {
                "setVariable": {
                  "variableName": "string",
                  "value": "string"
                },
                "sns": {
                  "targetArn": "string"
                },
                "iotTopicPublish": {
                  "mqttTopic": "string"
                },
                "setTimer": {
                  "timerName": "string",
                  "seconds": integer
                },
                "clearTimer": {
                  "timerName": "string"
                },
                "resetTimer": {
                  "timerName": "string"
                },
                "lambda": {
                  "functionArn": "string"
                },
                "iotEvents": {
                  "inputName": "string"
                },
                "sqs": {
                  "queueUrl": "string",
                  "useBase64": true|false
                },
                "firehose": {
                  "deliveryStreamName": "string",
                  "separator": "string"
                }
              }
              ...
            ],
            "nextState": "string"
          }
          ...
        ]
      },
      "onEnter": {
        "events": [
          {
            "eventName": "string",
            "condition": "string",
            "actions": [
              {
                "setVariable": {
                  "variableName": "string",
                  "value": "string"
                },
                "sns": {
                  "targetArn": "string"
                },
                "iotTopicPublish": {
                  "mqttTopic": "string"
                },
                "setTimer": {
                  "timerName": "string",
                  "seconds": integer
                },
                "clearTimer": {
                  "timerName": "string"
                },
                "resetTimer": {
                  "timerName": "string"
                },
                "lambda": {
                  "functionArn": "string"
                },
                "iotEvents": {
                  "inputName": "string"
                },
                "sqs": {
                  "queueUrl": "string",
                  "useBase64": true|false
                },
                "firehose": {
                  "deliveryStreamName": "string",
                  "separator": "string"
                }
              }
              ...
            ]
          }
          ...
        ]
      },
      "onExit": {
        "events": [
          {
            "eventName": "string",
            "condition": "string",
            "actions": [
              {
                "setVariable": {
                  "variableName": "string",
                  "value": "string"
                },
                "sns": {
                  "targetArn": "string"
                },
                "iotTopicPublish": {
                  "mqttTopic": "string"
                },
                "setTimer": {
                  "timerName": "string",
                  "seconds": integer
                },
                "clearTimer": {
                  "timerName": "string"
                },
                "resetTimer": {
                  "timerName": "string"
                },
                "lambda": {
                  "functionArn": "string"
                },
                "iotEvents": {
                  "inputName": "string"
                },
                "sqs": {
                  "queueUrl": "string",
                  "useBase64": true|false
                },
                "firehose": {
                  "deliveryStreamName": "string",
                  "separator": "string"
                }
              }
              ...
            ]
          }
          ...
        ]
      }
    }
    ...
  ],
  "initialStateName": "string"
}

--detector-model-description (string)

A brief description of the detector model.

--role-arn (string)

The ARN of the role that grants permission to AWS IoT Events to perform its operations.

--evaluation-method (string)

When set to SERIAL , variables are updated and event conditions evaluated in the order that the events are defined. When set to BATCH , variables are updated and events performed only after all event conditions are evaluated.

Possible values:

  • BATCH
  • SERIAL

--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

See 'aws help' for descriptions of global parameters.

Examples

To update a detector model

The following update-detector-model example updates the specified detector model. Detectors (instances) spawned by the previous version are deleted and then re-created as new inputs arrive.

aws iotevents update-detector-model \
    --cli-input-json file://motorDetectorModel.update.json

Contents of motorDetectorModel.update.json:

{
    "detectorModelName": "motorDetectorModel",
    "detectorModelDefinition": {
        "states": [
            {
                "stateName": "Normal",
                "onEnter": {
                    "events": [
                        {
                            "eventName": "init",
                            "condition": "true",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "0"
                                    }
                                }
                            ]
                        }
                    ]
                },
                "onInput": {
                    "transitionEvents": [
                        {
                            "eventName": "Overpressurized",
                            "condition": "$input.PressureInput.sensorData.pressure > 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "$variable.pressureThresholdBreached + 3"
                                    }
                                }
                            ],
                            "nextState": "Dangerous"
                        }
                    ]
                }
            },
            {
                "stateName": "Dangerous",
                "onEnter": {
                    "events": [
                        {
                            "eventName": "Pressure Threshold Breached",
                            "condition": "$variable.pressureThresholdBreached > 1",
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-east-1:123456789012:underPressureAction"
                                    }
                                }
                            ]
                        }
                    ]
                },
                "onInput": {
                    "events": [
                        {
                            "eventName": "Overpressurized",
                            "condition": "$input.PressureInput.sensorData.pressure > 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "3"
                                    }
                                }
                            ]
                        },
                        {
                            "eventName": "Pressure Okay",
                            "condition": "$input.PressureInput.sensorData.pressure <= 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "$variable.pressureThresholdBreached - 1"
                                    }
                                }
                            ]
                        }
                    ],
                    "transitionEvents": [
                        {
                            "eventName": "BackToNormal",
                            "condition": "$input.PressureInput.sensorData.pressure <= 70 && $variable.pressureThresholdBreached <= 1",
                            "nextState": "Normal"
                        }
                    ]
                },
                "onExit": {
                    "events": [
                        {
                            "eventName": "Normal Pressure Restored",
                            "condition": "true",
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-east-1:123456789012:pressureClearedAction"
                                    }
                                }
                            ]
                        }
                    ]
                }
            }
        ],
        "initialStateName": "Normal"
    },
    "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole"
}

Output:

{
    "detectorModelConfiguration": {
        "status": "ACTIVATING",
        "lastUpdateTime": 1560799387.719,
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "creationTime": 1560799387.719,
        "detectorModelArn": "arn:aws:iotevents:us-west-2:123456789012:detectorModel/motorDetectorModel",
        "key": "motorid",
        "detectorModelName": "motorDetectorModel",
        "detectorModelVersion": "2"
    }
}

For more information, see UpdateDetectorModel in the AWS IoT Events API Reference.

Output

detectorModelConfiguration -> (structure)

Information about how the detector model is configured.

detectorModelName -> (string)

The name of the detector model.

detectorModelVersion -> (string)

The version of the detector model.

detectorModelDescription -> (string)

A brief description of the detector model.

detectorModelArn -> (string)

The ARN of the detector model.

roleArn -> (string)

The ARN of the role that grants permission to AWS IoT Events to perform its operations.

creationTime -> (timestamp)

The time the detector model was created.

lastUpdateTime -> (timestamp)

The time the detector model was last updated.

status -> (string)

The status of the detector model.

key -> (string)

The input attribute key used to identify a device or system to create a detector (an instance of the detector model) and then to route each input received to the appropriate detector (instance). This parameter uses a JSON-path expression to specify the attribute-value pair in the message payload of each input that is used to identify the device associated with the input.

evaluationMethod -> (string)

When set to SERIAL , variables are updated and event conditions evaluated in the order that the events are defined. When set to BATCH , variables are updated and events performed only after all event conditions are evaluated.