Upgrade to Pro — share decks privately, control downloads, hide ads and more …

IoT だけじゃない!? AWS IoT Events の真骨頂 / aws-iot-even...

tomoki10
April 21, 2021

IoT だけじゃない!? AWS IoT Events の真骨頂 / aws-iot-events-ones-true-value

AKIBA.AWS ONLINE #02 の登壇資料です。
https://dev.classmethod.jp/news/akiba-aws-210421/

tomoki10

April 21, 2021
Tweet

More Decks by tomoki10

Other Decks in Technology

Transcript

  1. 2 ࣗݾ঺հ • ࠤ౻ஐथ • Ϋϥεϝιουגࣜձࣾ • CXࣄۀຊ෦ʢνʔϜIoTʣ • લ৬ɿSIerͷSEΛ4೥ऑ

    • ݱࡏɿαʔόʔαΠυΤϯδχΞ • ޷͖ͳAWSαʔϏεɿLambdaɺCDK @tmk2154 @tomoki10
  2. 4 ର৅ͷ੔ཧ ࢹௌऀͷΠϝʔδ • ͋Δఔ౓ AWS ͸஌͍ͬͯΔɻLambda͸஌ͬͯΔ • IoT Events

    ͸΄΅஌Βͳ͍ɻ໊લ΋ฉ͍ͨ͹͔Γ ໨ඪ • IoT Events Λͬ͘͟Γཧղ͢Δ • ঢ়ଶ؅ཧ΍λΠϚʔͷ࣮૷ʹ࢖͑Δ͜ͱΛཧղ͢Δ
  3. 12 IoT Events ͷྲྀΕΛͬ͘͟Γղઆ ։࢝Ґஔ ભҠ৚݅ ঢ়ଶ AWS IoT Core

    IoT rule IoT Device (GPS) AWS IoT Events ◦ ॲཧͷྲྀΕྫ GPSσʔλΛৗʹIoT Ruleʹૹ৴ ↓ ൣғ಺͔ભҠ৚݅ͰνΣοΫ ↓ ৚݅ద߹ʂΞΫγϣϯ࣮ߦ ↓ ঢ়ଶભҠ
  4. 13 IoT Events ͷྲྀΕΛͬ͘͟Γղઆ ભҠ৚݅ ঢ়ଶ AWS IoT Core IoT

    rule IoT Device (GPS) AWS IoT Events ◦ ॲཧͷྲྀΕྫ GPSσʔλΛৗʹIoT Ruleʹૹ৴ ↓ ൣғ಺͔ભҠ৚݅ͰνΣοΫ ↓ ৚݅ద߹ʂΞΫγϣϯ࣮ߦ ↓ ঢ়ଶભҠ ։࢝Ґஔ
  5. 14 IoT Events ͷྲྀΕΛͬ͘͟Γղઆ ։࢝Ґஔ ભҠ৚݅ ঢ়ଶ AWS IoT Core

    IoT rule IoT Device (GPS) AWS IoT Events ◦ ॲཧͷྲྀΕྫ GPSσʔλΛৗʹIoT Ruleʹૹ৴ ↓ ൣғ಺͔ભҠ৚݅ͰνΣοΫ ↓ ৚݅ద߹ʂΞΫγϣϯ࣮ߦ ↓ ঢ়ଶભҠ
  6. 15 IoT Events ͷྲྀΕΛͬ͘͟Γղઆ ։࢝Ґஔ ભҠ৚݅ ঢ়ଶ AWS IoT Core

    IoT rule IoT Device (GPS) AWS IoT Events ◦ ॲཧͷྲྀΕྫ GPSσʔλΛৗʹIoT Ruleʹૹ৴ ↓ ൣғ಺͔ભҠ৚݅ͰνΣοΫ ↓ ৚݅ద߹ʂΞΫγϣϯ࣮ߦ ↓ ঢ়ଶભҠ
  7. 16 IoT Events ͷྲྀΕΛͬ͘͟Γղઆ ։࢝Ґஔ ભҠ৚݅ ঢ়ଶ AWS IoT Core

    IoT rule IoT Device (GPS) AWS IoT Events ◦ ॲཧͷྲྀΕྫ GPSσʔλΛৗʹIoT Ruleʹૹ৴ ↓ ൣғ಺͔ભҠ৚݅ͰνΣοΫ ↓ ৚݅ద߹ʂΞΫγϣϯ࣮ߦ ↓ ঢ়ଶભҠ Amazon SNS
  8. 17 IoT Events ͷྲྀΕΛͬ͘͟Γղઆ ։࢝Ґஔ ભҠ৚݅ ঢ়ଶ AWS IoT Core

    IoT rule IoT Device (GPS) AWS IoT Events ◦ ॲཧͷྲྀΕྫ GPSσʔλΛৗʹIoT Ruleʹૹ৴ ↓ ൣғ಺͔ભҠ৚݅ͰνΣοΫ ↓ ৚݅ద߹ʂΞΫγϣϯ࣮ߦ ↓ ঢ়ଶભҠ
  9. 18 IoT Events ͷྲྀΕΛͬ͘͟Γղઆ ։࢝Ґஔ ભҠ৚݅ ঢ়ଶ AWS IoT Core

    IoT rule IoT Device (GPS) AWS IoT Events ◦ ॲཧͷྲྀΕྫ GPSσʔλΛৗʹIoT Ruleʹૹ৴ ↓ ൣғ಺͔ભҠ৚݅ͰνΣοΫ ↓ ৚݅ద߹ʂΞΫγϣϯ࣮ߦ ↓ ঢ়ଶભҠ
  10. 19 IoT Events ͷྲྀΕΛͬ͘͟Γղઆ ։࢝Ґஔ ભҠ৚݅ ঢ়ଶ AWS IoT Core

    IoT rule IoT Device (GPS) AWS IoT Events ◦ ॲཧͷྲྀΕྫ GPSσʔλΛৗʹIoT Ruleʹૹ৴ ↓ ൣғ಺͔ભҠ৚݅ͰνΣοΫ ↓ ৚݅ద߹ʂΞΫγϣϯ࣮ߦ ↓ ঢ়ଶભҠ ͜ΜͳॲཧΛGUIͰ࡞ΕΔʂ ʢίʔυͰॻ͘͜ͱ΋Մೳʣ
  11. 22 IoT αʔϏεͷಛੑ • σόΠε͕σʔλऩूػೳ͚ͩͷ৔߹΋ଟ͍ • Ϋϥ΢υଆ͔Β͢ΔͱΠϕϯτ͝ͱʹσʔλૹ৴ͯ͠ཉ͍͕͠ਨΕྲྀ͕͠ଟ͍ ΅͕͔͘Μ͕͍͖͑ͨ͞ΐ͏ͷIoTσόΠε Α͋͘ΔIoTσόΠε IoT

    Device AWS IoT Core AWS Cloud Ξϥʔτൃੜʂ IoT Device AWS IoT Core AWS Cloud Թ౓:20 Թ౓:22 Թ౓:40 IoT Greengrass ͕͋Ε͹Ͱ͖ͦ͏ ͨͩσόΠεͷ੍໿͕…
  12. 23 IoT αʔϏεͷಛੑ • σόΠε͕σʔλऩूػೳ͚ͩͷ৔߹΋ଟ͍ • Ϋϥ΢υଆ͔Β͢ΔͱΠϕϯτ͝ͱʹσʔλૹ৴ͯ͠ཉ͍͕͠ਨΕྲྀ͕͠ଟ͍ ΅͕͔͘Μ͕͍͖͑ͨ͞ΐ͏ͷIoTσόΠε Α͋͘ΔIoTσόΠε IoT

    Device AWS IoT Core AWS Cloud Ξϥʔτൃੜʂ IoT Device AWS IoT Core AWS Cloud Թ౓:20 Թ౓:22 Թ౓:40 IoT Events͸ӈͷσόΠεͷ࣌ɺγϯϓϧʹঢ়ଶ؅ཧΛ࣮ݱͰ͖Δʂ
  13. 24 IoT Events ͕ͳ͍৔߹ͷઃܭྫ • ΋͏গ͠ৄࡉʹղઆ IoT Device (Թ౓ηϯαʔ) AWS

    IoT Core AWS Cloud Թ౓:20 Թ౓:22 Թ౓:40 IoT rule AWS Lambda Amazon DynamoDB • Թ౓Λอଘ • ૹ৴͞ΕͨԹ౓ͱ લͷԹ౓Λൺֱ • Թ౓͕ٸͳมԽͰ ΞϥʔτΛൃ๒ ΤϯυϙΠϯτ ঢ়ଶݕ஌ ঢ়ଶอ࣋ AWS Lambda ΞΫγϣϯ Amazon SNS etc…
  14. 25 IoT Events ͕͋Δ৔߹ͷઃܭྫ • ΋͏গ͠ৄࡉʹղઆ IoT Device (Թ౓ηϯαʔ) AWS

    IoT Core AWS Cloud Թ౓:20 Թ౓:22 Թ౓:40 IoT rule • ૹ৴͞ΕͨԹ౓ͱ લͷԹ౓Λൺֱ • Թ౓͕ٸͳมԽͰ ΞϥʔτΛൃ๐ • Թ౓Λ಺෦ʹอଘ ΤϯυϙΠϯτ ঢ়ଶݕ஌ ঢ়ଶอ࣋ AWS IoT Events AWS Lambda ΞΫγϣϯ Amazon SNS etc…
  15. 26 ઃܭ͕࣮૷ʹͳΔʢIaC ʹ૊ࠐՄ!ʣ ઃܭ͸࣮૷ͷΈ͔ผ్هࡌ͕ඞཁ IoT Events ͕ͳ͍৔߹ IoT Events ͕͋Δ৔߹

    { "detectorModelDefinition": { "states": [ { "stateName": "inBoundary", "onInput": { "events": [], "transitionEvents": [ JSON Export ઃܭ΋อक͠΍͍͢
  16. ೖྗ͝ͱʹ։࢝εςʔτ͔ΒධՁ 29 ೖྗʹରͯ͠ݱࡏͷεςʔτ͔ΒධՁ Step Functions ͷ৔߹ IoT Events ͷ৔߹ AWS

    IoT Core IoT rule AWS IoT Core IoT rule … Step Functions ͱͷൺֱ =>ঢ়ଶ͕ଟ͘ͳͬͨ৔߹ॲཧΛ௥͏ͷ͕େม => ಛఆͷঢ়ଶͱભҠ৚͚݅ͩ௥͑͹ॲཧ͕෼͔Δ
  17. ೖྗ͝ͱʹ։࢝εςʔτ͔ΒධՁ 30 ೖྗʹରͯ͠ݱࡏͷεςʔτ͔ΒධՁ Step Functions ͷ৔߹ IoT Events ͷ৔߹ AWS

    IoT Core IoT rule AWS IoT Core IoT rule … Step Functions ͱͷൺֱ =>ঢ়ଶ͕ଟ͘ͳͬͨ৔߹ॲཧΛ௥͏ͷ͕େม => ಛఆͷঢ়ଶͱભҠ৚͚݅ͩ௥͑͹ॲཧ͕෼͔Δ
  18. 31 ྫɽGANTZͷ಄ͷര஄΍ػثͷ౪೉ݕ஌Λ࣮૷͍ͯͩ͘͠͞
 ɹɹ=> n෼Ҏ্ಛఆͷൣғ֎ʹ͍ͨ৔߹ঢ়ଶΛมߋ͍ͨ͠ IoT Events ͷ৔߹
 => ҎԼͷΑ͏ʹλΠϚʔΛ࢓ࠐΜ࣮ͩ૷͕૊Έ΍͍͢ AWS

    IoT Core IoT rule ①ಛఆͷൣғ͔Βग़ͨ৔߹ ɹ λΠϚʔελʔτ ②n෼Ҏ಺ʹൣғ಺ʹ໭Ε͹ ɹ λΠϚʔ࡟আ ③λΠϚʔ͕n෼Λա͗Ε͹ ɹ ൣғ֎ͷঢ়ଶʹભҠ GPSσʔλΛৗʹૹ৴ ※IoT Events ͷλΠϚʔ͸1෼͕࠷খ୯Ґ 2021/4/18 ࣌఺ Step Functions ͱͷൺֱ
  19. 32 IoT Events ͱ༗ݶΦʔτϚτϯ • IoT Events ͸༗ݶΦʔτϚτϯͷ࣮૷ͱ͍͑Δ
 => ༗ݶΦʔτϚτϯ͕༗ޮͳ৔߹

    IoT Ҏ֎Ͱ΋ద༻ՄೳͰ͋Δɻ
 => Serverless Ͱ࢖͑ΔʢEC2ɺVPCෆཁʣ
 ɹ Ώ͑ʹ Serverless Automaton ͱݴ͑Δʂ https://ja.wikipedia.org/wiki/༗ݶΦʔτϚτϯ ༗ݶΦʔτϚτϯ IoT Events ͷ σΟςΫλʔϞσϧ
  20. 33 ϋʔτϏʔτ؂ࢹ
 => Ұఆ࣌ؒ௨৴ͷͳ͍৔߹Ξϥʔτ ޻৔ͷੜ࢈ঢ়گ؂ࢹ
 => n෼Ҏ্ಛఆͷσʔλ͕དྷͨ࣌ΞΫγϣϯ࣮ߦ AWS IoT Core

    IoT rule https://dev.classmethod.jp/articles/aws-iot-events-heartbeat/ σʔλ͕ج४Λ௒͑ͨΒ λΠϚʔελʔτ IoT Events ͷԠ༻ྫ Ұఆ࣌ؒج४Λ௒͑ͨΒ ঢ়ଶมߋ&ΞΫγϣϯ࣮ߦ
  21. 34 ·ͱΊ • IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ
 => ঢ়ଶʹԠͨ͡ॲཧ͕Մೳ • IoT

    Events ͷར఺
 => ঢ়ଶݕ஌ɺঢ়ଶ؅ཧΛDBɺLambdaͳ͠ͰՄೳ • IoT Events ͱͦͷଞαʔϏεͱͷൺֱ
 => ༗ݶΦʔτϚτϯ͕༗ޮͳ৔߹ʹ IoT Ҏ֎Ͱ΋Ԡ༻Մೳ
 ɹ λΠϚʔॲཧ͕؆қʹ࣮૷Ͱ͖Δ