

# AWS CLI를 사용한 AWS IoT Events 예시
<a name="cli_iot-events_code_examples"></a>

다음 코드 예시는 AWS IoT Events와 함께 AWS Command Line Interface를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다.

*작업*은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

**Topics**
+ [작업](#actions)

## 작업
<a name="actions"></a>

### `batch-put-message`
<a name="iot-events_BatchPutMessage_cli_topic"></a>

다음 코드 예시에서는 `batch-put-message`의 사용 방법을 보여줍니다.

**AWS CLI**  
**AWS IoT Events로 메시지(입력) 전송**  
다음 `batch-put-message` 예시에서는 AWS IoT Events 시스템으로 메시지 세트를 전송합니다. 각 메시지 페이로드는 지정한 입력(`inputName`)으로 변환되고 해당 입력을 모니터링하는 모든 탐지기로 수집됩니다. 메시지가 여러 개 전송되는 경우 메시지가 처리되는 순서가 보장되지 않습니다. 순서를 보장하려면 메시지를 한 번에 하나씩 보내고 응답이 성공할 때까지 기다려야 합니다.  

```
aws iotevents-data batch-put-message \
    --cli-input-json file://highPressureMessage.json
```
`highPressureMessage.json`의 콘텐츠:  

```
{
    "messages": [
        {
            "messageId": "00001",
            "inputName": "PressureInput",
            "payload": "{\"motorid\": \"Fulton-A32\", \"sensorData\": {\"pressure\": 80, \"temperature\": 39} }"
        }
    ]
}
```
출력:  

```
{
    "BatchPutMessageErrorEntries": []
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [BatchPutMessage](https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_BatchPutMessage.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [BatchPutMessage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/batch-put-message.html)를 참조하세요.

### `batch-update-detector`
<a name="iot-events_BatchUpdateDetector_cli_topic"></a>

다음 코드 예시에서는 `batch-update-detector`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탐지기(인스턴스) 업데이트**  
다음 `batch-update-detector` 예시에서는 지정된 탐지기 모델의 하나 이상의 탐지기(인스턴스)의 상태, 변숫값 및 타이머 설정을 업데이트합니다.  

```
aws iotevents-data batch-update-detector \
    --cli-input-json file://budFulton-A32.json
```
`budFulton-A32.json`의 콘텐츠:  

```
{
    "detectors": [
        {
            "messageId": "00001",
            "detectorModelName": "motorDetectorModel",
            "keyValue": "Fulton-A32",
            "state": {
                "stateName": "Normal",
                "variables": [
                    {
                        "name": "pressureThresholdBreached",
                        "value": "0"
                    }
                ],
                "timers": [
                ]
            }
        }
    ]
}
```
출력:  

```
{
    "batchUpdateDetectorErrorEntries": []
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [BatchUpdateDetector](https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_BatchUpdateDetector.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [BatchUpdateDetector](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/batch-update-detector.html)를 참조하세요.

### `create-detector-model`
<a name="iot-events_CreateDetectorModel_cli_topic"></a>

다음 코드 예시에서는 `create-detector-model`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탐지기 모델 생성**  
다음 `create-detector-model` 예시에서는 파라미터 파일에 지정된 구성을 사용하여 탐지기 모델을 생성합니다.  

```
aws iotevents create-detector-model  \
    --cli-input-json file://motorDetectorModel.json
```
`motorDetectorModel.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 &gt; 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "$variable.pressureThresholdBreached + 3"
                                    }
                                }
                            ],
                            "nextState": "Dangerous"
                        }
                    ]
                }
            },
            {
                "stateName": "Dangerous",
                "onEnter": {
                    "events": [
                        {
                            "eventName": "Pressure Threshold Breached",
                            "condition": "$variable.pressureThresholdBreached &gt; 1",
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-east-1:123456789012:underPressureAction"
                                    }
                                }
                            ]
                        }
                    ]
                },
                "onInput": {
                    "events": [
                        {
                            "eventName": "Overpressurized",
                            "condition": "$input.PressureInput.sensorData.pressure &gt; 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "3"
                                    }
                                }
                            ]
                        },
                        {
                            "eventName": "Pressure Okay",
                            "condition": "$input.PressureInput.sensorData.pressure &lt;= 70",
                            "actions": [
                                {
                                    "setVariable": {
                                        "variableName": "pressureThresholdBreached",
                                        "value": "$variable.pressureThresholdBreached - 1"
                                    }
                                }
                            ]
                        }
                    ],
                    "transitionEvents": [
                        {
                            "eventName": "BackToNormal",
                            "condition": "$input.PressureInput.sensorData.pressure &lt;= 70 &amp;&amp; $variable.pressureThresholdBreached &lt;= 1",
                            "nextState": "Normal"
                        }
                    ]
                },
                "onExit": {
                    "events": [
                        {
                            "eventName": "Normal Pressure Restored",
                            "condition": "true",
                            "actions": [
                                {
                                    "sns": {
                                        "targetArn": "arn:aws:sns:us-east-1:123456789012:pressureClearedAction"
                                    }
                                }
                            ]
                        }
                    ]
                }
            }
        ],
        "initialStateName": "Normal"
    },
    "key": "motorid",
    "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole"
}
```
출력:  

```
{
    "detectorModelConfiguration": {
        "status": "ACTIVATING",
        "lastUpdateTime": 1560796816.077,
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "creationTime": 1560796816.077,
        "detectorModelArn": "arn:aws:iotevents:us-west-2:123456789012:detectorModel/motorDetectorModel",
        "key": "motorid",
        "detectorModelName": "motorDetectorModel",
        "detectorModelVersion": "1"
    }
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [CreateDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_CreateDetectorModel.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [CreateDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/create-detector-model.html)을 참조하세요.

### `create-input`
<a name="iot-events_CreateInput_cli_topic"></a>

다음 코드 예시에서는 `create-input`의 사용 방법을 보여줍니다.

**AWS CLI**  
**입력 생성**  
다음 `create-input` 예시에서는 입력을 생성합니다.  

```
aws iotevents create-input  \
    --cli-input-json file://pressureInput.json
```
`pressureInput.json`의 콘텐츠:  

```
{
    "inputName": "PressureInput",
    "inputDescription": "Pressure readings from a motor",
    "inputDefinition": {
        "attributes": [
            { "jsonPath": "sensorData.pressure" },
            { "jsonPath": "motorid" }
        ]
    }
}
```
출력:  

```
{
    "inputConfiguration": {
        "status": "ACTIVE",
        "inputArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
        "lastUpdateTime": 1560795312.542,
        "creationTime": 1560795312.542,
        "inputName": "PressureInput",
        "inputDescription": "Pressure readings from a motor"
    }
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [CreateInput](https://docs.aws.amazon.com/iotevents/latest/apireference/API_CreateInput)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [CreateInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/create-input.html)을 참조하세요.

### `delete-detector-model`
<a name="iot-events_DeleteDetectorModel_cli_topic"></a>

다음 코드 예시에서는 `delete-detector-model`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탐지기 모델 삭제**  
다음 `delete-detector-model` 예시에서는 지정된 탐지기 모델을 삭제합니다. 탐지기 모델의 모든 활성 인스턴스도 삭제됩니다.  

```
aws iotevents delete-detector-model \
    --detector-model-name motorDetectorModel
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS IoT Events API 참조*의 [DeleteDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DeleteDetectorModel)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeleteDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/delete-detector-model.html)을 참조하세요.

### `delete-input`
<a name="iot-events_DeleteInput_cli_topic"></a>

다음 코드 예시에서는 `delete-input`의 사용 방법을 보여줍니다.

**AWS CLI**  
**입력 삭제**  
다음 `delete-input` 예시에서는 지정된 입력을 삭제합니다.  

```
aws iotevents delete-input \
    --input-name PressureInput
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS IoT Events API 참조*의 [DeleteInput](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DeleteInput)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeleteInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/delete-input.html)을 참조하세요.

### `describe-detector-model`
<a name="iot-events_DescribeDetectorModel_cli_topic"></a>

다음 코드 예시에서는 `describe-detector-model`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탐지기 모델 정보 가져오기**  
다음 `describe-detector-model` 예시에서는 지정된 탐지기 모델의 세부 정보를 표시합니다. `version` 파라미터가 지정되지 않았으므로 최신 버전 정보가 반환됩니다.  

```
aws iotevents describe-detector-model \
    --detector-model-name motorDetectorModel
```
출력:  

```
{
    "detectorModel": {
        "detectorModelConfiguration": {
            "status": "ACTIVE",
            "lastUpdateTime": 1560796816.077,
            "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
            "creationTime": 1560796816.077,
            "detectorModelArn": "arn:aws:iotevents:us-west-2:123456789012:detectorModel/motorDetectorModel",
            "key": "motorid",
            "detectorModelName": "motorDetectorModel",
            "detectorModelVersion": "1"
        },
        "detectorModelDefinition": {
            "states": [
                {
                    "onInput": {
                        "transitionEvents": [
                            {
                                "eventName": "Overpressurized",
                                "actions": [
                                    {
                                        "setVariable": {
                                            "variableName": "pressureThresholdBreached",
                                            "value": "$variable.pressureThresholdBreached + 3"
                                        }
                                    }
                                ],
                                "condition": "$input.PressureInput.sensorData.pressure > 70",
                                "nextState": "Dangerous"
                            }
                        ],
                        "events": []
                    },
                    "stateName": "Normal",
                    "onEnter": {
                        "events": [
                            {
                                "eventName": "init",
                                "actions": [
                                    {
                                        "setVariable": {
                                            "variableName": "pressureThresholdBreached",
                                            "value": "0"
                                        }
                                    }
                                ],
                                "condition": "true"
                            }
                        ]
                    },
                    "onExit": {
                        "events": []
                    }
                },
                {
                    "onInput": {
                        "transitionEvents": [
                            {
                                "eventName": "BackToNormal",
                                "actions": [],
                                "condition": "$input.PressureInput.sensorData.pressure <= 70 && $variable.pressureThresholdBreached <= 1",
                                "nextState": "Normal"
                            }
                        ],
                        "events": [
                            {
                                "eventName": "Overpressurized",
                                "actions": [
                                    {
                                        "setVariable": {
                                            "variableName": "pressureThresholdBreached",
                                            "value": "3"
                                        }
                                    }
                                ],
                                "condition": "$input.PressureInput.sensorData.pressure > 70"
                            },
                            {
                                "eventName": "Pressure Okay",
                                "actions": [
                                    {
                                        "setVariable": {
                                            "variableName": "pressureThresholdBreached",
                                            "value": "$variable.pressureThresholdBreached - 1"
                                        }
                                    }
                                ],
                                "condition": "$input.PressureInput.sensorData.pressure <= 70"
                            }
                        ]
                    },
                    "stateName": "Dangerous",
                    "onEnter": {
                        "events": [
                            {
                                "eventName": "Pressure Threshold Breached",
                                "actions": [
                                    {
                                        "sns": {
                                            "targetArn": "arn:aws:sns:us-east-1:123456789012:underPressureAction"
                                        }
                                    }
                                ],
                                "condition": "$variable.pressureThresholdBreached > 1"
                            }
                        ]
                    },
                    "onExit": {
                        "events": [
                            {
                                "eventName": "Normal Pressure Restored",
                                "actions": [
                                    {
                                        "sns": {
                                            "targetArn": "arn:aws:sns:us-east-1:123456789012:pressureClearedAction"
                                        }
                                    }
                                ],
                                "condition": "true"
                            }
                        ]
                    }
                }
            ],
            "initialStateName": "Normal"
        }
    }
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [DescribeDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DescribeDetectorModel)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DescribeDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/describe-detector-model.html)을 참조하세요.

### `describe-detector`
<a name="iot-events_DescribeDetector_cli_topic"></a>

다음 코드 예시에서는 `describe-detector`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탐지기(인스턴스) 정보 가져오기**  
다음 `describe-detector` 예시에서는 지정된 탐지기(인스턴스)의 세부 정보를 표시합니다.  

```
aws iotevents-data describe-detector \
    --detector-model-name motorDetectorModel \
    --key-value "Fulton-A32"
```
출력:  

```
{
    "detector": {
        "lastUpdateTime": 1560797852.776,
        "creationTime": 1560797852.775,
        "state": {
            "variables": [
                {
                    "name": "pressureThresholdBreached",
                    "value": "3"
                }
            ],
            "stateName": "Dangerous",
            "timers": []
        },
        "keyValue": "Fulton-A32",
        "detectorModelName": "motorDetectorModel",
        "detectorModelVersion": "1"
    }
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [DescribeDetector](https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_DescribeDetector)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DescribeDetector](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/describe-detector.html)를 참조하세요.

### `describe-input`
<a name="iot-events_DescribeInput_cli_topic"></a>

다음 코드 예시에서는 `describe-input`의 사용 방법을 보여줍니다.

**AWS CLI**  
**입력 정보 가져오기**  
다음 `describe-input` 예시에서는 지정된 입력의 세부 정보를 표시합니다.  

```
aws iotevents describe-input \
    --input-name PressureInput
```
출력:  

```
{
    "input": {
        "inputConfiguration": {
            "status": "ACTIVE",
            "inputArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
            "lastUpdateTime": 1560795312.542,
            "creationTime": 1560795312.542,
            "inputName": "PressureInput",
            "inputDescription": "Pressure readings from a motor"
        },
        "inputDefinition": {
            "attributes": [
                {
                    "jsonPath": "sensorData.pressure"
                },
                {
                    "jsonPath": "motorid"
                }
            ]
        }
    }
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [DescribeInput](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DescribeInput)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DescribeInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/describe-input.html)을 참조하세요.

### `describe-logging-options`
<a name="iot-events_DescribeLoggingOptions_cli_topic"></a>

다음 코드 예시에서는 `describe-logging-options`의 사용 방법을 보여줍니다.

**AWS CLI**  
**로깅 설정 정보 가져오기**  
다음 `describe-logging-options` 예시에서는 현재 AWS IoT Events 로깅 옵션의 현재 설정을 가져옵니다.  

```
aws iotevents describe-logging-options
```
출력:  

```
{
    "loggingOptions": {
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "enabled": false,
        "level": "ERROR"
    }
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [DescribeLoggingOptions](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DescribeLoggingOptions)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DescribeLoggingOptions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/describe-logging-options.html)를 참조하세요.

### `list-detector-model-versions`
<a name="iot-events_ListDetectorModelVersions_cli_topic"></a>

다음 코드 예시에서는 `list-detector-model-versions`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탐지기 모델 버전 정보 가져오기**  
다음 `list-detector-model-versions` 예시에서는 탐지기 모델의 모든 버전을 나열합니다. 각 탐지기 모델 버전과 연결된 메타데이터만 반환됩니다.  

```
aws iotevents list-detector-model-versions \
    --detector-model-name motorDetectorModel
```
출력:  

```
{
    "detectorModelVersionSummaries": [
        {
            "status": "ACTIVE",
            "lastUpdateTime": 1560796816.077,
            "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
            "creationTime": 1560796816.077,
            "detectorModelArn": "arn:aws:iotevents:us-west-2:123456789012:detectorModel/motorDetectorModel",
            "detectorModelName": "motorDetectorModel",
            "detectorModelVersion": "1"
        }
    ]
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [ListDetectorModelVersions](https://docs.aws.amazon.com/iotevents/latest/apireference/API_ListDetectorModelVersions)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListDetectorModelVersions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-detector-model-versions.html)를 참조하세요.

### `list-detector-models`
<a name="iot-events_ListDetectorModels_cli_topic"></a>

다음 코드 예시에서는 `list-detector-models`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탐지기 모델 목록 가져오기**  
다음 `list-detector-models` 예시에서는 생성한 탐지기 모델을 나열합니다. 각 탐지기 모델과 연결된 메타데이터만 반환됩니다.  

```
aws iotevents list-detector-models
```
출력:  

```
{
    "detectorModelSummaries": [
        {
            "detectorModelName": "motorDetectorModel",
            "creationTime": 1552072424.212
            "detectorModelDescription": "Detect overpressure in a motor."
        }
    ]
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [ListDetectorModels](https://docs.aws.amazon.com/iotevents/latest/apireference/API_ListDetectorModels)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListDetectorModels](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-detector-models.html)를 참조하세요.

### `list-detectors`
<a name="iot-events_ListDetectors_cli_topic"></a>

다음 코드 예시에서는 `list-detectors`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탐지기 모델의 탐지기 목록 가져오기**  
다음 `list-detectors` 예시에서는 계정의 탐지기(탐지기 모델의 인스턴스)를 나열합니다.  

```
aws iotevents-data list-detectors \
    --detector-model-name motorDetectorModel
```
출력:  

```
{
    "detectorSummaries": [
        {
            "lastUpdateTime": 1558129925.2,
            "creationTime": 1552073155.527,
            "state": {
                "stateName": "Normal"
            },
            "keyValue": "Fulton-A32",
            "detectorModelName": "motorDetectorModel",
            "detectorModelVersion": "1"
        }
    ]
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [ListDetectors](https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_ListDetectors)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListDetectors](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-detectors.html)를 참조하세요.

### `list-inputs`
<a name="iot-events_ListInputs_cli_topic"></a>

다음 코드 예시에서는 `list-inputs`의 사용 방법을 보여줍니다.

**AWS CLI**  
**입력 나열**  
다음 `list-inputs` 예시에서는 계정에서 생성한 입력을 나열합니다.  

```
aws iotevents list-inputs
```
이 명령은 출력을 생성하지 않습니다. 출력:  

```
{
    {
        "status": "ACTIVE",
        "inputArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
        "lastUpdateTime": 1551742986.768,
        "creationTime": 1551742986.768,
        "inputName": "PressureInput",
        "inputDescription": "Pressure readings from a motor"
    }
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [ListInputs](https://docs.aws.amazon.com/iotevents/latest/apireference/API_ListInputs)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListInputs](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-inputs.html)를 참조하세요.

### `list-tags-for-resource`
<a name="iot-events_ListTagsForResource_cli_topic"></a>

다음 코드 예시에서는 `list-tags-for-resource`의 사용 방법을 보여줍니다.

**AWS CLI**  
**리소스에 할당된 태그 나열**  
다음 `list-tags-for-resource` 예시에서는 리소스에 할당한 태그 키 이름과 값을 나열합니다.  

```
aws iotevents list-tags-for-resource \
    --resource-arn "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput"
```
출력:  

```
{
    "tags": [
        {
            "value": "motor",
            "key": "deviceType"
        }
    ]
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [ListTagsForResource](https://docs.aws.amazon.com/iotevents/latest/apireference/API_ListTagsForResource)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/list-tags-for-resource.html)를 참조하세요.

### `put-logging-options`
<a name="iot-events_PutLoggingOptions_cli_topic"></a>

다음 코드 예시에서는 `put-logging-options`의 사용 방법을 보여줍니다.

**AWS CLI**  
**로깅 옵션 설정**  
다음 `put-logging-options` 예시에서는 AWS IoT Events의 로깅 옵션을 설정하거나 업데이트합니다. `loggingOptions` field, it can take up to one minute for the change to take effect. Also, if you change the policy attached to the role you specified in the ``roleArn` 필드의 값을 업데이트하는 경우(예: 잘못된 정책을 수정하는 경우) 변경 사항이 적용되려면 최대 5분이 걸릴 수 있습니다.  

```
aws iotevents put-logging-options \
    --cli-input-json file://logging-options.json
```
`logging-options.json`의 콘텐츠:  

```
{
    "loggingOptions": {
        "roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole",
        "level": "DEBUG",
        "enabled": true,
        "detectorDebugOptions": [
            {
                "detectorModelName": "motorDetectorModel",
                "keyValue": "Fulton-A32"
            }
        ]
    }
}
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS IoT Events API 참조*의 [PutLoggingOptions](https://docs.aws.amazon.com/iotevents/latest/apireference/API_PutLoggingOptions)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [PutLoggingOptions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/put-logging-options.html)를 참조하세요.

### `tag-resource`
<a name="iot-events_TagResource_cli_topic"></a>

다음 코드 예시에서는 `tag-resource`의 사용 방법을 보여줍니다.

**AWS CLI**  
**리소스에 태그 추가**  
다음 `tag-resource` 예시에서는 지정된 리소스에 연결된 태그를 추가하거나 수정합니다(키 `deviceType`이 이미 있는 경우).  

```
aws iotevents tag-resource \
    --cli-input-json file://pressureInput.tag.json
```
`pressureInput.tag.json`의 콘텐츠:  

```
{
    "resourceArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
    "tags": [
        {
            "key": "deviceType",
            "value": "motor"
        }
    ]
}
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS IoT Events API 참조*의 [TagResource](https://docs.aws.amazon.com/iotevents/latest/apireference/API_TagResource)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/tag-resource.html)를 참조하세요.

### `untag-resource`
<a name="iot-events_UntagResource_cli_topic"></a>

다음 코드 예시에서는 `untag-resource` 코드를 사용하는 방법을 보여줍니다.

**AWS CLI**  
**리소스에서 태그 제거**  
다음 `untag-resource` 예시에서는 지정된 리소스에서 지정된 키 이름이 있는 태그를 제거합니다.  

```
aws iotevents untag-resource \
    --resource-arn arn:aws:iotevents:us-west-2:123456789012:input/PressureInput \
    --tagkeys deviceType
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *AWS IoT Events API 참조*의 [UntagResource](https://docs.aws.amazon.com/iotevents/latest/apireference/API_UntagResource)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/untag-resource.html)를 참조하세요.

### `update-detector-model`
<a name="iot-events_UpdateDetectorModel_cli_topic"></a>

다음 코드 예시에서는 `update-detector-model`의 사용 방법을 보여줍니다.

**AWS CLI**  
**탐지기 모델 업데이트**  
다음 `update-detector-model` 예시에서는 지정된 탐지기 모델을 업데이트합니다. 이전 버전에서 생성된 탐지기(인스턴스)는 삭제된 다음 새 입력이 도착하면 다시 생성됩니다.  

```
aws iotevents update-detector-model \
    --cli-input-json file://motorDetectorModel.update.json
```
`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"
}
```
출력:  

```
{
    "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"
    }
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [UpdateDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_UpdateDetectorModel)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdateDetectorModel](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/update-detector-model.html)을 참조하세요.

### `update-input`
<a name="iot-events_UpdateInput_cli_topic"></a>

다음 코드 예시에서는 `update-input`의 사용 방법을 보여줍니다.

**AWS CLI**  
**입력 업데이트**  
다음 `update-input` 예시에서는 지정된 입력을 새 설명 및 정의로 업데이트합니다.  

```
aws iotevents update-input \
    --cli-input-json file://pressureInput.json
```
`pressureInput.json`의 콘텐츠:  

```
{
    "inputName": "PressureInput",
    "inputDescription": "Pressure readings from a motor",
    "inputDefinition": {
        "attributes": [
            { "jsonPath": "sensorData.pressure" },
            { "jsonPath": "motorid" }
        ]
    }
}
```
출력:  

```
{
    "inputConfiguration": {
        "status": "ACTIVE",
        "inputArn": "arn:aws:iotevents:us-west-2:123456789012:input/PressureInput",
        "lastUpdateTime": 1560795976.458,
        "creationTime": 1560795312.542,
        "inputName": "PressureInput",
        "inputDescription": "Pressure readings from a motor"
    }
}
```
자세한 내용은 *AWS IoT Events API 참조*의 [UpdateInput](https://docs.aws.amazon.com/iotevents/latest/apireference/API_UpdateInput)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdateInput](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iotevents/update-input.html)을 참조하세요.