AWS parking lot shutter hack project

F3ba76698a3a2ea827abd7b73d74a5b7?s=47 teitei_tk
February 09, 2017
3.2k

AWS parking lot shutter hack project

F3ba76698a3a2ea827abd7b73d74a5b7?s=128

teitei_tk

February 09, 2017
Tweet

Transcript

  1. AWSΛ࢖ͬͨறྠ৔γϟο λʔHACKϓϩδΣΫτ 2017/02/08 @teitei_tk

  2. ࠓ·Ͱ΍͍ͬͯͨ͜ͱ • Slackͷͱ͋ΔνϟϯωϧͰಛఆͷݴ༿Λ ᄁ͘ͱ1Fறྠ৔ͷγϟολʔ͕։͘ • ศར • ָͪΜ • UX࠷ߴ

  3. ͕ɺ

  4. ʊਓਓਓਓਓਓਓਓਓ_ ʼ αʔϏεऴྃͷ͓஌Βͤ ʻ ʉY^Y^Y^Y^Y^Y^Y^Yʉ

  5. αʔϏεऴྃͷ͓஌Βͤ • ࢖༻͍ͯͨ͠DBaaSͷڍಈ͕ෆ҆ఆ • ৐Γ׵͑ઌͷݕ౼ɺઃܭɾ࣮૷ʹख͕ճΒ ͳ͍

  6. AWSΛར༻ͯ͠ ΋͏Ұ౓͋ͷମݧΛ

  7. ͱΓ͋͑ͣ ໊৐ΓΛ্͛ͨ

  8. • AWSͷମܥతͳֶशΛ͍ͨ͠ • ೖࣾͨ͠͹͔ΓͩͬͨͷͰإΛ֮͑ͯ΋Β͏ • ΍͍ͬͯ͘ͱ͍͏ؾ࣋ͪ

  9. ΍͍ͬͯͧ͘

  10. چ ߏ੒ਤ Post Get Every Sec

  11. ͜ΕΛϕʔεʹ͢Δ

  12. ৽ ߏ੒ਤ 1. Open Request 2. Update Shutter Status 3.

    Request Check & Open Door 4. Finish Message
  13. RaspberryPi(Client) • ຖඵAPI Gateway΁γϟολʔͷΦʔϓϯϦΫΤ ετ͕དྷ͍ͯͳ͍͔Λ֬ೝ • ΦʔϓϯϦΫΤετ͕དྷ͍ͯͨΒαʔϘ(։Ϙλ ϯ)Λ࣮ߦ

  14. AWS(Server) • API Gateway & Lambda • ྲྀߦΓʁͷServerless Architecture @

    Python • ϑϨʔϜϫʔΫ͸࢖Θͳ͍ • SQS • ΦʔϓϯϦΫΤετ͕དྷͨΒQueueΛEnQueue
  15. API Gateway • ֤HTTP Methodຖʹ໾ׂΛ෼ࢄ • GET • γϟολʔͷঢ়ଶ؅ཧ •

    PUT • γϟολʔͷΦʔϓϯ • POST • γϟολʔ͕։͖ऴΘͬͨࡍͷ௨஌
  16. ·͋Α͋͘Δ ΠϕϯτυϦϰϯͳઃܭ

  17. ηΩϡϦςΟΠϯγσϯτ • URL࿙ΕͰੜ͡Δ֎෦ͷਓؒʹΑΔ։ด • SlackͰ͔͠ϦΫΤετ͸དྷͳ͍૝ఆͰ͸ɺURL͕ ࿙ΕͨΒ౪೉͞Ε͔Ͷͳ͍ɻ • ϩʔυόΠΫ͸1୆XXສ͢Δ෺΋͋Δ༷ͳͷͰׂΓ ͱ͋Γ͑Δ࿩

  18. ରԠࡦ • API GatewayͷCustom Authorize༻ͷFunction Λ࡞੒ • Request Headerʹೝূ༻ͷTokenΛࡌͤͯೝূ Λߦ͏

  19. ग़དྷΔͧʂʂʂ

  20. None
  21. աͪͱጻչͱݴ͍༁ͱ • ·͋PythonͳΒ༨༟Ͱ͠ΐͱ͍͏Ṗͷຫ৺ • ؁͑Ͱͨ͠ɻ • ઃܭϛεʹΑΔRollback • ࠷ॳ͸DynamoͰ͍͜͏ͱ͍ͯͨ͠

  22. ར༻ऀͷํʑ΋͏͠͹ Β͓͘଴ͪΛ͹ :pray:

  23. ·ͱΊ • Ψοͱ୹࣌ؒͰ࡞Δ΂͖ͩͬͨ • ੵΈॏͳΔݴ͍༁ɺ৳ͼΔೲظɺ๨Ε͍ͯ͘ίʔ υ • αʔόʔϨεΞʔΩςΫνϟ͸ศར • αʔόͷӡ༻Λ͋·Γؾʹ͔͚ͣʹྑ͍

    • ͪΐͬͱͨ͠λεΫΛ੾Γग़͢ʹ͸΍͸Γྑ͍