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

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

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

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

380bcd2ab751f5838abd8219df53e5fe?s=128

tomoki10

April 21, 2021
Tweet

Transcript

  1. IoT ͚ͩ͡Όͳ͍!? AWS IoT Events ͷਅࠎ௖ AKIBA.AWS ONLINE #02 2021/4/21

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

    • ݱࡏɿαʔόʔαΠυΤϯδχΞ • ޷͖ͳAWSαʔϏεɿLambdaɺCDK @tmk2154 @tomoki10
  3. 3 ͸͡Ίʹ IoT Events ͷ׆༻͸ IoT ʹͱͲ·Βͳ͍!? =>໊͋͑ͯ෇͚͢ΔͳΒ
 ɹ Serverless

    Automaton
  4. 4 ର৅ͷ੔ཧ ࢹௌऀͷΠϝʔδ • ͋Δఔ౓ AWS ͸஌͍ͬͯΔɻLambda͸஌ͬͯΔ • IoT Events

    ͸΄΅஌Βͳ͍ɻ໊લ΋ฉ͍ͨ͹͔Γ ໨ඪ • IoT Events Λͬ͘͟Γཧղ͢Δ • ঢ়ଶ؅ཧ΍λΠϚʔͷ࣮૷ʹ࢖͑Δ͜ͱΛཧղ͢Δ
  5. 5 ֓ཁ • IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ • IoT Events ͷར఺

    • IoT Events ͱͦͷଞαʔϏεͱͷൺֱ
  6. 6 ֓ཁ • IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ • IoT Events ͷར఺

    • IoT Events ͱͦͷଞαʔϏεͱͷൺֱ
  7. 7 IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ • ެࣜͷ঺հ(αʔϏεϖʔδΑΓ) https://aws.amazon.com/jp/iot-events/

  8. 8 IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ ͳΔ΄Ͳ Θ͔ΒΜ

  9. 9 IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ • ެࣜͷ঺հ(Black Belt ΑΓ) https://www.slideshare.net/AmazonWebServicesJapan/20200916-aws-black-belt-online-seminar-aws-iot-events#12

  10. 10 IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ • ެࣜͷ঺հ(Black BeltΑΓ) https://www.slideshare.net/AmazonWebServicesJapan/20200916-aws-black-belt-online-seminar-aws-iot-events#16

  11. • ެࣜͷ঺հ(Black BeltΑΓ) 11 IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ https://www.slideshare.net/AmazonWebServicesJapan/20200916-aws-black-belt-online-seminar-aws-iot-events#16 ൣғ಺ ൣғ֎

    ஍ਤ ɿσόΠε Ξϥʔτର৅
  12. 12 IoT Events ͷྲྀΕΛͬ͘͟Γղઆ ։࢝Ґஔ ભҠ৚݅ ঢ়ଶ AWS IoT Core

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

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

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

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

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

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

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

    IoT rule IoT Device (GPS) AWS IoT Events ◦ ॲཧͷྲྀΕྫ GPSσʔλΛৗʹIoT Ruleʹૹ৴ ↓ ൣғ಺͔ભҠ৚݅ͰνΣοΫ ↓ ৚݅ద߹ʂΞΫγϣϯ࣮ߦ ↓ ঢ়ଶભҠ ͜ΜͳॲཧΛGUIͰ࡞ΕΔʂ ʢίʔυͰॻ͘͜ͱ΋Մೳʣ
  20. 20 ֓ཁ • IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ • IoT Events ͷར఺

    • IoT Events ͱͦͷଞαʔϏεͱͷൺֱ
  21. 21 IoT αʔϏεͷಛੑ • σόΠε͕σʔλૹ৴ػೳ͚ͩͷ৔߹΋ଟ͍ • Ϋϥ΢υଆ͔Β͢ΔͱΠϕϯτ͝ͱʹσʔλૹ৴ͯ͠ཉ͍͕͠ਨΕྲྀ͕͠ଟ͍ ΅͕͔͘Μ͕͍͖͑ͨ͞ΐ͏ͷIoTσόΠε Α͋͘ΔIoTσόΠε IoT

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

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

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

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

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

    { "detectorModelDefinition": { "states": [ { "stateName": "inBoundary", "onInput": { "events": [], "transitionEvents": [ JSON Export ઃܭ΋อक͠΍͍͢
  27. 27 ֓ཁ • IoT Events ͱ͸Կ͕Ͱ͖ΔαʔϏεͳͷ͔ʁ • IoT Events ͷར఺

    • IoT Events ͱͦͷଞαʔϏεͱͷൺֱ
  28.  Step Functions ͡ΌμϝͳΜʁ ͪΐͬͱ଴ͬͯ

  29. ೖྗ͝ͱʹ։࢝εςʔτ͔ΒධՁ 29 ೖྗʹରͯ͠ݱࡏͷεςʔτ͔ΒධՁ Step Functions ͷ৔߹ IoT Events ͷ৔߹ AWS

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

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

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

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

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

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