Slide 1

Slide 1 text

C o d e P i p e l i n e + C o d e B u i l d Ͱ S e r v e r l e s s F r a m e w o r k ͷ σ ϓ ϩ Π Λ ָ ʹ ͢ Δ S e r v e r l e s s M e e t u p O s a k a v o l . 2 LT

Slide 2

Slide 2 text

· ͱ Ί • AWS Code BuildͰServerless FrameworkͷσϓϩΠ͕ࣗಈԽͰ͖Δ • AWS CodePipeline΋࢖͑͹ঝೝϑϩʔ·Ͱ࡞੒Մೳ • खॱॻͷཁΔ࡞ۀ͸ͲΜͲΜࣗಈԽ΍͍ͬͯ͜͏

Slide 3

Slide 3 text

H i d e t a k a O k a m o t o • AMIMOTO / Shifter • WordBenchKyoto • SAAϦϕϯδ੒ޭ

Slide 4

Slide 4 text

https://getshifter.io/

Slide 5

Slide 5 text

https://serverless.com/

Slide 6

Slide 6 text

A P I ͸ S e r v e r l e s s F W Ͱ σ ϓ ϩ Πɺ ϑ ϩ ϯ τ ͸ S 3 Ͱ ϗ ε τ ͠ Α ͏

Slide 7

Slide 7 text

$ s l s d e p l o y $ s 3 s y n c . s 3 : / / s o m e - b u c k e t

Slide 8

Slide 8 text

։ ൃ ͱ ຊ ൪ Ͱ ؀ ڥ Θ ͚Α ͏ ɻ σ ϓ ϩ Π ࣌ ͸ ཁ ஫ ҙ Ͷ ɻ

Slide 9

Slide 9 text

$ s l s d e p l o y - - s t a g e d e v $ s 3 s y n c . s 3 : / / d e v - s o m e - b u c k e t $ s l s d e p l o y - - s t a g e p ro d $ s 3 s y n c . s 3 : / / p ro d - s o m e - b u c k e t

Slide 10

Slide 10 text

n p m ͷ ύ ο έ ʔ δ Λ ͍ ͭ͘ ͔ ಉ ࠝ ͠ ͨ ͍

Slide 11

Slide 11 text

$ n p m p r u n e - - p ro d u c t i o n $ s l s d e p l o y - - s t a g e d e v $ s 3 s y n c . s 3 : / / d e v - s o m e - b u c k e t $ s l s d e p l o y - - s t a g e p ro d $ s 3 s y n c . s 3 : / / p ro d - s o m e - b u c k e t $ n p m i n s t a l l

Slide 12

Slide 12 text

σ ϓ ϩ Π લ ʹ ςε τ ΍ ߏ จ ν Σ ο Ϋ ΋ ͠ Α ͏

Slide 13

Slide 13 text

$ n p m t e s t $ n p m r u n l i n t $ n p m p r u n e - - p ro d u c t i o n $ s l s d e p l o y - - s t a g e d e v $ s 3 s y n c . s 3 : / / d e v - s o m e - b u c k e t $ s l s d e p l o y - - s t a g e p ro d $ s 3 s y n c . s 3 : / / p ro d - s o m e - b u c k e t $ n p m i n s t a l l

Slide 14

Slide 14 text

C D N ͭ ͚ ͨ ͷ Ͱɺ Ω ϟ ο γ ϡ ΋ ফ ͠ · ͠ ΐ ͏

Slide 15

Slide 15 text

$ n p m t e s t $ n p m r u n l i n t $ n p m p r u n e - - p ro d u c t i o n $ s l s d e p l o y - - s t a g e d e v $ s 3 s y n c . s 3 : / / d e v - s o m e - b u c k e t $ s l s d e p l o y - - s t a g e p ro d $ s 3 s y n c . s 3 : / / p ro d - s o m e - b u c k e t $ a w s c l o u d f ro n t c re a t e - i n v a l i d a t i o n - - p a t h " / * " $ n p m i n s t a l l

Slide 16

Slide 16 text

ʊ ਓ ਓ ਓ ਓ ਓ ʊ ʼ ɹ ͭ Β ͍ ɹ ʻ ʉ Y ^ Y ^ Y ^ Y ʉ

Slide 17

Slide 17 text

ί Ϛ ϯ υ ͕ ૿ ͑Δ ͱ ϛ ε ΍ ώ Ϡ Ϧ ϋο τ ΋ ૿ ͑Δ • σϓϩΠઌΛؒҧ͑Δʢdev ? develpoment ? staging ?ʣ • ௕͘ͳΔखॱॻɺ࿙ΕΔߋ৽ • Ωϟογϡফ͠๨ΕɺΩϟογϡ࡟আૢ࡞ϛε • ύοέʔδಉࣦࠝഊʢ--save-devͨ͠ͷ΋ೖͬͯ༰ྔΦʔόʔʣ

Slide 18

Slide 18 text

ʊ ਓ ਓ ਓ ਓ ਓ ʊ ʼ ɹ ͭ Β ͍ ɹ ʻ ʉ Y ^ Y ^ Y ^ Y ʉ

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

C o d e B u i l d w i t h S e r v e r l e s s F r a m e w o r k • Code Build͸Node.js͕࣮ߦՄೳ • buildspec.ymlͰσϓϩΠίϚϯυΛGit؅ཧ • ؀ڥม਺΋ઃఆՄೳͳͷͰࣗ༝౓͕ߴ͍

Slide 21

Slide 21 text

΍ ͬͯ Έͯ ϋϚ ͬ ͨ o r ཁ ஫ ҙ ͩ ͬ ͨ ͱ ͜ Ζ • IAMϩʔϧ • Serverless FrameworkͷΠϯετʔϧ৔ॴ • σϓϩΠλΠϛϯάͷࢦఆͱঝೝϑϩʔ • Code Buildߋ৽Ͱ͖ͳ͍໰୊

Slide 22

Slide 22 text

΍ ͬͯ Έͯ ϋϚ ͬ ͨ o r ཁ ஫ ҙ ͩ ͬ ͨ ͱ ͜ Ζ • IAMϩʔϧ • Serverless FrameworkͷΠϯετʔϧ৔ॴ • σϓϩΠλΠϛϯάͷࢦఆͱঝೝϑϩʔ • Code Buildߋ৽Ͱ͖ͳ͍໰୊

Slide 23

Slide 23 text

I A M ϩ ʔϧ ઃ ఆ ͕ େ ม • Serverless FW͕৮ΔϦιʔεଟ͍ • ϑϧݖݶ͸Ͱ͖Δ͚ͩ౉ͨ͘͠ͳ͍ • IAM͸ӈͷ͕̒ͭ࠷খݶʢͳ͸ͣʣ "iam:GetRole", "iam:CreateRole", "iam:DeleteRole", "iam:PutRolePolicy", "iam:DeleteRolePolicy", "iam:PassRole"

Slide 24

Slide 24 text

΍ ͬͯ Έͯ ϋϚ ͬ ͨ o r ཁ ஫ ҙ ͩ ͬ ͨ ͱ ͜ Ζ • IAMϩʔϧ • Serverless FrameworkͷΠϯετʔϧ৔ॴ • σϓϩΠλΠϛϯάͷࢦఆͱঝೝϑϩʔ • Code Buildߋ৽Ͱ͖ͳ͍໰୊

Slide 25

Slide 25 text

n p m p r u n e - - p ro d u c t i o n ʹ ཁ ஫ ҙ • `npm prune --production`͢ΔͱdevDependenciesͷύοέʔδ͕ফ͑Δ • `npm install --save-dev serverless`΋ফ͑Δ • `npm install -g serverless@version`ͷํ͕ແ೉͔΋

Slide 26

Slide 26 text

΍ ͬͯ Έͯ ϋϚ ͬ ͨ o r ཁ ஫ ҙ ͩ ͬ ͨ ͱ ͜ Ζ • IAMϩʔϧ • Serverless FrameworkͷΠϯετʔϧ৔ॴ • σϓϩΠλΠϛϯάͷࢦఆͱঝೝϑϩʔ • Code Buildߋ৽Ͱ͖ͳ͍໰୊

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

ঝ ೝ ϑ ϩ ʔ Λ ͭ ͚Δ ͳ Β C o d e P i p e l i n e • Code PipelineΛ࢖͑͹खಈঝೝ͕ઃఆͰ͖Δ • SNSͰ௨஌Λग़ͤΔͷͰɺϦϦʔεϦʔμʔ΁ͷ֬ೝґཔ΋ࣗಈԽ • Code Pipelineͷ؅ཧը໘ͰCode BuildͷઃఆΛ͢ΔͱͪΐͬͱϋϚΔ

Slide 29

Slide 29 text

΍ ͬͯ Έͯ ϋϚ ͬ ͨ o r ཁ ஫ ҙ ͩ ͬ ͨ ͱ ͜ Ζ • IAMϩʔϧ • Serverless FrameworkͷΠϯετʔϧ৔ॴ • σϓϩΠλΠϛϯάͷࢦఆͱঝೝϑϩʔ • Code Buildߋ৽Ͱ͖ͳ͍໰୊

Slide 30

Slide 30 text

C o d e P i p e l i n e ͔ Β ৮ Δ ͱ ઃ ఆ ม ߋ Ͱ ͖ ͳ ͍ • Code Pipeline͔Β࡞ͬͨCode BuildͷϏϧυ͸ߋ৽Ͱ͖ͳ͍ • มߋ͍ͨ࣌͠͸ɺ৽͘͠࡞Γ௚͢ඞཁ͋Γ • ؀ڥม਺ม͍͑ͨ࣌ʹͭΒ͍

Slide 31

Slide 31 text

· ͱ Ί • Serverless Framework͸Code Build͔ΒσϓϩΠՄೳ • Code PipelineΛ࢖͑͹ϦϦʔεͷϫʔΫϑϩʔ΋࡞Γ΍͍͢ • SaaS / FaaS࢖ͬͯʮ࡞ۀʯΛͲΜͲΜݮΒ͍ͯ͜͠͏