Slide 1

Slide 1 text

ଟ෼Θ͔Δ Serverless Framework ARCANA Meetup Nakao Takamasa

Slide 2

Slide 2 text

ࠓճͷझࢫ • αʔόʔϨε͸Կͳͷ͔ɺͦͯ͠Ͳ͏͍͏࣌ʹ໾ʹཱͭͷ͔ཧղͰ͖ ΔΑ͏ʹͳΔ • Serverless FrameworkͱLambda͕ͳΜͳͷ͔গ͠Ͱ΋ཧղͰ͖ΔΑ ͏ʹͳΔ • جૅͷجૅΛ࿩͠·͢ • AWS͕བྷΈ࢝ΊΔͱ͜Ζ·Ͱ͸࿩͠·ͤΜ

Slide 3

Slide 3 text

΅͘ ͠͝ͱ ɾLaravelͱJQueryͰԥΓ౗͢ ࠓقΞχϝ ɾͷΜͷΜͼΑΓΛ؍͍ͯ·͢

Slide 4

Slide 4 text

ʮࠓ൩ͷΞχϝͳΜ͚ͩͬʯ

Slide 5

Slide 5 text

SlackͷbotΛ࡞Γ·ͨ͠

Slide 6

Slide 6 text

̍೔̍ճ͔͠ಈ͔ͳ͍ίʔυര஀

Slide 7

Slide 7 text

͔͠͠ɺPCʹίʔυ͕͋ΔͷͰPCΛด͡Δͱ ಈ͍ͯ͘Ε·ͤΜ

Slide 8

Slide 8 text

ͳͷͰαʔόͰಈ͔͠·͠ΐ͏

Slide 9

Slide 9 text

αʔόͰಈ͔͠·͠ΐ͏ • ద౰ͳαʔό(VPS)Λܖ໿͠·͢ • SSH΍sudo·ΘΓͱ͍ͬͨUNIXؔ࿈ͷઃఆΛ͠·͢ • npmΛೖΕ·͢ • Node.jsΛೖΕ·͢ • ϑΝΠϧΛSFTPͱ͔Ͱసૹ͠·͢ • CronͰఆظతʹಈ͘Α͏ʹ͠·͢

Slide 10

Slide 10 text

͜ͷํ๏ʹ͸՝୊఺͕͋Δ

Slide 11

Slide 11 text

՝୊఺ • ίʔυΛಈ͔͍͚ͨͩ͠ͳͷʹLinuxͷߏஙΛͯ͠Δ • Πϯϑϥ஌ࣝͷͳ͍ํʹͱͬͯ͸ॳݟࡴ͠ • ಈ͍͍ͯͳ͍࣌ؒ΋՝ۚ͞Ε͍ͯΔ • 1೔1ඵ͚ͩಈ͘ίʔυ͕͋ͬͨΒ࢒Γͷ࣌ؒͷ՝ۚ͸…

Slide 12

Slide 12 text

࣮૷͞Εͨӡ༻

Slide 13

Slide 13 text

ސ٬͕ຊ౰ʹ ඞཁͩͬͨ΋ͷ ࣮૷͞Εͨӡ༻

Slide 14

Slide 14 text

Lambda • AWS͕ఏڙ͢ΔɺίʔυΛ࣮ߦͯ͘͠ΕΔ΍ͭ • ͱΓ͋͑ͣjs͕ಈ͘؀ڥΛ͘ΕΔ • 1ϛϦඵ͋ͨΓͰ՝ۚ͞ΕΔ • 0.0000000021USD • ·͔͔͋࣌ؒͬͯ΋ߴ͘͸ͳ͍ΑͶ

Slide 15

Slide 15 text

• MicrosoftʮαʔόϨεͳAzure FunctionsϦϦʔε͠·͢ʯ • IBMʮαʔόϨεͳIBM Cloud FunctionsϦϦʔε͠·͢ʯ • GoogleʮαʔόϨεͳGoogle Cloud FunctionsϦϦʔε͠·͢ʯ

Slide 16

Slide 16 text

‧‪‬‭⛺è䡢(’ω’)䡢è⛺䡡‬‪‧ ͏Θ͋͋͋͋͋͋͋͋͋͋͋͋

Slide 17

Slide 17 text

αʔϏε͝ͱʹίϚϯυ֮͑ΜͷͭΒ͍͠ แׅతʹͳΜ͔΍ͬͯ͘ΕΔ΋ͷ͸ͳ͍ͷ͔…

Slide 18

Slide 18 text

͋ΔΜͩͳͦΕ͕

Slide 19

Slide 19 text

Serverless Framework • ࠓ೔ͷຊ୊ • αʔόʔϨεܥͷߏ੒Λָʹ؅ཧͯ͘͠ΕΔπʔϧ • ָʢ؆୯ͱ͸ݴͬͯͳ͍ʣ

Slide 20

Slide 20 text

Serverless Frameworkͷಋೖ • NpmΛಋೖ͍ͯ͠Δ؀ڥͰҎԼͷίϚϯυΛୟ͘ • ؆୯Ͱ͢Ͷ

Slide 21

Slide 21 text

ϓϩόΠμʔΞΧ΢ϯτͷઃఆ • Serverless Framework͸֤αʔόʔϨεαʔϏεΛแׅͯ͘͠ΕΔ΍ ͭͳͷͰɺʮAWSͷLambdaͰ΍Δͱ͖͸͜ͷAPIΩʔ࢖ͬͯͶʯͱ ࣄલʹઃఆͯ͋͛͠Δඞཁ͕͋Δ • APIΩʔͷൃߦ͕ඞཁͳͷͰAWSͳΒϧʔτϢʔβʔͰೖͬͯIAM ϢʔβʔΛ৽ن࡞੒͓ͯ͘͠

Slide 22

Slide 22 text

ϓϩδΣΫτͷ࡞੒

Slide 23

Slide 23 text

ϓϩδΣΫτͷ࡞੒ σΟϨΫτϦΛ࡞Δ

Slide 24

Slide 24 text

ϓϩδΣΫτͷ࡞੒ BXTͷMBNCEBͰ/PEFKTΛ ࢖͏ͱ͖ͷςϯϓϨʔτ ໊લ

Slide 25

Slide 25 text

࡞Δ • ಈ͔͍ͨ͠ίʔυΛ͕Γ͕Γॻ͘

Slide 26

Slide 26 text

࡞Δ • ͍͍Ͱ͢Ͷ

Slide 27

Slide 27 text

ิ଍ࣄ߲ • ؀ڥม਺͸serverless.ymlͰߦ͏ • API GatewayͷઃఆͳͲ΋͜͜Ͱߦ͏

Slide 28

Slide 28 text

σϓϩΠ • sls deployͰOK • ϥΠϒϥϦ΋Α͠ͳʹ ͯ͘͠ΕΔ • ZIPͰݻΊͯS3ʹ্͛ͯ CFnͰల։͢Δ·Ͱશ ࣗಈͰ͢Δ

Slide 29

Slide 29 text

• ʮServerless Frameworkͷ΄͏͕೉ͦ͠͏ʹݟ͑ΔΜ͚ͩͲʯ • ʮ͜Ε࢖ΘͣʹLambdaͰ΍ͬͨ΄͏ָ͕ͳΜ͡Όͳ͍ͷʯ

Slide 30

Slide 30 text

ಉ͜͡ͱΛLambdaͰ΍Δ৔߹ • σΟϨΫτϦΛzipͰѹॖ͢Δʢnode_modules΋ͦͷ··Ͱྑ͍ʣ • AWSͷϚωδϝϯτ ίϯιʔϧΛ։͖ɺlambdaΛ։͘ • ֘౰ϓϩδΣΫτΛબ୒ • ZipΛΞοϓϩʔυ

Slide 31

Slide 31 text

͜͏ͳΓ͔Ͷͳ͍ͷͰ͓͢͢Ί͸͠·ͤΜ

Slide 32

Slide 32 text

·ͱΊ • Serverless Framework͸Lambda”ͳͲ”ͷαʔόʔϨεΞʔΩςΫ νϟΛָʹѻ͑ΔϑϨʔϜϫʔΫ • AWSͷ৔߹͸APIͷઃఆͳͲ΋ࣗಈԽͰ͖ΔͨΊɺϙνϙνૢ࡞͢Δ ख͕ؒҰؾʹল͚Δ

Slide 33

Slide 33 text

ऴΘΓ