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
80
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
290
Other Decks in Technology
See All in Technology
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
380
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
3
200
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
AGIについてChatGPTに聞いてみた
blueb
0
130
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
580
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
The Role of Developer Relations in AI Product Success.
giftojabu1
0
120
隣接領域をBeyondするFinatextのエンジニア組織設計 / beyond-engineering-areas
stajima
1
270
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
170
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
180
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
The Language of Interfaces
destraynor
154
24k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
For a Future-Friendly Web
brad_frost
175
9.4k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
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ͷΞʔΩςΫνϟఆٛ αʔϏεͷϓϩόΠμʔϥϯλΠϜڥͷఆٛ ϑΝϯΫγϣϯͱͦΕΛൃՐ͢ΔͨΊͷΠϕϯτΛఆٛ ༻͢ΔΫϥυϦιʔεͷఆٛ TFSWFSMFTT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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
͓ΘΓ