detector_models
Creates, updates, deletes or gets a detector_model resource or lists detector_models in a region
Overview
| Name | detector_models |
| Type | Resource |
| Description | The AWS::IoTEvents::DetectorModel resource creates a detector model. You create a *detector model* (a model of your equipment or process) using *states*. For each state, you define conditional (Boolean) logic that evaluates the incoming inputs to detect significant events. When an event is detected, it can change the state or trigger custom-built or predefined actions using other AWS services. You can define additional events that trigger actions when entering or exiting a state and, optionally, when a condition is met. For more information, see [How to Use](https://docs.aws.amazon.com/iotevents/latest/developerguide/how-to-use-iotevents.html) in the *Developer Guide*. When you successfully update a detector model (using the ITE console, ITE API or CLI commands, or CFN) all detector instances created by the model are reset to their initial states. (The detector's ``state``, and the values of any variables and timers are reset.) When you successfully update a detector model (using the ITE console, ITE API or CLI commands, or CFN) the version number of the detector model is incremented. (A detector model with version number 1 before the update has version number 2 after the update succeeds.) If you attempt to update a detector model using CFN and the update does not succeed, the system may, in some cases, restore the original detector model. When this occurs, the detector model's version is incremented twice (for example, from version 1 to version 3) and the detector instances are reset. Also, be aware that if you attempt to update several detector models at once using CFN, some updates may succeed and others fail. In this case, the effects on each detector model's detector instances and version number depend on whether the update succeeded or failed, with the results as stated. |
| Id | awscc.iotevents.detector_models |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
detector_model_definition | object | Information that defines how a detector operates. |
detector_model_description | string | A brief description of the detector model. |
detector_model_name | string | The name of the detector model. |
evaluation_method | string | Information about the order in which events are evaluated and how actions are executed. |
key | string | The value used to identify a detector instance. When a device or system sends input, a new detector instance with a unique key value is created. ITE can continue to route input to its corresponding detector instance based on this identifying information. <br />This parameter uses a JSON-path expression to select the attribute-value pair in the message payload that is used for identification. To route the message to the correct detector instance, the device must send a message payload that contains the same attribute-value. |
role_arn | string | The ARN of the role that grants permission to ITE to perform its operations. |
tags | array | An array of key-value pairs to apply to this resource.<br />For more information, see [Tag](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html). |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
detector_model_name | string | The name of the detector model. |
region | string | AWS region. |
For more information, see AWS::IoTEvents::DetectorModel.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | detector_models | INSERT | DetectorModelDefinition, RoleArn, region |
delete_resource | detector_models | DELETE | Identifier, region |
update_resource | detector_models | UPDATE | Identifier, PatchDocument, region |
list_resources | detector_models_list_only | SELECT | region |
get_resource | detector_models | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual detector_model.
SELECT
region,
detector_model_definition,
detector_model_description,
detector_model_name,
evaluation_method,
key,
role_arn,
tags
FROM awscc.iotevents.detector_models
WHERE
region = 'us-east-1' AND
Identifier = '{{ detector_model_name }}';
Lists all detector_models in a region.
SELECT
region,
detector_model_name
FROM awscc.iotevents.detector_models_list_only
WHERE
region = 'us-east-1';
INSERT example
Use the following StackQL query and manifest file to create a new detector_model resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.iotevents.detector_models (
DetectorModelDefinition,
RoleArn,
region
)
SELECT
'{{ detector_model_definition }}',
'{{ role_arn }}',
'{{ region }}';
/*+ create */
INSERT INTO awscc.iotevents.detector_models (
DetectorModelDefinition,
DetectorModelDescription,
DetectorModelName,
EvaluationMethod,
Key,
RoleArn,
Tags,
region
)
SELECT
'{{ detector_model_definition }}',
'{{ detector_model_description }}',
'{{ detector_model_name }}',
'{{ evaluation_method }}',
'{{ key }}',
'{{ role_arn }}',
'{{ tags }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: detector_model
props:
- name: detector_model_definition
value:
initial_state_name: '{{ initial_state_name }}'
states:
- on_enter:
events:
- actions:
- clear_timer:
timer_name: '{{ timer_name }}'
dynamo_db:
hash_key_field: '{{ hash_key_field }}'
hash_key_type: '{{ hash_key_type }}'
hash_key_value: '{{ hash_key_value }}'
operation: '{{ operation }}'
payload:
content_expression: '{{ content_expression }}'
type: '{{ type }}'
payload_field: '{{ payload_field }}'
range_key_field: '{{ range_key_field }}'
range_key_type: '{{ range_key_type }}'
range_key_value: '{{ range_key_value }}'
table_name: '{{ table_name }}'
dynamo_dbv2:
payload: null
table_name: '{{ table_name }}'
firehose:
delivery_stream_name: '{{ delivery_stream_name }}'
payload: null
separator: '{{ separator }}'
iot_events:
input_name: '{{ input_name }}'
payload: null
iot_site_wise:
asset_id: '{{ asset_id }}'
entry_id: '{{ entry_id }}'
property_alias: '{{ property_alias }}'
property_id: '{{ property_id }}'
property_value:
quality: '{{ quality }}'
timestamp:
offset_in_nanos: '{{ offset_in_nanos }}'
time_in_seconds: '{{ time_in_seconds }}'
value:
boolean_value: '{{ boolean_value }}'
double_value: '{{ double_value }}'
integer_value: '{{ integer_value }}'
string_value: '{{ string_value }}'
iot_topic_publish:
mqtt_topic: '{{ mqtt_topic }}'
payload: null
lambda:
function_arn: '{{ function_arn }}'
payload: null
reset_timer:
timer_name: '{{ timer_name }}'
set_timer:
duration_expression: '{{ duration_expression }}'
seconds: '{{ seconds }}'
timer_name: '{{ timer_name }}'
set_variable:
value: '{{ value }}'
variable_name: '{{ variable_name }}'
sns:
payload: null
target_arn: '{{ target_arn }}'
sqs:
payload: null
queue_url: '{{ queue_url }}'
use_base64: '{{ use_base64 }}'
condition: '{{ condition }}'
event_name: '{{ event_name }}'
on_exit:
events:
- null
on_input:
events:
- null
transition_events:
- actions:
- null
condition: '{{ condition }}'
event_name: '{{ event_name }}'
next_state: '{{ next_state }}'
state_name: '{{ state_name }}'
- name: detector_model_description
value: '{{ detector_model_description }}'
- name: detector_model_name
value: '{{ detector_model_name }}'
- name: evaluation_method
value: '{{ evaluation_method }}'
- name: key
value: '{{ key }}'
- name: role_arn
value: '{{ role_arn }}'
- name: tags
value:
- key: '{{ key }}'
value: '{{ value }}'
UPDATE example
Use the following StackQL query and manifest file to update a detector_model resource, using stack-deploy.
/*+ update */
UPDATE awscc.iotevents.detector_models
SET PatchDocument = string('{{ {
"DetectorModelDefinition": detector_model_definition,
"DetectorModelDescription": detector_model_description,
"EvaluationMethod": evaluation_method,
"RoleArn": role_arn,
"Tags": tags
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ detector_model_name }}';
DELETE example
/*+ delete */
DELETE FROM awscc.iotevents.detector_models
WHERE
Identifier = '{{ detector_model_name }}' AND
region = 'us-east-1';
Permissions
To operate on the detector_models resource, the following permissions are required:
- Create
- Read
- Update
- Delete
- List
iotevents:CreateDetectorModel,
iotevents:UpdateInputRouting,
iotevents:DescribeDetectorModel,
iotevents:ListTagsForResource,
iotevents:TagResource,
iam:PassRole
iotevents:DescribeDetectorModel,
iotevents:ListTagsForResource
iotevents:UpdateDetectorModel,
iotevents:UpdateInputRouting,
iotevents:DescribeDetectorModel,
iotevents:ListTagsForResource,
iotevents:UntagResource,
iotevents:TagResource,
iam:PassRole
iotevents:DeleteDetectorModel,
iotevents:DescribeDetectorModel
iotevents:ListDetectorModels