目次
AWS IoT Events 完全ガイド v2.0
初心者から実務者向けの包括的解説
AWS IoT Events は、IoTセンサーデータから複雑なイベントパターンを検出し、アラート・自動復旧コマンドを実行する専用イベント処理エンジンです。有限状態機械(FSM)ベースのディテクターモデルで「3分以上75℃以上が続いたら過熱アラート」等の時間的・条件的な複雑なロジックをコードなしに定義し、SNS・SQS・Lambda・IoT Core にアクションを実行します。ただし ⚠️ End-of-Service: 2025-12-15 予定(2026-05-20 新規ユーザー受付終了)のため、EventBridge・Step Functions・Lambda への移行が必須です。
目次
- 概要
- IoT Events が解決する課題
- 主な特徴
- アーキテクチャ
- コアコンポーネント
- 主要ユースケース
- ディテクターモデル詳細
- 設定・操作の具体例
- アラームモデル
- 類似サービス比較表
- ベストプラクティス
- トラブルシューティング
- End-of-Service 移行ガイド
- 2025-2026 最新動向
- 学習リソース・参考文献
- 実装例・チェックリスト
- まとめ
概要
AWS IoT Events とは
AWS IoT Events は イベント駆動型の状態管理エンジン として機能し、以下を統合提供します:
- ディテクターモデル: 有限状態機械で複雑なイベント検出ロジック定義
- インプット: 複数センサー・IoT Core・IoT SiteWise からのデータ受信
- ステート管理: 時間的条件・複合条件での状態遷移
- トリガー・アクション: SNS・SQS・Lambda・Kinesis Firehose への自動実行
- スケーリング: 数百万デバイスの同時監視対応
- アラームモデル: 複数ディテクターの組み合わせアラーム管理
ユースケースの広がり
- 工場機械の温度・圧力・振動の複合アラート
- スマートホーム・スマートシティのセンサー異常検出
- 農業 IoT の土壌水分・気象複合条件トリガー
- インフラ施設の冷却・電力系統の異常検出
- 医療機器(IIoT)の状態変化追跡
IoT Events が解決する課題
| 課題 | 従来の方法 | IoT Events での解決 |
|---|---|---|
| 複合条件イベント検出 | Lambda で「温度 > 80℃ が 5 分以上継続」をコーディング。複雑化すると保守困難 | Detector Model でルールを JSON 定義。条件変更が簡単 |
| デバイスフリート状態管理 | 各デバイスの状態を DynamoDB で管理。手動コード必要 | IoT Events が自動状態追跡・遷移実行 |
| 時系列パターン検出 | 時間ウィンドウ・カウンター管理が複雑。バグ多発 | Timer・Event Counter で宣言的定義 |
| 複数アクション実行 | Lambda で SNS・SQS・DynamoDB 順序実行。複数実行の順序制御が困難 | アクションチェーン・並列実行を定義可能 |
| 大規模オートスケール | EC2・Lambda で手動スケーリング。コスト増加 | マネージドサービスで自動スケーリング |
| SiteWise 統合 | SiteWise のアラート機能が限定的。外部ツール必要 | SiteWise データからイベント検出・自動アクション |
主な特徴
✅ 有限状態機械(FSM)ベース
- 状態: NORMAL / HEATING / CRITICAL 等を定義
- 遷移: 条件で状態変更。Timer・Event Count ベース
- アクション: 状態進入・出入時に実行
✅ 複数インプット対応
- IoT Core MQTT トピック
- AWS IoT SiteWise アセット
- Lambda・API Gateway を経由したカスタムインプット
- BatchPutMessage API で外部アプリケーション統合
✅ 時間的条件制御
- タイマー: 状態滞在時間トリガー
- イベントカウンター: 条件発生 N 回でアクション
- ウィンドウ: 指定期間内のイベント集計
✅ 自動スケーリング
- ディテクター定義を一度作成
- 同一タイプのデバイス数に応じて自動スケーリング
- コスト効率的な運用
✅ アラームモデル
- 複数ディテクターの複合条件アラーム
- アラーム状態(DISABLED / ENABLED)管理
- アラーム抑制・再開コントロール
アーキテクチャ
┌──────────────────────────────────────────────────────────────┐
│ IoT デバイス・システム │
├──────────────────────────────────────────────────────────────┤
│ • センサーデータ(温度・圧力・振動) │
│ • IoT Core MQTT トピック │
│ • AWS IoT SiteWise (OPC-UA / Modbus) │
└──────────────────┬──────────────────────────────────────────┘
│
┌──────────▼──────────┐
│ AWS IoT Events │
├─────────────────────┤
│ ディテクターモデル │
│ • Input(複数) │
│ • State Tree │
│ • Transitions │
│ • Timers / Counters │
│ • Trigger │
│ • Actions │
└──────────┬──────────┘
│
┌───────────┼───────────┬─────────────┐
│ │ │ │
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
SNS SQS Lambda Kinesis IoT Core DynamoDB
Alert Send Compute Stream Publish Logs
コアコンポーネント
1. Input(インプット)
デバイス・センサーからのデータ入力定義。複数インプット可。
{
"inputName": "SensorInput",
"inputDefinition": {
"attributes": [
{ "jsonPath": "deviceId" },
{ "jsonPath": "temperature" },
{ "jsonPath": "pressure" },
{ "jsonPath": "timestamp" }
]
}
}
属性タイプ: STRING / INTEGER / FLOAT / BOOLEAN / TIMESTAMP
2. Detector Model(ディテクターモデル)
状態機械を定義。以下要素で構成:
- States: 各状態の名前・条件・アクション
- Transitions: 状態間の遷移ルール
- Initial State: 初期状態
- Key: デバイス ID(各デバイスインスタンスを識別)
3. State(状態)
{
"stateName": "NORMAL",
"onEnter": {
"events": [
{
"eventName": "EnterNormal",
"condition": "true",
"actions": [
{ "clearTimer": { "timerName": "overheatingTimer" } }
]
}
]
},
"onInput": {
"transitionEvents": [
{
"eventName": "TemperatureRising",
"condition": "$input.SensorInput.temperature > 75",
"actions": [
{ "setTimer": { "timerName": "overheatingTimer", "seconds": 180 } }
],
"nextState": "HEATING"
}
]
},
"onExit": {
"events": [ ... ]
}
}
4. Trigger & Action
Trigger 条件:
- 静的スレッショルド:
temperature > 80 - 時間的条件: Timer 満了・Event Count 達成
- 複合条件: AND / OR 演算
Action 実行:
- SNS:
sns.targetArnでメッセージ送信 - SQS:
sqs.queueUrlでメッセージ送信 - Lambda:
lambda.functionArnで関数起動 - Kinesis Firehose:
firehose.deliveryStreamArn - IoT Core:
iotTopicPublish.mqttTopicに MQTT メッセージ
5. Expression(式)
条件判定用の JavaScript ライク表記法:
// 単純比較
$input.SensorInput.temperature > 75
// AND / OR
($input.SensorInput.temperature > 75) && ($input.SensorInput.pressure > 100)
// イベントカウンター
$input.SensorInput.error_code == "E001"
// 現在時刻利用(Timer 向け)
$variables.timer_overheat_elapsed > 300 // 5分以上
主要ユースケース
✅ 1. 工場機械過熱検出・自動停止
状態 NORMAL: 温度監視
→ 温度 > 75℃ が 3 回連続 → HEATING 状態へ
状態 HEATING: 段階的アラート
→ 温度 > 90℃ → CRITICAL 状態へ(SNS 通知)
→ 温度 < 70℃ × 5 → NORMAL へ戻る
状態 CRITICAL: 緊急停止
→ SQS で停止コマンド送信
→ 10 分後 HEATING へ自動ダウングレード
✅ 2. スマートホーム異常検出
- 異常なドア開閉: 1時間に 50 回以上 → アラート
- 冷蔵庫開きっぱなし: 10 分以上 → 推し通知
- 冷房つけっぱなし: 外気温 < 16℃ かつ冷房 ON → 消去提案
✅ 3. 農場灌漑自動化
- 土壌水分 < 30%: 5 分以上継続 → ポンプ起動
- 雨検出: 雨量 > 5mm → ポンプ停止
- 気温 < 5℃: 灌漑禁止(凍結防止)
✅ 4. データセンター温度管理
- 入口温度 25℃ → 冷却 1 段階
- 入口温度 28℃ → 冷却 2 段階 + SNS アラート
- 入口温度 32℃ → 冷却 3 段階 + Lambda で VPC リソース削減
✅ 5. 医療機器(IIoT)監視
- バイタル異常: 心拍 < 50 bpm or > 120 bpm
- バッテリー低下: 残容量 < 10% → 交換通知
- 通信断: 5 分以上未応答 → 医師に通知
✅ 6. EV バッテリー劣化検出
- 放電レート異常: 通常比 ±20% → ログ記録
- 温度上昇: 充電時温度 > 55℃ → 充電速度低下コマンド
- セル不均衡: 最大 - 最小 > 0.2V → 診断実施
✅ 7. 倉庫温度・湿度管理
- 温度 22℃・湿度 40% → NORMAL(正常)
- 温度 26℃ or 湿度 70% → 1 時間経過で ALERT
- 温度 28℃ or 湿度 80% → CRITICAL(1 分で警報)
- → 空調・除湿コマンド自動送信
✅ 8. 自動運転テスト車両データ収集
- 急ブレーキ検出: 減速度 > 0.8g → イベント詳細記録
- 急ハンドル: ステアリング角速度 > 90°/s → カメラデータ抽出
- 異常センサー: LiDAR / Camera 喪失 → 運転停止要求
✅ 9. トレーラー・バッテリー異常
- バッテリー電圧低下: < 11.5V が 10 分 → 運転手通知
- 漏液検出: 湿度センサー反応 → 警報 + 位置情報送信
- エンジン停止: 回転速度ゼロ × 10 秒 → メンテナンス予約
✅ 10. インフラ施設(橋梁・ダム)監視
- 振動異常: 加速度 > 0.3g が 5 分継続 → 検査要請
- 水位上昇: レベル > 警告値が 1 時間 → 放水ゲート開啓要求
- 温度勾配: 温度差 > 20℃ が 30 分 → 膨張対策警告
✅ 11. エレベーター・エスカレーター故障予知
- 異常な消費電力: 通常比 × 1.5 → メンテナンス予約
- ドア開閉不全: 開時間 > 60 秒 が 5 回 → 緊急停止
- 振動パターン変化: ML Detect(SageМaker)との組み合わせ
✅ 12. IoT パーキングメーター
- 駐車状態遷移: 磁気センサー → SQS で課金トリガー
- 車両盗難検出: センサー急激喪失 → GPS 位置情報リアルタイム送信
- 台座異常: 衝突検出 → 修理要請自動発行
ディテクターモデル詳細
ディテクター定義の最小構成
# 1. Input 作成
aws iotevents create-input \
--input-name TemperatureInput \
--input-definition '{
"attributes": [
{ "jsonPath": "deviceId" },
{ "jsonPath": "temperature" },
{ "jsonPath": "timestamp" }
]
}'
# 2. Detector Model 作成(JSON ファイル)
cat > detector-model.json << 'EOF'
{
"detectorModelName": "TemperatureAlarm",
"detectorModelDefinition": {
"states": [
{
"stateName": "NORMAL",
"onInput": {
"transitionEvents": [
{
"eventName": "TemperatureRising",
"condition": "$input.TemperatureInput.temperature > 75",
"actions": [
{
"setTimer": {
"timerName": "overheatingTimer",
"seconds": 180
}
}
],
"nextState": "HEATING"
}
]
}
},
{
"stateName": "HEATING",
"onInput": {
"transitionEvents": [
{
"eventName": "CriticalTemperature",
"condition": "$input.TemperatureInput.temperature > 90",
"nextState": "CRITICAL"
},
{
"eventName": "TemperatureNormal",
"condition": "$input.TemperatureInput.temperature < 70",
"nextState": "NORMAL"
}
]
}
},
{
"stateName": "CRITICAL",
"onEnter": {
"events": [
{
"eventName": "SendCriticalAlert",
"condition": "true",
"actions": [
{
"sns": {
"targetArn": "arn:aws:sns:us-east-1:123456789012:machine-critical-alerts"
}
},
{
"sqs": {
"queueUrl": "https://sqs.us-east-1.amazonaws.com/123456789012/shutdown-commands"
}
}
]
}
]
}
}
],
"initialStateName": "NORMAL"
},
"key": "deviceId",
"roleArn": "arn:aws:iam::123456789012:role/IoTEventsRole"
}
EOF
aws iotevents create-detector-model --cli-input-json file://detector-model.json
Detector Instance 監視
# Detector Instance の現在状態確認
aws iotevents-data describe-detector \
--detector-model-name TemperatureAlarm \
--key-value device-001
# 出力例
{
"detector": {
"detectorModelName": "TemperatureAlarm",
"keyValue": "device-001",
"detectorState": {
"stateName": "HEATING",
"variables": {
"overheatingTimer": 120
},
"timerInferences": []
},
"creationTime": 1704067200000,
"lastUpdateTime": 1704067320000
}
}
# イベント送信(テスト)
aws iotevents-data batch-put-detector-values \
--detector-value-updates '[
{
"detectorModelName": "TemperatureAlarm",
"keyValue": "device-001",
"state": {
"stateName": "HEATING",
"variables": {},
"timerInferences": []
}
}
]'
設定・操作の具体例
CLI を使用したディテクター作成
# ステップ 1: Input 定義
aws iotevents create-input \
--input-name FactoryInput \
--input-definition '{
"attributes": [
{ "jsonPath": "deviceId" },
{ "jsonPath": "temperature" },
{ "jsonPath": "pressure" },
{ "jsonPath": "vibration" },
{ "jsonPath": "timestamp" }
]
}'
# ステップ 2: IAM ロール確認
aws iam get-role --role-name IoTEventsServiceRole
# ステップ 3: Detector Model 作成
aws iotevents create-detector-model \
--detector-model-name FactoryMonitor \
--detector-model-definition file://factory-detector.json \
--role-arn arn:aws:iam::123456789012:role/IoTEventsServiceRole
# ステップ 4: Detector Model 更新(複数状態追加)
aws iotevents update-detector-model \
--detector-model-name FactoryMonitor \
--detector-model-definition file://factory-detector-v2.json \
--role-arn arn:aws:iam::123456789012:role/IoTEventsServiceRole
# ステップ 5: Detector Instance リスト
aws iotevents list-detectors \
--detector-model-name FactoryMonitor
IoT Core Rules Engine との統合
-- IoT Core Rule SQL
SELECT deviceId, temperature, pressure FROM '$aws/things/+/shadow/update/accepted'
WHERE temperature > 75
-- Action: Invoke IoT Events Detector
{
"actionType": "IotEvents",
"parameters": {
"inputName": "FactoryInput",
"detectorKeyPath": "$.deviceId"
}
}
Lambda からのイベント送信
import boto3
import json
from datetime import datetime
iotevents_client = boto3.client('iotevents-data')
def lambda_handler(event, context):
# IoT Core トピックから受信したセンサーデータ
device_id = event['deviceId']
temperature = event['temperature']
pressure = event['pressure']
# IoT Events に Input として送信
response = iotevents_client.batch_put_detector_values(
detectorValueUpdates=[
{
'detectorModelName': 'FactoryMonitor',
'keyValue': device_id,
'state': {
'stateName': 'MONITORING',
'variables': {
'temperature': temperature,
'pressure': pressure
},
'timerInferences': []
}
}
]
)
return {
'statusCode': 200,
'body': json.dumps('Event sent to IoT Events')
}
SDK(Python/JavaScript)での操作
# AWS SDK for Python (Boto3)
import boto3
client = boto3.client('iotevents')
# Detector Model 取得
response = client.describe_detector_model(
detectorModelName='FactoryMonitor'
)
print(response['detectorModel']['detectorModelDefinition'])
# Detector Model 削除
response = client.delete_detector_model(
detectorModelName='FactoryMonitor'
)
// AWS SDK for JavaScript
const AWS = require('aws-sdk');
const iotevents = new AWS.IoTEvents();
// Detector Model リスト
iotevents.listDetectorModels({}, (err, data) => {
if (err) console.log(err);
else console.log(data.detectorModelSummaries);
});
// Detector Model 詳細
iotevents.describeDetectorModel({
detectorModelName: 'FactoryMonitor'
}, (err, data) => {
if (err) console.log(err);
else console.log(JSON.stringify(data, null, 2));
});
IaC(CloudFormation / Terraform)
# CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Resources:
IoTEventsInput:
Type: AWS::IoTEvents::Input
Properties:
InputName: FactoryInput
InputDefinition:
Attributes:
- JsonPath: deviceId
- JsonPath: temperature
- JsonPath: pressure
IoTEventsDetectorModel:
Type: AWS::IoTEvents::DetectorModel
Properties:
DetectorModelName: FactoryMonitor
DetectorModelDefinition:
States:
- StateName: NORMAL
OnInput:
TransitionEvents:
- EventName: TemperatureRising
Condition: "$input.FactoryInput.temperature > 75"
NextState: HEATING
RoleArn: !GetAtt IoTEventsRole.Arn
Key: deviceId
# Terraform
resource "aws_iotevents_input" "factory_input" {
name = "FactoryInput"
input_definition {
attributes = [
{
json_path = "deviceId"
},
{
json_path = "temperature"
}
]
}
}
resource "aws_iotevents_detector_model" "factory_monitor" {
name = "FactoryMonitor"
role_arn = aws_iam_role.iotevents_role.arn
detector_model_definition {
initial_state_name = "NORMAL"
states {
state_name = "NORMAL"
on_input {
transition_events {
event_name = "TemperatureRising"
condition = "$input.FactoryInput.temperature > 75"
next_state = "HEATING"
}
}
}
}
}
アラームモデル
複数ディテクターの組み合わせで高度なアラーム定義:
{
"alarmModelName": "FactoryHealthAlarm",
"alarmModelDefinition": {
"states": [
{
"stateName": "HEALTHY",
"onInput": {
"transitionEvents": [
{
"eventName": "AnyDetectorAlert",
"condition": "$detectors.TemperatureAlarm.state.stateName == 'CRITICAL' || $detectors.PressureAlarm.state.stateName == 'CRITICAL'",
"nextState": "ALARMED"
}
]
}
},
{
"stateName": "ALARMED",
"onEnter": {
"events": [
{
"eventName": "SendAlarm",
"actions": [
{
"sns": {
"targetArn": "arn:aws:sns:us-east-1:...:factory-critical"
}
}
]
}
]
}
}
]
}
}
類似サービス比較表
| 特性 | IoT Events | EventBridge | Step Functions | Apache Flink CEP | Azure Stream Analytics |
|---|---|---|---|---|---|
| 状態管理 | ✅ FSM ベース(優秀) | △ ルール型(限定) | ✅ Workflow(優秀) | △ CEP イベント型 | △ ウィンドウ型 |
| 時間的条件 | ✅ Timer・Counter | △ Cron・Rate | ✅ Wait State | ✅ TimeWindow | ✅ Windowing |
| 複合条件判定 | ✅ Expression 言語 | ✅ EventPattern JSON | ✅ JSONPath | ✅ Pattern Language | ✅ SQL WHERE |
| 複数 Input | ✅ 複数 Input サポート | △ 単一 Event Stream | ✅ 複数 Input | ✅ 複数 Stream | ✅ 複数 Input |
| アクション数 | 5+ 選択肢 | 100+ サービス連携 | 200+ API 対応 | 制限あり | 出力アダプタ型 |
| 大規模スケール | ✅ 100M+ デバイス | ✅ 1000 万 TPS | ⚠️ State 管理が重い | ✅ 高スループット | ✅ マネージド |
| 学習曲線 | 🟩 中程度 | 🟩 中程度 | 🟥 複雑 | 🟥 複雑 | 🟩 中程度 |
| マネージド | ✅ Yes | ✅ Yes | ✅ Yes | △ IaaS | ✅ Yes |
| コスト | 💰 安い | 💰 安い | 💰💰 中程度 | 💰💰💰 高い | 💰💰 中程度 |
| End-of-Service | ⚠️ 2025-12-15 | ✅ 継続 | ✅ 継続 | ✅ OSS | ✅ 継続 |
ベストプラクティス
✅ 1. 状態設計の最小化
❌ 過度に細かい状態設計
NORMAL → WARMING → HEATING → PRE_CRITICAL → CRITICAL
(状態遷移ロジックが複雑化)
✅ 必要最小限の状態
NORMAL → HEATING → CRITICAL
(条件・タイマーで細かい制御)
✅ 2. Expression 言語の活用
// ❌ 複雑な条件を複数状態で分散
State A: temperature > 75
State B: temperature > 90
State C: temperature > 75 AND pressure > 100
// ✅ Expression で一元管理
condition: "($input.temp > 75 && $input.pressure > 100) || $input.temp > 90"
✅ 3. Timer の効果的活用
// ❌ Event Count のみ(時間条件が不明確)
"condition": "error_count > 5"
// ✅ Time Window + Counter
"setTimer": { "timerName": "errorWindow", "seconds": 300 }
"condition": "$variables.errorWindow > 0 && error_count > 5"
✅ 4. Action 実行順序の制御
// アクション実行は順序保証あり
"actions": [
{ "sqs": { "queueUrl": "..." } }, // 1 番目
{ "sns": { "targetArn": "..." } }, // 2 番目
{ "lambda": { "functionArn": "..." } } // 3 番目
]
✅ 5. Key(デバイス識別子)の設計
// ❌ String Key のみ(複合キーが困難)
"key": "deviceId"
// ✅ 階層的識別子
"key": "facility-line-machine" // facility-01-line-02-cnc-03
✅ 6. Input・Output の命名規則
Input: {Service}{DataType}Input
例: TemperatureInput, SensorInput, MetricsInput
Detector: {System}{Monitor}Detector
例: FactoryHealthDetector, BuildingTempDetector
Alarm: {System}Alarm
例: FactoryAlarm, DataCenterAlarm
✅ 7. IAM ポリシーの最小権限
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iotevents:PutMessage"
],
"Resource": "arn:aws:iotevents:*:*:input/FactoryInput"
},
{
"Effect": "Allow",
"Action": "sns:Publish",
"Resource": "arn:aws:sns:*:*:factory-alerts"
},
{
"Effect": "Allow",
"Action": "sqs:SendMessage",
"Resource": "arn:aws:sqs:*:*:shutdown-commands"
}
]
}
トラブルシューティング
| 現象 | 原因 | 対策 |
|---|---|---|
| Detector が状態遷移しない | Condition 式が false | CloudWatch Logs で Input データ形式確認。Expression 再評価 |
| Action が実行されない | Target ARN 間違い / IAM 権限不足 | IAM ロールの SNS・SQS・Lambda 権限確認 |
| EventCounter が動作しない | State 내 Counter 定義不足 | onInput → transitionEvents に Count フィルタ追加 |
| Timer 満了後に状態遷移しない | onTimer イベント未定義 | onEnter / onInput / onTimer 全て確認 |
| Expression 構文エラー | 不正な JSON Path | $input.{InputName}.{AttributeName} 形式確認 |
| 大量デバイスで遅延 | Input Processing の遅延 | Input 複数個に分散。Batch 処理検討 |
| Input 受信できない | IoT Core Rule のフォワーディング失敗 | Rule Engine の SQL・Action を確認 |
| SQS に重複メッセージ | Action 実行が複数回される | Idempotency key を SQS メッセージに含める |
End-of-Service 移行ガイド
⚠️ End-of-Service 日程
- 2025-05-20: 新規顧客は使用不可(既存顧客は継続可)
- 2025-12-15: サービス廃止予定
移行パス選択フロー
┌─────────────────────────────────────────┐
│ 現在の IoT Events ユースケース │
└──────────────────┬──────────────────────┘
│
┌──────────┼──────────┐
│ │ │
▼ ▼ ▼ ▼ ▼ ▼
複雑な 単純な リアル 大規模
FSM ルール タイム スケール
│ │ │ │
▼ ▼ ▼ ▼
Step Event Kinesis IoT
Functions Bridge Stream SiteWise
1. Step Functions への移行(推奨: 複雑 FSM)
{
"Comment": "IoT Events Detector -> Step Functions State Machine",
"StartAt": "NORMAL",
"States": {
"NORMAL": {
"Type": "Task",
"Resource": "arn:aws:lambda:...:function:CheckTemperature",
"Next": "DecideNextState"
},
"DecideNextState": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.temperature",
"NumericGreaterThan": 75,
"Next": "HEATING"
}
],
"Default": "NORMAL"
},
"HEATING": {
"Type": "Wait",
"Seconds": 180,
"Next": "CheckCritical"
},
"CheckCritical": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.temperature",
"NumericGreaterThan": 90,
"Next": "SendCriticalAlert"
}
]
},
"SendCriticalAlert": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"Parameters": {
"TopicArn": "arn:aws:sns:...",
"Message.{{CONTENT}}quot;: "$.alertMessage"
},
"End": true
}
}
}
2. EventBridge への移行(推奨: ルール型イベント)
Name: FactoryTemperatureRule
EventPattern:
source:
- aws.iot
detail:
deviceId:
- device-001
temperature:
- numeric: ['>', 75]
Targets:
- Arn: arn:aws:lambda:...:function:HandleTemperatureAlert
RoleArn: arn:aws:iam::...:role/EventBridgeRole
- Arn: arn:aws:sns:...:factory-alerts
RoleArn: arn:aws:iam::...:role/EventBridgeRole
3. Lambda + DynamoDB 状態管理
import boto3
import json
from datetime import datetime
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('DeviceState')
sns_client = boto3.client('sns')
def lambda_handler(event, context):
device_id = event['deviceId']
temperature = event['temperature']
# 現在の状態を DynamoDB から取得
response = table.get_item(Key={'device_id': device_id})
current_state = response.get('Item', {}).get('state', 'NORMAL')
# 次の状態を決定
if current_state == 'NORMAL' and temperature > 75:
next_state = 'HEATING'
elif current_state == 'HEATING' and temperature > 90:
next_state = 'CRITICAL'
# アラート実行
sns_client.publish(
TopicArn='arn:aws:sns:...',
Message=f'Critical temperature: {temperature}°C'
)
elif temperature < 70:
next_state = 'NORMAL'
else:
next_state = current_state
# 状態更新
table.put_item(Item={
'device_id': device_id,
'state': next_state,
'temperature': temperature,
'timestamp': datetime.utcnow().isoformat()
})
return {
'statusCode': 200,
'previous_state': current_state,
'next_state': next_state
}
4. IoT SiteWise アラーム機能
IoT SiteWise Alarms は IoT Events のアラーム機能に似ており、アセット監視に最適化:
sitewise = boto3.client('iotsitewise')
# アラーム定義
sitewise.create_asset_model(
assetModelName='TemperatureSensor',
assetModelProperties=[
{
'name': 'temperature',
'dataType': 'DOUBLE',
'unit': 'Celsius'
}
]
)
2025-2026 最新動向
📰 1. End-of-Service による生態系変化
- EventBridge の強化: Rule Enrichment・Dead Letter Queue 拡張
- Step Functions の進化: Distributed Map・Express Workflows の改善
- IoT SiteWise 統合: Alarms 機能の拡張(IoT Events 代替)
📰 2. サーバーレス IoT アーキテクチャ
- IoT Core → Lambda → EventBridge → Step Functions → Action
- (IoT Events なし・完全サーバーレス)
📰 3. 予測的メンテナンス(SageMaker ML 統合)
IoT Events の後継は ML-driven なアプローチ:
- Timestream データ → SageMaker Autopilot
- → EventBridge Rule(予測スコア)
- → Lambda → アクション
📰 4. Edge Computing との統合
- AWS IoT Greengrass での Edge Lambda(状態管理オフロード)
- AWS IoT Core Device Defender との組み合わせ
学習リソース・参考文献
公式ドキュメント(8+)
- AWS IoT Events Developer Guide
- AWS IoT Events End of Support
- Migration Procedure for Detector Models
- AWS IoT Events FAQs
- AWS IoT Events Examples
- Expressions in AWS IoT Events
- AWS IoT Events API Reference
- AWS IoT Events Pricing
パートナー・ベンダー リソース(5+)
- AWS IoT Events is Shutting Down - Migration Guide
- AWS Step Functions vs EventBridge Comparison
- EventBridge for Event-Driven Architectures
- AWS IoT SiteWise Alarms
- AWS Step Functions State Machine Design Patterns
コミュニティ・ブログ
- AWS IoT on AWS Blog
- AWS re:Post IoT Events Tag
- GitHub: aws-iot-events-examples
実装例・チェックリスト
チェックリスト: IoT Events 導入前評価
- [ ] 複雑な状態遷移ロジックが必要か?(Yes → IoT Events / No → EventBridge)
- [ ] 複数センサーの時系列パターン検出が必要か?
- [ ] デバイスフリートが 10,000+ 台以上か?
- [ ] オフライン時の状態管理が必要か?
- [ ] SNS・SQS・Lambda への自動アクション実行が必要か?
- [ ] 既存 IoT Core インフラと統合する必要があるか?
- [ ] 2025-12-15 の End-of-Service を考慮したか?→ Step Functions 移行計画立案
チェックリスト: Detector Model 設計
- [ ] 状態名を英数字・アンダースコア(NORMAL・HEATING・CRITICAL)で定義
- [ ] Input 属性を JSON Path で正確に定義
- [ ] Condition Expression を $input.{InputName}.{Attr} 形式で記述
- [ ] Timer は秒単位で適切に設定
- [ ] Event Counter の初期化タイミング確認
- [ ] Action の Target ARN を正確に設定
- [ ] IAM ロールの権限が最小権限で設定
- [ ] CloudWatch Logs を有効化して動作監視
チェックリスト: 本番運用準備
- [ ] Detector Model のテスト環境での検証(10+ パターン)
- [ ] End-of-Service 対応(移行スケジュール立案)
- [ ] CloudWatch Alarms で Detector 監視
- [ ] Action の失敗時の再試行ロジック実装
- [ ] Device のデバイス登録プロセス自動化
- [ ] Cost Estimation(Event 数 × $0.10/千)
- [ ] Disaster Recovery・Backup 計画
まとめ
AWS IoT Events は、IoT センサーデータから複雑なイベントパターンを検出し、ステートマシン(FSM)ベースで自動アクション実行する専用エンジンです。複数センサーの時間的・条件的な複合判定が必要な工場・インフラ・農業 IoT などで威力を発揮します。
ただし、⚠️ 2025-12-15 End-of-Service決定のため、新規導入は Step Functions / EventBridge / Lambda への移行 を視野に入れた検討が必須です。既存ユーザーは計画的にサービス移行を進める必要があります。
推奨導入パス:
- 複雑 FSM → Step Functions へ移行
- ルール型イベント → EventBridge へ移行
- IoT SiteWise アセット監視 → IoT SiteWise Alarms へ移行
最終更新:2026-04-26 バージョン:v2.0