Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
serverless-framework-workshop
Search
堀家隆宏
March 05, 2017
Technology
4
1.9k
serverless-framework-workshop
堀家隆宏
March 05, 2017
Tweet
Share
More Decks by 堀家隆宏
See All by 堀家隆宏
オープンソースコミュニティで加速するサーバーレスの未来/serverless will be
horike37
4
690
auth0-meetup.pdf
horike37
1
250
What’s happening with Serverless Framework, and it lives with AWS SAM.
horike37
0
77
What is Serverless. Why is Serverless.
horike37
1
59
aws-with-functional-saas
horike37
2
160
serverless-with-oss
horike37
0
100
slsconftokyo
horike37
0
5.3k
slsconfworkshop
horike37
3
2.5k
Test Driven Development For Lambda
horike37
2
290
Other Decks in Technology
See All in Technology
ABEMA のコンテンツ制作を最適化!生成 AI x クラウド映像編集システム / abema-ai-editor
cyberagentdevelopers
PRO
1
180
CI/CDやテスト自動化の開発プロジェクトへの適用
megascus
3
740
大規模データ基盤チームのオンプレTiDB運用への挑戦 / dpu-tidb
cyberagentdevelopers
PRO
1
110
AWS re:Inventを徹底的に楽しむためのTips / Tips for thoroughly enjoying AWS re:Invent
yuj1osm
1
540
ネット広告に未来はあるか?「3rd Party Cookie廃止とPrivacy Sandboxの効果検証の裏側」 / third-party-cookie-privacy
cyberagentdevelopers
PRO
1
120
生成AIと知識グラフの相互利用に基づく文書解析
koujikozaki
1
130
プロダクトチームへのSystem Risk Records導入・運用事例の紹介/Introduction and Case Studies on Implementing and Operating System Risk Records for Product Teams
taddy_919
1
160
いまならこう作りたい AWSコンテナ[本格]入門ハンズオン 〜2024年版 ハンズオンの構想〜
horsewin
9
2k
WINTICKETアプリで実現した高可用性と高速リリースを支えるエコシステム / winticket-eco-system
cyberagentdevelopers
PRO
1
190
初心者に Vue.js を 教えるには
tsukuha
5
390
分布で見る効果検証入門 / ai-distributional-effect
cyberagentdevelopers
PRO
4
690
で、ValhallaのValue Classってどうなったの?
skrb
1
660
Featured
See All Featured
Fireside Chat
paigeccino
32
3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
790
How to train your dragon (web standard)
notwaldorf
88
5.7k
YesSQL, Process and Tooling at Scale
rocio
167
14k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
How STYLIGHT went responsive
nonsquared
95
5.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
37
1.8k
RailsConf 2023
tenderlove
29
880
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
107
49k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
BBQ
matthewcrist
85
9.3k
Transcript
4FSWFSMFTT'SBNFXPSLͷ جૅͱ։ൃख๏͔Β $*$%ύΠϓϥΠϯͷߏங·Ͱ
ࣗݾհ
ࣗݾհ %JHJUBM$VCF$P-UEͷΤϯδχΞ 4FSWFSMFTT'SBNFXPSL։ൃ νʔϜϝϯόʔ ओཁݴޠ /PEFKT 1)1
4FSWFSMFTT4UFQ'VODUJPOT IUUQTHJUIVCDPNIPSJLFTFSWFSMFTTTUFQGVODUJPOT
4IJGUFS IUUQTHFUTIJGUFSJP
2JJUB IUUQRJJUBDPNIPSJLF
4FSWFSMFTT'SBNFXPSLͷ֓ཁ
4FSWFSMFTT'SBNFXPSLͱ αʔόʔϨεΞʔΩςΫνϟʹ͓͚Δ։ൃσϓϩΠΛ αϙʔτͯ͘͠ΕΔίϚϯυϥΠϯπʔϧ ZBNMʹΑΔΞʔΩςΫνϟͷߏཧ ϚϧνΫϥυϓϩόΠμʔαϙʔτ 044ͱͯ͠(JU)VC্Ͱ։ൃ
ϓϥάΠϯʹΑΔ֦ு
࣮͞Ε͍ͯΔओͳίϚϯυ TMTDSFBUF ϓϩδΣΫτͷ࡞ TMTEFQMPZ ϩʔΧϧڥ͔ΒΫϥυͷσϓϩΠ TMTJOWPLF ϑΝϯΫγϣϯͷ࣮ߦ TMTJOGP σϓϩΠ͞ΕͨߏͷใΛදࣔ TMTMPHT
ϑΝϯΫγϣϯͷ࣮ߦϩάͷ֬ೝ TMTSFNPWF σϓϩΠ͞Εͨߏͷআ
ϓϩδΣΫτͷϑΝΠϧߏཧ /PEFKT ᵓᴷTFSWFSMFTTZNM ᵋᴷIBOEMFSKT ΞʔΩςΫνϟશମͷߏΛ ఆٛ͢ΔϑΝΠϧ ϑΝϯΫγϣϯͰ࣮ߦ͞ΕΔ ϓϩάϥϜ
:".-ϑΝΠϧʹΑΔߏཧ QSPWJEFS OBNFBXT SVOUJNFOPEFKT JBN3PMF4UBUFNFOUT &⒎FDU"MMPX "DUJPO EZOBNPEC GVODUJPOT
DSFBUF IBOEMFSUPEPTDSFBUFDSFBUF FWFOUT IUUQ QBUIUPEPT NFUIPEQPTU DPSTUSVF ϑΝϯΫγϣϯʹΞλον͢Δ ݖݶͷઃఆ ༻͢ΔΫϥυϓϩόΠμʔٴͼ ϥϯλΠϜڥͷࢦఆ ϑΝϯΫγϣϯͷ࣮ߦϑΝΠϧͷ ࢦఆ ϑΝϯΫγϣϯΛ࣮ߦͤ͞Δ Πϕϯτͷࢦఆ
ϚϧνΫϥυϓϩόΠμʔαϙʔτ ($1 ։ൃதɻۙϦϦʔε༧ఆ QSPWJEFS OBNFBXT QSPWJEFS OBNFPQFOXIJTL QSPWJEFS OBNFB[VSF
044ͱͯ͠(JU)VC্Ͱ։ൃ
ϓϥάΠϯʹΑΔػೳ֦ு QMVHJOT TFSWFSMFTTTUFQGVODUJPOT TFSWFSMFTTP⒐JOF IUUQTHJUIVCDPNTFSWFSMFTTQMVHJOT
Πϯετʔϧ͔Βॳظઃఆ·Ͱ
Πϯετʔϧ OQNJOTUBMMHTFSWFSMFTT
$SFEFOUJBMͷઃఆ TMTDPOpHDSFEFOUJBMTQSPWJEFS BXTLFZZPVSLFZTFDSFUZPVSTFDSFU
$SFEFOUJBMͷઃఆ "84ͷ߹ɺ"ENJOJTUSBUPS"DDFTTͷϙϦγʔΛ BUUBDI͢Δ͜ͱ͕ެࣜυΩϡϝϯτʹهࡌ͞Ε͍ͯΔ IUUQTTFSWFSMFTTDPNGSBNFXPSLEPDTQSPWJEFSTBXTHVJEFDSFEFOUJBMT
$SFEFOUJBMͷઃఆ &⒎FDU"MMPX "DUJPO< JBN(FU3PMF JBN$SFBUF3PMF JBN%FMFUF3PMF
JBN1VU3PMF1PMJDZ JBN%FMFUF3PMF1PMJDZ JBN1BTT3PMF MPHT T MBNCEB DMPVEGPSNBUJPO BQJHBUFXBZ > 3FTPVSDF< > ΦϑΟγϟϧʹެ։͞Εͯͳ͍͕ɺ ࠷ݶ͜ͷ͋ͨΓͷϦιʔεʹ ڐՄ͕͋Εಈ࡞͢Δ
$SFEFOUJBMͷઃఆ IUUQTHJUIVCDPNTFSWFSMFTTTFSWFSMFTTJTTVFT "ENJO$SFEFOUJBMΛΘͳ͍ηοτΞοϓํ๏ݱࡏٞத
։ൃϑϩʔ
αʔϏεͷ ࡞ TFSWFSMFTTZNM ͷΞʔΩςΫνϟ ఆٛ σϓϩΠ Ϋϥυ্ Ͱͷςετ ։ൃͷϫʔΫϑϩʔ ϩʔΧϧͰͷ
GVODUJPO։ൃ
αʔϏεͷ࡞ TMTDSFBUFUFNQMBUFBXTOPEFKT ֤ϓϩόΠμʔͷϥϯλΠϜڥʹ߹Θͤͨ ελʔλʔςϯϓϨʔτΛࣗಈͰ࡞ͯ͘͠ΕΔ
ରԠ͍ͯ͠ΔϥϯλΠϜڥ "84 BXTOPEFKT BXTQZUIPO BXTKBWBHSBEMF BXTKBWBNBWFO BXTTDBMBTCU BXTDTIBSQ
"[VSF OPEFKT 0QFO8IJTL PQFOXIJTLOPEFKT
TFSWFSMFTTZNMͷΞʔΩςΫνϟఆٛ αʔϏεͷϓϩόΠμʔϥϯλΠϜڥͷఆٛ ϑΝϯΫγϣϯͱͦΕΛൃՐ͢ΔͨΊͷΠϕϯτΛఆٛ ༻͢ΔΫϥυϦιʔεͷఆٛ TF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ϧͰ γϡϛϨʔτ IUUQTHJUIVCDPN YUTFSWFSMFTT EZOBNPECMPDBM 4FSWFSMFTT 0⒐JOF "1*(BUFXBZΛϩʔΧϧͰ γϡϛϨʔτ IUUQTHJUIVCDPN EIFSBVMUTFSWFSMFTT P⒐JOF ,JOFTBMJUF ,JOFTJTΛϩʔΧͰγϡϛ Ϩʔτ IUUQTHJUIVCDPN NIBSULJOFTBMJUF
ΫϥυڥͷσϓϩΠ TMTEFQMPZTUBHFεςʔδ໊WFSCPTF TFSWFSMFTTZNMͰఆٛͨ͠ΞʔΩςΫνϟ ٴͼϑΝϯΫγϣϯͷιʔεΛσϓϩΠ͢Δ
εςʔδͷΈ EFWεςʔδ ϩʔΧϧ QSPEVDUJPO εςʔδ ςετڥͱຊ൪ڥͱ͍͍͚͕࣮ͬͨݱͰ͖Δ ֤εςʔδޓ͍ʹӨڹΛٴ΅͠߹Θͳ͍ ඞཁͳ͚ͩεςʔδ࡞Մೳ
σϓϩΠͷॲཧͷྲྀΕ TMTEFQMPZίϚϯυͷൃߦ 4FSWFSMFTT͕ TFSWFSMFTTZNMΛύʔε σϓϩΠύοέʔδ ΛTFSWFSMFTTԼʹग़ྗ ֤ϓϩόΠμʔͷํࣜʹैͬͯ σϓϩΠ "84ͳΒ$MPVE'PSNBUJPO
σϓϩΠࣦഊ࣌ͷσόοά TMTEFQMPZOP%FQMPZ TFSWFSMFTTԼʹσϓϩΠύοέʔδͷΈग़ྗ ͜ΕΛݩʹௐࠪՄೳ
σϓϩΠޙͷ࣮ߦ TMTJOWPLFGVODUJPOϑΝϯΫγϣϯ໊MPHT ΫϥυʹσϓϩΠࡁΈͷϑΝϯΫγϣϯͷ࣮ߦ
ϩάͷ֬ೝ TMTMPHTGVODUJPOϑΝϯΫγϣϯ໊ ϑΝϯΫγϣϯͷ࣮ߦϩάͷ֬ೝ
σϓϩΠޙमਖ਼ TMTEFQMPZGVODUJPOGVODUJPOϑΝϯΫγϣϯ໊ ϑΝϯΫγϣϯ୯ମͷσϓϩΠ͕Մೳ
σϓϩΠޙͷϩʔϧόοΫ TMTEFQMPZMJTU TMTSPMMCBDLUJNFTUBNQUJNFTUBNQ TMTEFQMPZΛલճ࣮ࢪͨ͠ঢ়ଶ·ͰϩʔϧόοΫ ͯ͘͠ΕΔ
$*$%ύΠϓϥΠϯࣗಈԽ
ͳͥɺ$*$% σϓϩΠͷଐਓԽɺϛεΛແ͘͢ 13ۦಈͷ։ൃʹ͓͚Δ࣭ͷ୲อ ςετͷࣗಈԽʹΑΔޮԽ
$*$%ύΠϓϥΠϯߏ
ܧଓతΠϯςάϨʔγϣϯ $*
$*ύΠϓϥΠϯߏ -JOUʹΑΔιʔείʔυͷ੩తղੳ Ϣχοτςετ ΠϯςάϨʔγϣϯςετ
-JOUʹΑΔιʔείʔυͷ੩తղੳ ίʔυ࣮ߦલʹγϯλοΫεΤϥʔΛݕͰ͖Δ ίʔυͷελΠϧ͕౷Ұ͞ΕΔͨΊɺ ෳਓͰͷϝϯςφϯεੑ্͕͢Δ
Ϣχοτςετ ϓϩάϥϜΛߏ͢Δݸʑͷػೳ͕ਖ਼͘͠ಈ͘͜ͱΛݕূ͢Δςετ ςετίʔυΛಡΉͱͦͷιϑτΣΞ͕Ͳ͏ಈ͖͔͘ ͦͷ༷͕Θ͔Δ ͩΕ͕ϓϧϦΫΤετΛૹͬͯಉ͡ج४Ͱࣗಈςετ͕ߦ͑Δ ɹ࣭͕୲อ͞ΕΔ
-BNCEBͰߦ͏Ϣχοτςετ ᵓᴷIBOEMFSKT ᵋᴷMJC ᵓᴷIFMMPDMBTTKT ᵋᴷIFMMPDMBTTUFTUKT -BNCEBͰ࣮ߦ͞ΕΔ ϝΠϯͷϑΝΠϧ ϏδωεϩδοΫ Ϣχοτςετͷίʔυ
const Hello = require(‘./lib/hello.class.js'); const hello = new Hello(); module.exports.hello
= (event, context, callback) => { const response = { statusCode: 200, body: JSON.stringify({ message: hello.say(), input: event, }), }; callback(null, response); }; -BNCEBͰߦ͏Ϣχοτςετ ςετ͕Γ͍͢Α͏ʹ-BNCEBΛ ࣮ߦ͢ΔϝΠϯͷϑΝΠϧ͔ΒΫϥε ͰΓग़ͯ͋͛͠Δ IBOEMFSKT
-BNCEBͰߦ͏Ϣχοτςετ class Hello { say() { return 'Your function executed
successfully!'; } } module.exports = Hello; IFMMPDMBTTKT
-BNCEBͰߦ͏Ϣχοτςετ const expect = require('chai').expect; const Hello = require('./hello.class.js'); describe('Hello',
() => { let hello; beforeEach(() => { hello = new Hello(); }); describe('say', () => { it('should return the value', () => expect(hello.say()) .to.be.equal('Your function executed successfully!')); }); }); ΫϥεͰΓग़ͨ͠ϏδωεϩδοΫ ʹରͯ͠ςετίʔυΛఆٛ IFMMPDMBTTUFTUKT
Ϣχοτςετʹ͓͚ΔBXTTELͷѻ͍ beforeEach(() => { awsStub = sinon.stub(aws.provider, 'request') .returns(BbPromise.resolve({})); });
ςετͰΫϥυڥʹΞΫηε͠ͳ͍ ελϒԽɻBXTTELϢχοτςετͷൣғͰͳ͍ IUUQTHJTUHJUIVCDPNIPSJLFBCECGFDGDBCFG
ΠϯςάϨʔγϣϯςετ TFSWFSMFTTZNMͰఆٛͨ͠ߏٴͼϑΝϯΫγϣϯΛ ࣮ࡍͷΫϥυڥσϓϩΠͯࣗ͠ಈͰ݁߹ςετΛߦ͏
"1*(BUFXBZΠϕϯτͷςετͷϑϩʔ "1*(BUFXBZΠϕ ϯτͷσϓϩΠ BXTTELͷ EFTDSJCF4UBDLTʹΑΓ "1*ΤϯυϙΠϯτΛऔಘ "1*ͷฦΓ ΛνΣοΫ "1*ʹ IUUQϦΫΤετ
IUUQTHJUIVCDPNIPSJLFTFSWFSMFTTBQJJOUFHSBUJPOUFTUTBNQMFCMPCNBTUFS JOUFHSBUJPOUFTUUFTUKT--
4Πϕϯτͷςετͷϑϩʔ 4Πϕϯτͷ σϓϩΠ σϓϩΠࡁΈͷόέοτ ͷΦϒδΣΫτૢ࡞ $MPVE8BUDI-PHT ͰΠϕϯτ͕ൃՐ͔ͨ͠ νΣοΫ IUUQTHJUIVCDPNIPSJLFTFSWFSMFTTBQJJOUFHSBUJPOUFTUTBNQMFCMPCNBTUFS JOUFHSBUJPOUFTUUFTUKT--
ܧଓతσϦόϦʔ $%
$%ύΠϓϥΠϯߏ EFWFMPQNFOUϒϥϯνQVTI࣌ͷςετͷ࣮ߦ ޭ࣌ʹςετεςʔδʹσϓϩΠ NBTUFSϒϥϯνΛ࠷৽ιʔεͷूॴͱͯ͠ɺ QVTI࣌ʹςετͷΈ࣮ߦ UBHΛͬͯQVTI͢ΔͱϦϦʔε ςετ࣮ߦͯ͠ޭ͢Εຊ൪εςʔδʹσϓϩΠ
$%ύΠϓϥΠϯߏ (JU %FQMPZNFOU CSBODINBTUFS CSBODIEFWFMPQNFOU UBHYYY EFWFMPQNFOUTUBHF QSPETUBHF
$%ύΠϓϥΠϯߏ CSBODINBTUFS CSBODIEFWFMPQNFOU UBHYYY -JOU -JOU -JOU Ϣχοτ ςετ Ϣχοτ
ςετ Ϣχοτ ςετ ΠϯςάϨʔ γϣϯςετ ΠϯςάϨʔ γϣϯςετ
language: node_js node_js: - '4.3' env: global: - AWS_REGION=us-east-1 -
SLS_DEBUG=true - secure: lSxO7tZ0….BEVm - secure: LIh0lkl….7fM= before_install: - chmod +x ./bin/deploy.sh - npm i -g serverless install: - travis_retry npm install script: - npm run lint - npm run test - if [[ $TRAVIS_BRANCH == "master" ]] || [[ $TRAVIS_TAG ]]; then npm run integration-test; fi after_success: - ./bin/deploy.sh USBWJTZNMͷઃఆ "84ͷDSFEFOUJBMΛ҉߸Խͯ͠ઃఆ 5SBWJT͔Β"84ڥଓΛՄೳͱ͍ͯ͠Δ NBTUFSϒϥϯνͱUBHͷQVTI࣌ͷΈ ΠϯςάϨʔγϣϯςετ͕Δ ޭ͢ΕσϓϩΠεΫϦϓτ͕Δ
EFQMPZTI QVTIઌʹԠͯ͡TUBHFΛઃఆ σϓϩΠޠෆཁͳOQNύοέʔδͷআ σϓϩΠ #!/bin/bash set -e if [[ $TRAVIS_TAG
]]; then STAGE="production" elif [[ $TRAVIS_BRANCH == 'dev' ]]; then STAGE="development" fi echo "Deploying from branch $BRANCH to stage $STAGE" npm prune --production #remove devDependencies sls deploy --stage $STAGE --region $AWS_REGION
͓ΘΓ