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

AWS parking lot shutter hack project

teitei_tk
February 09, 2017
3.5k

AWS parking lot shutter hack project

teitei_tk

February 09, 2017
Tweet

Transcript

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  8. ΍͍ͬͯͧ͘

    View full-size slide

  9. چ ߏ੒ਤ
    Post
    Get
    Every Sec

    View full-size slide

  10. ͜ΕΛϕʔεʹ͢Δ

    View full-size slide

  11. ৽ ߏ੒ਤ
    1. Open Request
    2. Update
    Shutter Status
    3. Request Check
    &
    Open Door
    4. Finish Message

    View full-size slide

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

    View full-size slide

  13. AWS(Server)
    • API Gateway & Lambda
    • ྲྀߦΓʁͷServerless Architecture @ Python
    • ϑϨʔϜϫʔΫ͸࢖Θͳ͍
    • SQS
    • ΦʔϓϯϦΫΤετ͕དྷͨΒQueueΛEnQueue

    View full-size slide

  14. API Gateway
    • ֤HTTP Methodຖʹ໾ׂΛ෼ࢄ
    • GET
    • γϟολʔͷঢ়ଶ؅ཧ
    • PUT
    • γϟολʔͷΦʔϓϯ
    • POST
    • γϟολʔ͕։͖ऴΘͬͨࡍͷ௨஌

    View full-size slide

  15. ·͋Α͋͘Δ
    ΠϕϯτυϦϰϯͳઃܭ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  18. ग़དྷΔͧʂʂʂ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide