AWS x Alexa対策講座

46e8de7d6e95be6327e8c49bf3b0c028?s=47 chao2suke
August 21, 2018

AWS x Alexa対策講座

2018/08/21 Alexa Salon SP@東京 資料

46e8de7d6e95be6327e8c49bf3b0c028?s=128

chao2suke

August 21, 2018
Tweet

Transcript

  1. AWS x Alexa ରࡦߨ࠲ クラスメソッド株式会社 せーの 1

  2. ࣗݾ঺հ ✦ ਗ਼໺ɹ߶࢙(ͤʔͷ) ✦ ΫϥεϝιουגࣜձࣾࡳຈΦϑΟε
 AIιϦϡʔγϣϯ෦
 AlexaςΫχΧϧΤόϯδΣϦετ
 VUIΞʔΩςΫτ 2

  3. Agenda ✦ جຊͱͯ͠ԡ͓͑ͯ͘͞αʔϏε ✦ AWS IAM ✦ DynamoDB ✦ Cognito

    ✦ AlexaͷදݱྗΛิ͏ ✦ AWS IoT ✦ Kinesis Video Stream + Rekognition Video ✦ ӡ༻Λॿ͚Δ ✦ CloudWatch Logs ✦ API Gateway 3
  4. 4 AWS IAM

  5. 5 AWS IAM ✦ ֤AWS αʔϏεͷ࢖༻ݖݶΛ੍ޚ͢Δ ✦ ʮϢʔβʔʯ͕αʔϏεΛ࢖͑Δ
 => IAM

    User ✦ ʮαʔϏεΛ࢖͑ΔݖݶʯΛ
 ͍Ζ͍Ζͳ΋ͷʹ͚ͭΔ => IAM Role ✦ LambdaͷτϦΨʔ͔Β֬ೝͰ͖Δ
  6. 6 AWS IAM

  7. 7 AWS IAM

  8. 8 AWS IAM

  9. 9 DynamoDB

  10. 10 DynamoDB ✦ NoSQLܗࣜͷσʔλϕʔεαʔϏε ✦ αʔόʔεϖοΫ΍༰ྔ͸ؾʹ͠ͳͯ͘΋ྑ͍ ʢϚωʔδυαʔϏε) ✦ ӬଓԽαʔϏεͱͯ͠Alexa-SDKʹσϑΥϧτ Ͱૢ࡞API͕͍͍ͭͯΔ

    ✦ ॳ৺ऀ͕Ҿ͔͔ͬΔͷ͸ʮΩʔʯͱʮϢχοτʯ
  11. 11 DynamoDB var alexa = Alexa.handler(event, context); alexa.dynamoDBTableName = 'AlexaUserData_V1';

  12. 12 DynamoDB Alexa.SkillBuilders.standard() .addRequestHandlers(LaunchRequestHandler) .withTableName("AlexaUserData_V2") .withAutoCreateTable(true) .lambda();

  13. 13 DynamoDB handlerInput.attributesManager.setPersistentAttributes(dynamos) ; await handlerInput.attributesManager.savePersistentAttributes();

  14. 14 DynamoDB Ωʔ / ΠϯσοΫεͷ͍͍ͭͯΔItem͕ݕࡧͰ͖Δ

  15. 15 DynamoDB ϓϥΠϚϦΩʔ Hash Key Range Key Hash Key OR

  16. 16 DynamoDB ηΧϯμϦΠϯσοΫε Hash Key Range Key Hash Key Local

    Secondary Index Range Key Global Secondary Index
  17. 17 DynamoDB ΩϟύγςΟʔϢχοτ

  18. 18 DynamoDB ΩϟύγςΟʔϢχοτ WCU (Write Capacity Unit) RCU (Read Capacity

    Unit)
  19. 19 DynamoDB ΩϟύγςΟʔϢχοτ WCU (Write Capacity Unit) RCU (Read Capacity

    Unit) 1 4KB 1 2 1 1KB 1
  20. 20 DynamoDB DynamoDBͷಡΈࠐΈ GetItem BatchGetItem Query Scan

  21. 21 DynamoDB

  22. 22 DynamoDB ಡΈࠐΈ༰ྔ +

  23. 23 DynamoDB

  24. 24 Cognito

  25. 25 Cognito ✦ AWSͷೝূαʔϏε ✦ Facebook / Google / Amazon

    Login / Twitter౳ʹରԠ ✦ ಠࣗͷೝূج൫ʮCognito User Poolʯ Λ࡞੒Ͱ͖Δ
 =>AlexaʹखܰͳೝূΛ͚ͭΒΕΔ
  26. 26 Cognito Device ID ✦ Device ID͸εΩϧͷOFF/ONͰมΘΔ ✦ εΩϧ͸Ի੠ͰOFF/ON͕Ͱ͖Δ ✦

    Alexa͸݁ߏޡೝࣝ͢Δ ✦ ஌Βͳ͍ؒʹ͢΂ͯͷDeviceID͕มΘ͍ͬͯΔ ͜ͱ͕͋Δ
  27. 27 Cognito https://bit.ly/2whJEZJ

  28. Agenda ✦ جຊͱͯ͠ԡ͓͑ͯ͘͞αʔϏε ✦ AWS IAM ✦ DynamoDB ✦ Cognito

    ✦ AlexaͷදݱྗΛิ͏ ✦ AWS IoT ✦ Kinesis Video Stream + Rekognition Video ✦ ӡ༻Λॿ͚Δ ✦ CloudWatch Logs ✦ API Gateway 28
  29. 29 AWS IoT

  30. 30 AWS IoT ✦ AWSͷIoT౷߹αʔϏε ✦ MQTT/HTTPSʹରԠ͠ɺRule Engineʹͯෳ਺ ͷΞΫγϣϯ͕Մೳ ✦

    MQTT Over WebSocketͰ
 WebSocketύΠϓͰMQTT௨৴͕Մೳ
  31. 31 AWS IoT ✦ Echo Spot΍εϚϗ্ͷΧʔυ͸ܾΊΒΕͨς ϯϓϨʔτʹը૾΍ө૾ΛࡌͤΔܗࣜ ✦ Web SocketʹࡌͤΔ͜ͱͰϒϥ΢β্ͱAlexa

    ΛϦΞϧλΠϜ௨৴ͤ͞Δࣄ͕Ͱ͖Δ ✦ IoT SDKΛࡌͤΒΕΔͳΒεϚϗΞϓϦͱ௨৴ ͯ͠ө૾ΛมԽͤ͞Δ͜ͱ΋
  32. 32 AWS IoT

  33. 33 Kinesis Video Stream + Rekognition Video

  34. 34 Kinesis Video Stream + Rekognition Video ✦ ಈըετϦʔϜαʔϏε &

    ෼ੳαʔϏε ✦ AWSʹ҆શʹಈըΛετϦʔϜ͠ɺϦΞϧλΠ Ϝɺόονॲཧ྆ํʹରԠ͢Δ ✦ ಈըΛ෼ੳ͠ɺإೝࣝɺإೝূͳͲͷ෼ੳ࡞ۀ ͕ߦ͑Δ ✦ ྆αʔϏε͸σϑΥϧτͰ࿈ܞͰ͖Δ
  35. 35 Kinesis Video Stream + Rekognition Video ✦ Echoʹ͸Χϝϥ͕ͳ͍ͨΊɺϊϯόʔόϧί ϛϡχέʔγϣϯ͕શ͘Ͱ͖ͳ͍

    ✦ ΧϝϥΛ࢖༻ͯ͠ඇಉظʹ࿈ܞͤ͞Δ͜ͱͰ΍ ΓͱΓʹΑΓਓؒຯΛ΋ͨͤͨΓɺ༨ܭͳ΍Γ औΓΛলུͨ͠ΓͰ͖Δ ✦ Camera recap APIͱ͍͏ͷ΋ग़͖͍ͯͯΔ Alexa
  36. 36 Kinesis Video Stream + Rekognition Video K i n

    e s i s V i d e o S t r e a m R e k o g n i t i o n V i d e o K i n e s i s D a t a S t r e a m S t r e a m P r o c e s s o r
  37. Agenda ✦ جຊͱͯ͠ԡ͓͑ͯ͘͞αʔϏε ✦ AWS IAM ✦ DynamoDB ✦ Cognito

    ✦ AlexaͷදݱྗΛิ͏ ✦ AWS IoT ✦ Kinesis Video Stream + Rekognition Video ✦ ӡ༻Λॿ͚Δ ✦ CloudWatch Logs ✦ API Gateway 37
  38. 38 Cloud Watch Logs

  39. 39 CloudWatch Logs ✦ AWSͷϩάαʔϏε ✦ ࠷େ10೥·Ͱͷϩάอ؅͕Մೳ ✦ ϑΟϧλΛ͔͚ͯɺಛఆͷϩάΛநग़Ͱ͖Δ ✦

    αϒεΫϦϓγϣϯϑΟϧλͰɺநग़ ͨ͠ϩάʹϦΞϧλΠϜͰॲཧΛૹΔ͜ͱ͕Ͱ ͖Δ
  40. 40 CloudWatch Logs

  41. 41 CloudWatch Logs

  42. 42 API Gateway

  43. 43 API Gateway ✦ AWSͷAPIαʔϏε ✦ खܰʹAPIΤϯυϙΠϯτΛ࡞੒Ͱ͖Δ ✦ ཪଆʹ͸Lambda΍SNSͳͲͷAWSαʔϏεΛ഑ ஔͨ͠ΓϓϩΩγͱͯ͠ઃఆͨ͠ΓͰ͖Δ

    ✦ Account LinkͷϓϩΩγͱͯ͠഑ஔ͢Δ͜ͱͰ OAuth2઀ଓͷ಺༰ΛϩΪϯά͢Δ͜ͱ͕Ͱ͖Δ
  44. 44 API Gateway

  45. 45 API Gateway

  46. 46 API Gateway https://bit.ly/2BuUZvl

  47. 47 ·ͱΊ ✦ Alexaͷཪଆ͸LambdaͰ͋Δ͜ͱ͕ଟ͘ɺAWS αʔϏεͱͷ਌࿨ੑ͕ߴ͍ ✦ ͳΔ΂͘AWSαʔϏεͰࡁ·͓ͤͯ͘ͱࠔͬͨͱ ͖ʹϥΫ ✦ AlexaεΩϧΛެ։͢ΔͱAWSΫϨδοτ͕΋Β͑

    ΔͷͰɺେମແྉͰ࡞ΕΔ ✦ ࠔͬͨ࣌͸Developers.IOΛݟͯΈΑ͏