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

Serverless Frameworkで行うサーバレスアーキテクチャの構築から運用までの話/...

Serverless Frameworkで行うサーバレスアーキテクチャの構築から運用までの話/MasterCloud – Container adoptions on the cloud (Tokyo)

DigitalCube Inc.

May 16, 2017
Tweet

More Decks by DigitalCube Inc.

Other Decks in Technology

Transcript

  1. M A S T E R C L O U

    D – C O N TA I N E R A D O P T I O N S O N T H E C L O U D ( T O K Y O ) - S H I F T E R Ͱ ͷ Ϣʔεέ ʔε - #getshifter S E R V E R L E S S F R A M E W O R K Ͱ ߦ ͏ α ʔόʔ Ϩε Ξʔ Ω ς Ϋ ν ϟ ͷ ߏ ங ͔ Β ӡ ༻ · Ͱ ͷ ࿩
  2. E N G I N E E R O F

    S H I F T E R S E R V E R L E S S F R A M E W O R K C O R E C O N T R I B U T O R ࣗ ݾ ঺ հ #getshifter
  3. #getshifter D E V E L O P P L

    U G I N IUUQTHJUIVCDPNIPSJLFTFSWFSMFTTTUFQGVODUJPOT
  4. #getshifter P O S T O N Q I I

    TA IUUQRJJUBDPNIPSJLF
  5. ɾ S h i f t e r ͱ ͸

    ? ɾ S e r v e r l e s s Ξʔ Ω ς Ϋ ν ϟ ͱ ͸ ? ɾ S h i f t e r Ͱ ͷ S e r v e r l e s s Ξʔ Ω ς Ϋ ν ϟ ͷ ׆ ༻ ɾ S e r v e r l e s s F r a m e w o r k Λ ࢖ ͬ ͨ C I / C D ύΠ ϓ ϥ Π ϯ #getshifter
  6. S H I F T E R ͱ ͸ ?

    #getshifter
  7. S h i f t e r ͸ ɺ Wo

    rd P re s s αΠ τ Λ Ұ ࿈ ͷ ੩ త H T M L ϑ ΝΠϧ ʹ 
 ม ׵ ͠ ɺ C D N Λ հ ͯͦ͠ Ε Β Λ ఏ ڙ ͢ Δ ϗ ε ςΟ ϯ ά α ʔ Ϗ ε Ͱ ͢ɻ ι ϑ τ ΢ Σ Ξ อ क ΍ α ʔό ؅ ཧ ͷ ෛ ୲ Λ ഉ আ ͢ Δ ϝ Ϧ ο τ ͕ ͋ Γ · ͢ɻ #getshifter
  8. [ ͓ ͞ Β ͍ ] W O R D

    P R E S S ͱ ͸ ? #getshifter
  9. M o s t p o p u l a

    r c o n t e n t m a n a g e m e n t s y s t e m s h t t p s : / / w 3 t e c h s . c o m / 
 s i n c e 1 J a n u a r y 2 0 1 7 Usage Change Since 1 January 2017 Market Share Change Since 1 January 2017 1.WordPress 27.5% +0.2% 58.7% +0.2% 2.Joomla 3.3% -0.1% 7.1% -0.1% 3.Drupal 2.2% 4.8% #getshifter
  10. – ๭ α Π τ ੍ ࡞ ୅ ཧ ళ

    ͷ ੠ “ϝϯςφϯε΍ηΩϡϦςΟ͕໰୊ࢹ͞ΕΔ͕….
 ։ൃऀͷϦιʔεௐୡ΍ϊ΢ϋ΢ɺΤϯυ͔Βͷೲظ΍ίετΛߟ͑Δͱ….” #getshifter
  11. – ๭ ৘ ใ γε ςϜ ୲ ౰ ऀ ͷ

    ੠ “৘γεࢹ఺Ͱ͸ӡ༻͕ͭΒ͍ͷ͚ͩͲ…..
 શ͘ར༻͠ͳ͍Θ͚ʹ΋͍͔ͳ͍ͷ͕…ݱ࣮” #getshifter
  12. W O R D P R E S S ͷ

    ӡ ༻ ͱ ͔ η Ω ϡ Ϧ ςΟ #getshifter
  13. Wo rd P re s s αΠ τ ͷ վ

    ͟ Μ ඃ ֐ ͸ 1 5 0 ສ ݅ ௒ ʹ 
 ʮ ࠷ ѱ ڃ ͷ ੬ ऑ ੑ ʯ
  14. Wo rd P re s s ͸ ࠜ ຊ త

    ʹ ӡ ༻ ΍ η Ω ϡ Ϧ ςΟ ʹ ໰ ୊ ͕ ͋ Δ ͷ ͔ʁ #getshifter
  15. ɾ Wo rd P re s s C o re

    ͷ Ξ οϓ σ ʔ τ ͕ ස ൟ ͢ ͗ Δ 
 ɾ Wo rd P re s s P l u g i n ͕ ੬ ऑ 
 ɾ Wo rd P re s s T h e m e ͕ ෳ ࡶ Ͱ ϝ ϯ ς ෆ ೳ 
 ɾ ͦ ΋ ͦ ΋ … P H P ΍ M y S Q L ͳ Ͳͷ ϛ υϧ ΢ Σ Ξ ʹ ໰ ୊ #getshifter
  16. ɾ ౾ ஌ ࣝ Wo rd P re s s

    ઐ ໳ ͷ Ϛ ω ʔ δ υ ϗ ε ςΟ ϯ ά Λ ར ༻ ͢ Δ ͜ ͱ Ͱ 
 ϝ ϯ ς φ ϯε ί ε τ ΍ φ Ϩ ο δ Λ ڞ ༗ Ͱ ͖ Δ ͷ Ͱ ؅ ཧ Ϧ ι ʔε Λ ܰ ݮ Ͱ ͖ · ͢ɻ 
 ୅ ද త ͳ α ʔ Ϗ ε - W P E n g i n e - P a g e l y - A M I M O T O 
 ͳ Ͳ ͳ Ͳ …
  17. අ ༻ ର ޮ Ռ ͷ ߴ ͍ બ ୒

    ࢶ ͕ ཉ ͠ ͍ ! ར ศ ੑ 㱻 ӡ ༻ ί ε τ #getshifter
  18. S H I F T W O R D P

    R E S S T O S E R V E R L E S S
  19. S E R V E R L E S S

    Ξʔ Ω ς Ϋ ν ϟ ͱ ͸ #getshifter
  20. S e r v e r l e s s

    Ξʔ Ω ς Ϋ ν ϟ ͱ ͸ 
 - F a a S ( L a m b d a , G o o g l e C l o u d F u n c t i o n s , A z u re F u n c t i o n s e t c ) ͱ Ϛ ω ʔ δ υ α ʔ Ϗ ε Λ ࢖ ͬͯ ߏ ੒ ͞ Ε ͨ γε ςϜ - Ϣʔεέ ʔε ɿ 
 w e b , Ϟ όΠϧ , I o T ͳ Ͳͷ A P I ͷ ό ο Ϋ Τ ϯ υ σ ʔ λ ϓ ϩ η ο γ ϯ ά - Πϕ ϯ τ ۦ ಈ ܕ ( ϓ ϩ η ε ͕ ৗ ற ͠ ͳ ͍ ) - α ʔό ͕ ແ ͍ ͱ ͍ ͏ ͜ ͱ Ͱ ͸ ͳ ͍ ɻ α ʔό ͷ ؅ ཧ Λ Ϋ ϥ ΢ υ ϕ ϯ μʔ ʹ Ξ ΢ τι ʔε #getshifter
  21. - α ʔό ͷ ϝ ϯ ς φ ϯε Λ

    Ξ ΢ τι ʔε ग़ དྷ Δ ͨ Ί ɺ ։ ൃ ऀ ͕ ί ʔ υ Λ ॻ ͘͜ ͱ ʹ ϑ Υ ʔΧ ε Ͱ ͖ Δ - ϑ Ν ϯ Ϋ γ ϣ ϯ ͷ ࣮ ߦ ࣌ ؒ ʹ Ԡ ͡ ͯ ՝ ۚ ͞ Ε Δ ͨ Ί ɺ ଟ ͘ͷ ৔ ߹ ͸ ί ε τ ͕ ҆ ͘ ͳΔ #getshifter
  22. S H I F T E R ʹ ͓ ͚Δ

    α ʔό Ϩε Ξʔ Ω ς Ϋ ν ϟ ͷ ׆ ༻ • WordPressΛىಈ͢ΔDockerίϯς φҎ֎͸αʔόϨεΞʔΩςΫνϟ Ͱͷߏ੒ • 5ਓఔ౓ͷ։ൃνʔϜͰ΋ޮ཰Α͘ϝ ϯςφϯε͕ग़དྷ͍ͯΔ • αʔϏε։͔࢝ΒɺΠϯϑϥͷ໰୊ ʹىҼ͢ΔαʔϏεμ΢ϯ͸ແ͠ #getshifter
  23. Q α ʔό Ϩε Ξʔ Ω ς Ϋ ν ϟ

    ͸ ۜ ͷ ஄ ؙ ʁ A ͍ ͑΋ ͪ Ζ Μ ͦΜ ͳ ͜ ͱ ͸ ͋ Γ · ͤ Μ #getshifter
  24. - α ʔό ͷ ؅ ཧ ͸ ߟ ͑ ͳ

    ͘ ͯΑ ͍ ͕ ӡ ༻ ࣗ ମ ͕ ͳ ͘ ͳ ͬ ͨ Θ ͚ Ͱ ͸ ͳ ͍ - α ʔό ༗ Γ ͖ Ͱ ߟ ͑Δ σ ϓ ϩ Π ͷ ϑ ϩ ʔ ͕ ࢖ ͑ ͳ ͍ ( s s h Ͱ ϩ άΠ ϯ ͠ ͯ g i t p u l l Λ ߦ ͏ ͳ Ͳ ) - α ʔό Ϩε Ξʔ Ω ς Ϋ ν ϟ ͳ ΒͰ ͸ ͷ ӡ ༻ ࣗ ಈ Խ Λ ߦ ͏ ඞ ཁ ͕ ͋ Δ ( ε ς ʔ δ ͷ ෼ ׂ ͳ Ͳ ) #getshifter
  25. S e r v e r l e s s

    F r a m e w o r k ͱ ͸ 
 - α ʔόʔ Ϩε Ξʔ Ω ς Ϋ ν ϟ ʹ ͓ ͚Δ ։ ൃ ΍ σ ϓ ϩ Π Λ α ϙʔ τ ͯ͘͠Ε Δ ί Ϛ ϯ υ ϥ Π ϯ π ʔϧ - y a m l ʹ ΑΔ Ξʔ Ω ς Ϋ ν ϟ ͷ ߏ ੒ ؅ ཧ - Ϛϧ ν Ϋ ϥ ΢ υ ϓ ϩ όΠμʔ α ϙʔ τ - O S S ͱ ͯ͠ G i t H u b ্ Ͱ ։ ൃ - ϓ ϥ άΠ ϯ ʹ ΑΔ ֦ ு #getshifter
  26. S E R V E R L E S S

    ͕ ఏ ڙ ͢ Δ ί Ϛ ϯ υ ϥ Π ϯ • αʔόϨεΞʔΩςΫνϟͷ։ൃɾ ӡ༻ʹඞཁͳϥΠϑαΠΫϧ͕ίϚ ϯυϥΠϯͷΈͰ࣮ݱͰ͖Δ #getshifter sls create ϓϩδΣΫτͷ࡞੒ sls deploy ϩʔΧϧ؀ڥ͔ΒΫϥ΢υ΁ͷσϓϩΠ sls invoke ϑΝϯΫγϣϯͷ࣮ߦ sls info σϓϩΠ͞Εͨߏ੒ͷ৘ใΛදࣔ sls logs ϑΝϯΫγϣϯͷ࣮ߦϩάͷ֬ೝ sls remove σϓϩΠ͞Εͨߏ੒ͷ࡟আ
  27. ߏ ੒ ؅ ཧ • ΞʔΩςΫνϟʹඞཁͳϦιʔε͸ ͢΂ͯserverless.ymlʹهड़ͯ͠؅ཧ ͢Δ #getshifter provider:

    name: aws runtime: nodejs4.3 iamRoleStatements: - Effect: Allow Action: - dynamodb:* functions: create: handler: todos/create.create events: - http: path: todos method: post cors: true
  28. Ͳͷ Α ͏ ʹ ։ ൃ ͔ Β ӡ ༻

    Λ ߦ ͏ ͷ ͔ #getshifter
  29. σ ϓ ϩ Π · Ͱ ͷ ϥ Π ϑ

    α ΠΫϧ • جຊతʹ͸͜ͷϥΠϑαΠΫϧΛճ ͯ͠ίʔυ΍ߏ੒ͷσϓϩΠ·ͰΛ ࣮ࢪ͢Δ • ӡ༻ʹ͓͍ͯ͸σϓϩΠٴͼςετ ͸ࣗಈԽ͕ඞਢ #getshifter αʔϏεͷ࡞੒ serverless.yml΁ͷΞʔΩς Ϋνϟఆٛ σϓϩΠ Ϋϥ΢υ্Ͱͷςετ ϩʔΧϧͰͷfunction։ ൃ
  30. σ ϓ ϩ Π · Ͱ ͷ ϥ Π ϑ

    α ΠΫϧ • جຊతʹ͸͜ͷϥΠϑαΠΫϧΛճ ͯ͠ίʔυ΍ߏ੒ͷσϓϩΠ·ͰΛ ࣮ࢪ͢Δ • ӡ༻ʹ͓͍ͯ͸σϓϩΠٴͼςετ ͸ࣗಈԽ͕ඞਢ #getshifter αʔϏεͷ࡞੒ serverless.yml΁ͷΞʔΩς Ϋνϟఆٛ σϓϩΠ Ϋϥ΢υ্Ͱͷςετ ϩʔΧϧͰͷfunction։ ൃ ࣗಈԽ
  31. #getshifter α ʔ ό Ϩε Ξʔ Ω ς Ϋ ν

    ϟ ͳ ΒͰ ͸ ͷ ࣗ ಈ Խ ͷ ε ε ϝ - α ʔόʔ Ϩε Ξʔ Ω ς Ϋ ν ϟ ͸ F a a S ͱ ༷ ʑ ͳ α ʔ Ϗ ε ͷ ෳ ࡶ ͳ ૊ Έ ߹ Θ ͤ Ͱ ग़ དྷ ͯ ͍ Δ ͜ ͱ ͕ ଟ ͍ ɻ ख ಈ ʹ ΑΔ α ʔ Ϗ ε ͷ σ ϓ ϩ Π ๨ Ε΍ ϛ ε ͕ ͋ Δ ͱ ΍ ͹ ͍ ( Ͳ ͜ Ͱ ϛ ε ͕ ͋ ͬ ͨ ͷ ͔ ޙ ͔ Β ௥ ͍ ͔ ͚Δ ͷ ͕ େ ม ) - ߏ ੒ ͕ ଟ ذ ʹ ౉ Δ ͨ Ί ௨ ৗ ͷ Ϣ χ ο τ ςε τ ͩ ͚ Ͱ ͸ ɺ ඼ ࣭ Λ Χ όʔ ͠ ͖ Ε ͳ ͍ ɻ Π ϯ ς ά Ϩ ʔ γ ϣ ϯ ςε τ ͱ ͍ ͏ ࣮ ࡍ ʹ Ϋ ϥ ΢ υ ؀ ڥ ʹ ߏ ੒ Λ σ ϓ ϩ Π ͯ͠ͷ ࣗ ಈ ςε τ ΋ ࣮ ࢪ ͢ Δ
  32. #getshifter Π ϯ ς ά Ϩ ʔ γ ϣ ϯ

    ςε τ - s e r v e r l e s s . y m l ʹ ه ड़ ͠ ͨ ߏ ੒ Λ ઐ ༻ ͷ ε ς ʔ δ ʹ σ ϓ ϩ Π Λ ߦ ͏ ( s l s d e p l o y — s t a g e i n t e g r a t i o n t e s t ) - m o c h a ΍ j e s t ͱ ͍ ͬ ͨ ςε ςΟ ϯ ά ϑ Ϩ ʔϜϫ ʔ Ϋ Λ ࢖ ͬͯ σ ϓ ϩ Π ࡁ Έ ͷ ؀ ڥ ʹ ͯ ߏ ੒ Λ ಈ ͔ ͯ͠ ฦ Γ ஋ Λ ν Σ ο Ϋ - ςε τ ͕ ऴ Θ Ε ͹ ɺ ͦ ͷ ߏ ੒ ͸ ࡟ আ ( s l s re m o v e — s t a g e i n t e g r a t i o n t e s t ) - Tr a v i s ΍ C i rc l e C I ͱ ͍ ͬ ͨ α ʔ Ϗ ε ͱ ࿈ ܞ ͞ ͤ ͯɺ ຊ ൪ σ ϓ ϩ Π લ ͳ Ͳ λΠ ϛ ϯ ά Λ ܾ Ίͯ ࣮ ߦ Ͱ ͖ Δ Α ͏ ʹ ͯ͠ ͓ ͘
  33. A P I G AT E WAY Ͱ ߏ ੒

    ͞ Ε ͨ A P I ͷ ςε τ #getshifter API σϓϩΠ ࣄલʹఆ͍ٛͯͨ͠ೖྗ஋ͱ ฦΓ஋ΛνΣοΫ ͢΂ͯςετ͕௨Ε ͹ߏ੒࡟আ IUUQTHJUIVCDPNIPSJLFTFSWFSMFTTBQJJOUFHSBUJPOUFTU TBNQMFCMPCNBTUFSJOUFHSBUJPOUFTUUFTUKT--
  34. S 3 Πϕ ϯ τ Ͱ ߏ ੒ ͞ Ε

    ͨ Ξʔ Ω ς Ϋ ν ϟ ͷ ςε τ #getshifter S3σϓϩΠ σϓϩΠࡁΈͷόέοτ΁ͷ ΦϒδΣΫτૢ࡞ ͢΂ͯςετ͕௨Ε ͹ߏ੒࡟আ IUUQTHJUIVCDPNIPSJLFTFSWFSMFTTBQJJOUFHSBUJPOUFTU TBNQMFCMPCNBTUFSJOUFHSBUJPOUFTUUFTUKT-- CloudWatchLogsͰΠϕϯτ ൃՐΛ֬ೝ