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
700
auth0-meetup.pdf
horike37
1
250
What’s happening with Serverless Framework, and it lives with AWS SAM.
horike37
0
81
What is Serverless. Why is Serverless.
horike37
1
59
aws-with-functional-saas
horike37
2
160
serverless-with-oss
horike37
0
110
slsconftokyo
horike37
0
5.3k
slsconfworkshop
horike37
3
2.5k
Test Driven Development For Lambda
horike37
2
300
Other Decks in Technology
See All in Technology
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
150
マイクロサービスにおける容易なトランザクション管理に向けて
scalar
0
110
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
220
kargoの魅力について伝える
magisystem0408
0
200
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
330
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
170
DevOps視点でAWS re:invent2024の新サービス・アプデを振り返ってみた
oshanqq
0
180
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
520
.NET 9 のパフォーマンス改善
nenonaninu
0
770
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
530
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
150
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
A better future with KSS
kneath
238
17k
Designing Experiences People Love
moore
138
23k
The Cult of Friendly URLs
andyhume
78
6.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Designing for Performance
lara
604
68k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
4 Signs Your Business is Dying
shpigford
181
21k
What's in a price? How to price your products and services
michaelherold
243
12k
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ͷΞʔΩςΫνϟఆٛ αʔϏεͷϓϩόΠμʔϥϯλΠϜڥͷఆٛ ϑΝϯΫγϣϯͱͦΕΛൃՐ͢ΔͨΊͷΠϕϯτΛఆٛ ༻͢ΔΫϥυϦιʔεͷఆٛ TFSWFSMFTTZNM͕αʔϏεશମͷઃܭਤͱͳΔ
TFSWFSMFTTZNMͷΠϕϯτఆٛ GVODUJPOT VTFS$SFBUF IBOEMFSMJCVTFS$SFBUFIBOEMFS FWFOUT IUUQ QBUIVTFST NFUIPEQPTU IUUQΠϕϯτͷఆٛ
TFSWFSMFT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ΛϩʔΧͰγϡϛ Ϩʔτ 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
͓ΘΓ