ä»æ¥ãç§ã¯ITã®äžçã§ç©æ¥µçã«å¢ããåŸãŠããæè¡ãã€ãŸãã¯ã©ãŠãæè¡ã®1ã€ãããªãã¡ãµãŒããŒã¬ã¹ã¢ããªã±ãŒã·ã§ã³ã¢ãŒããã¯ãã£ïŒãµãŒããŒã¬ã¹ïŒã«ã€ããŠã話ããããšæããŸãã æè¿ãã¯ã©ãŠããã¯ãããžãŒã®äººæ°ãé«ãŸã£ãŠããŸãã ããã¯ãåçŽãªçç±-容æãªå¯çšæ§ãæ¯èŒçå®äŸ¡ãã·ãŒãè³æ¬ã®äžè¶³-ã€ã³ãã©ã¹ãã©ã¯ãã£ãç¶æããã³å±éããããã®ç¥èãšããéã®äž¡æ¹ã®ããã«çºçããŸãã
ãµãŒããŒã¬ã¹ãã¯ãããžãŒã¯ãŸããŸãæ®åããŠããŸãããäœããã®çç±ã§ãIaaSãDBaaSãPaaSãªã©ã®ä»ã®ã¯ã©ãŠããã¯ãããžãŒãšã¯ç°ãªããITæ¥çã§ã¯ã»ãšãã©ã«ããŒãããŠããŸããã
ãã®èšäºãæžãããã«ãAWSïŒAmazon Web ServicesïŒãééããªãæ倧ã§æãèãæããããµãŒãã¹ãšããŠäœ¿çšããŸããïŒ2015幎ã®Gartnerã®åæã«åºã¥ãïŒã
ä»æ¥å¿
èŠãªãã®ïŒ
- AWSã¢ã«ãŠã³ãïŒãã¹ãããã³æå°éã®éçºã«ã¯ãç¡æå©çšæ ã§ååã§ãïŒ;
- éçºçšãã©ãããã©ãŒã ïŒLinux-Fedoraã奜ãã§ããã4.3以äžã®ããŒããšNPMããµããŒããããã£ã¹ããªãã¥ãŒã·ã§ã³ã䜿çšã§ããŸãïŒã
- ãµãŒããŒã¬ã¹ãã¬ãŒã ã¯ãŒã¯1. *ããŒã¿-ãã®ãã¬ãŒã ã¯ãŒã¯ã«ã€ããŠã¯ãå¥ã®ç« ïŒhttps://github.com/serverless/serverlessïŒã§è©³ãã説æããŸãã
ããã§ã¯ãåºæ¬ããå§ããŸãããã
ãµãŒããŒã¬ã¹-人æ°ã®åºç€ã¯äœã§ãã
ãµãŒããŒã¬ã¹ã¯ããµãŒããŒã¬ã¹ã®ã¢ããªã±ãŒã·ã§ã³ã¢ãŒããã¯ãã£ã§ãã å®éã圌女ã¯ããã»ã©ãµãŒããŒã¬ã¹ã§ã¯ãããŸããã ã¢ãŒããã¯ãã£ã®åºç€ã¯ãç¹å®ã®ã¿ã¹ã¯ãå®è¡ããpr玢奜ããªç®ããé ãããè«çã³ã³ããã§å®è¡ããããã€ã¯ããµãŒãã¹ãŸãã¯æ©èœïŒã©ã ãïŒã§ãã ã€ãŸã ãšã³ããŠãŒã¶ãŒã«ã¯ãé¢æ°ïŒãµãŒãã¹ïŒã³ãŒããèªã¿èŸŒãããã®ã€ã³ã¿ãŒãã§ã€ã¹ãšãã€ãã³ããœãŒã¹ããã®é¢æ°ã«æ¥ç¶ããæ©èœã®ã¿ãæäŸãããŸãã
AmazonãµãŒãã¹ã®äŸãèãããšãã€ãã³ãã®ãœãŒã¹ã¯åãAmazonãµãŒãã¹ã®å€ãã§ããå¯èœæ§ããããŸãã
- S3ã¹ãã¬ãŒãžã¯ããã±ããå
ã®ãã¡ã€ã«ã®è¿œå ãåé€ãç·šéãªã©ãã»ãŒãã¹ãŠã®æäœã§å€ãã®ã€ãã³ããçæã§ããŸãã
- RDSããã³DynamoDB-ããã«ãDynamoã§ã¯ãããŒãã«ã®ããŒã¿ãè¿œå ãŸãã¯å€æŽãããšãã«ã€ãã³ããçæã§ããŸãã
- Cloudwatchã¯ãcronã«äŒŒãã·ã¹ãã ã§ãã
- ãããŠãç§ãã¡ã«ãšã£ãŠæãèå³æ·±ãã®ã¯API Gatewayã§ãã ããã¯ãåäžã®ãã€ã¯ããµãŒãã¹ã€ãã³ããžã®ãªã¯ãšã¹ããæœè±¡åã§ããHTTPãããã³ã«ã®ãœãããŠã§ã¢ãšãã¥ã¬ãŒã¿ã§ãã
æŠç¥çã«ããã€ã¯ããµãŒãã¹ã®äœæ¥ã¯æ¬¡ã®ããã«è¡šãããšãã§ããŸãã
å®éãé¢æ°ã³ãŒããAmazonã«ã¢ããããŒããããšããã«ãå éšãã¡ã€ã«ãµãŒããŒïŒS3ãªã©ïŒã«ããã±ãŒãžãšããŠä¿åãããŸãã æåã®ã€ãã³ããåä¿¡ããããšãAmazonã¯ç¹å®ã®ã€ã³ã¿ãŒããªã¿ãŒïŒãŸãã¯JAVAã®å Žåã¯ä»®æ³ãã·ã³ïŒã§ããã³ã³ãããŒãèªåçã«èµ·åããçæãããã€ãã³ãæ¬äœãåŒæ°ãšããŠçœ®ãæããŠãçµæã®ã³ãŒããå®è¡ããŸãã ãã€ã¯ããµãŒãã¹ã®åçããæãããªããã«ãã³ã³ãããžã®ã¢ã¯ã»ã¹ããªãããã®ååšã¯äœã«ãã£ãŠã決å®ãããªãããããã®ãããªåé¢æ°ã¯ç¶æ ïŒã¹ããŒãã¬ã¹ïŒãæã€ããšãã§ããŸããã ãã®å質ã«ããããã€ã¯ããµãŒãã¹ã¯ãªã¯ãšã¹ãã®æ°ãšè² è·ã«å¿ããŠæ¯éãªãæ°Žå¹³ã«æé·ã§ããŸãã å®éãå®è·µã«åºã¥ããŠãAmazonã®ãªãœãŒã¹ã®ãã©ã³ã¹ã¯éåžžã«è¯å¥œã§ãããè² è·ã®çæ£æ§ã®å¢å ããã£ãŠããæ©èœã¯ããã«ãã¹ããŒã³ãããŸãã
äžæ¹ããã®ãããªã¹ããŒãã¬ã¹ãªèµ·åã®ãã1ã€ã®å©ç¹ã¯ãç¹å®ã®æ©èœã®å®è¡ã«ãããæéã«åºã¥ããŠããµãŒãã¹ã®äœ¿çšã«å¯Ÿããæ¯æããéåžžè¡ãããããšã§ãã ãã®ãããªäŸ¿å©ãªæ¯æãæ¹æ³-åŸéå¶ã®è±èªã§ã®æ¯æã-ã¯ãåæè³æ¬ãªãã§ã¹ã¿ãŒãã¢ãããä»ã®ãããžã§ã¯ããç«ã¡äžããããšãå¯èœã«ããŸãã çµå±ã®ãšãããã³ãŒãããã¹ãããããã«ãã¹ãã£ã³ã°ãè³Œå ¥ããå¿ èŠã¯ãããŸããã ãµãŒãã¹ã®äœ¿çšéã«å¿ããŠæ¯æããè¡ãããšãã§ããŸãïŒããã«ããããµãŒãã¹ã®å¿ èŠãªåçåãæè»ã«èšç®ããããšãã§ããŸãïŒã
ãããã£ãŠããã®ãããªã¢ãŒããã¯ãã£ã®å©ç¹ã¯æ¬¡ã®ãšããã§ãã
- ããŒããŠã§ã¢ã®äžè¶³-ãµãŒããŒã
- ãµãŒããŒåŽã®çŽæ¥é£çµ¡ãšç®¡çã®æ¬ åŠ;
- ãããžã§ã¯ãã®ã»ãŒç¡å¶éã®æ°Žå¹³æ¹åã®æé·ã
- 䜿çšããCPUæéã®æ¯æãã
æ¬ ç¹ã¯æ¬¡ã®ãšããã§ãã
- ã³ã³ããã®æ£ç¢ºãªå¶åŸ¡ã®æ¬ åŠïŒã©ãã§ã©ã®ããã«èµ·åããã誰ãã¢ã¯ã»ã¹ã§ãããã¯æ±ºããŠããããŸããïŒ-ãã°ãã°åŠæ³ãåŒãèµ·ããå¯èœæ§ããããŸãã
- ã¢ããªã±ãŒã·ã§ã³ã®ãæŽåæ§ãã®æ¬ åŠïŒåæ©èœã¯ç¬ç«ãããªããžã§ã¯ãã§ãããå€ãã®å Žåãã¢ããªã±ãŒã·ã§ã³ã®ç¹å®ã®åæ£ãšãã¹ãŠããŸãšããããšãå°é£ã«ãªããŸãã
- ã³ã³ããã®ã³ãŒââã«ãã¹ã¿ãŒãã«ã¯ãïŒå°ãªããšãAmazonã§ïŒæãŸããããšãå€ããããŸãã ã©ã ãé¢æ°ã䜿çšããã³ã³ããã®æåã®èµ·åã¯ã2ã3ç§éé ããªãããšããããããŸãããããã¯åžžã«ãŠãŒã¶ãŒã«ååã«èªèããããšã¯éããŸããã
äžè¬çã«ããã¯ãããžãŒã«ã¯ç¬èªã®éèŠã»ã°ã¡ã³ããšç¬èªã®æ¶è²»è åžå ŽããããŸãã ãããããã®ãã¯ãããžãŒã¯ãåçŽãªããã°ãããªã³ã©ã€ã³ã²ãŒã ãªã©ãã¹ã¿ãŒãã¢ããã®åæ段éã«éåžžã«é©ããŠãããšæããŸãã ãã®å ŽåããµãŒããŒã€ã³ãã©ã¹ãã©ã¯ãã£ããã®ç¬ç«æ§ãšèªåã¢ãŒãã§ã®çç£æ§ã®ç¡å¶éã®åäžã«ç¹ã«éç¹ã眮ãããŸãã
ãµãŒããŒã¬ã¹ãã¬ãŒã ã¯ãŒã¯
åè¿°ã®ããã«ãBSAã®æ¬ ç¹ã®1ã€ã¯ãã¢ããªã±ãŒã·ã§ã³ã®æçåãšãã€ãã³ããã³ãŒããããŒã«ãã»ãã¥ãªãã£ããªã·ãŒãªã©ãå¿ èŠãªãã¹ãŠã®ã³ã³ããŒãã³ãã®éåžžã«éãå¶åŸ¡ã§ãã Hello Worldãããããè€éãªãããžã§ã¯ãã§ã¯ãããããã¹ãŠã®ã³ã³ããŒãã³ãã®èŠå¶ã¯å€§ããªé çã®çš®ã§ãã ãŸãã次ã®æŽæ°äžã«ãµãŒãã¹ã倱æããããšããããããŸãã
ãã®åé¡ãåé¿ããããã«ãåè¯ãªäººã ã¯åãååã®éåžžã«äŸ¿å©ãªãŠãŒãã£ãªãã£-ServerlessãæžããŸããã ãã®ãã¬ãŒã ã¯ãŒã¯ã¯ãAWSã€ã³ãã©ã¹ãã©ã¯ãã£ã§äœ¿çšããããã«ç¹å¥ã«èšèšãããŠããŸãïŒ0.5ããŒãžã§ã³ã®ãã©ã³ãã¯NodeJSçšã«å®å šã«éçºãããŸãããã1ã*ãã©ã³ãããã¹ãŠã®ãµããŒããããAWSèšèªã«ãªãã€ã¬ã¯ãããããšã¯å€§ããªãã©ã¹ã§ããïŒã å°æ¥çã«ã¯ããã©ã³ã1ã«ã€ããŠèª¬æããŸãã*ç§ã®æèŠã§ã¯ããã®æ§é ã¯ããè«ççã§æè»ã«äœ¿çšã§ããããã§ãã ããã«ãããŒãžã§ã³1ã§ã¯ãã»ãšãã©ã®ãŽããã¯ãªãŒã³ã¢ãããããJavaãšPythonã®ãµããŒããè¿œå ãããŸããã
ãã®ãœãªã¥ãŒã·ã§ã³ã®æçšæ§ã¯äœã§ããïŒ çãã¯éåžžã«ç°¡åã§ã-ãµãŒããŒã¬ã¹ãã¬ãŒã ã¯ãŒã¯ã¯ããããžã§ã¯ãã®ãã¹ãŠã®å¿ èŠãªã€ã³ãã©ã¹ãã©ã¯ãã£ãã€ãŸããã³ãŒãå¶åŸ¡ããã¹ãããªãœãŒã¹ãããŒã«ãããã³ã»ãã¥ãªãã£ããªã·ãŒã®äœæãšç£èŠãéäžãããŸãã ãã®ããããã¹ãŠã1ãæã«ãããããŒãžã§ã³ç®¡çã®ããã«gitã«ç°¡åã«è¿œå ã§ããŸãã
ãã¬ãŒã ã¯ãŒã¯ãã€ã³ã¹ããŒã«ããŠèšå®ããããã®åºæ¬çãªæé ãèªãã åŸãããããæ¢ã«ã€ã³ã¹ããŒã«ã§ããŠããŸãããåå¿è ã«åœ¹ç«ã€èšäºãç¶æããããã«ãå¿ èŠãªæé ããªã¹ãããŸãããã ãããŸã§èªãã ãšããã§ããã§ã«Centosãåããã³ã³ãœãŒã«ãæå ã«ããããšãé¡ã£ãŠããŸãã®ã§ãNPM / Nodeã®ã€ã³ã¹ããŒã«ã«ã€ããŠç¥ãåãã«ãªããŸãããïŒãµãŒããŒã¬ã¹ããã±ãŒãžã¯NodeJSã§æžãããŠããŸããïŒã
ã¹ããŒãž1
ããŒãã®ããŒãžã§ã³ç®¡çã«ã¯NVMã奜ãã§ãïŒ
curl https://raw.githubusercontent.com/creationix/nvm/v0.31.6/install.sh | bash
ã¹ããŒãž2
ã€ã³ã¹ããŒã«ã®æåŸã«ç€ºãããããã«ããããã¡ã€ã«ããªããŒãããŸãã
. ~/.bashrc
ã¹ããŒãž3
次ã«ãNode / NPMã¢ã»ã³ããªãã€ã³ã¹ããŒã«ããŸãïŒäŸã§ã¯ãæå
ã«ããããã4.4.5ã䜿çšããŠããŸãïŒã
nvm install v4.4.5
ã¹ããŒãž4
ã€ã³ã¹ããŒã«ãæ£åžžã«å®äºããããAWSãžã®ã¢ã¯ã»ã¹ãèšå®ããŸãããã®èšäºã®äžéšãšããŠãéçºãšãã®åœ¹å²ã®ããã«ç¹å®ã®AWSã¢ã«ãŠã³ããèšå®ãã段éãã¹ãããããŸãã詳现ãªæé ã¯ãã¬ãŒã ã¯ãŒã¯ã®ããã¥ã¢ã«ã«èšèŒãããŠããŸãã
第äºæ®µé
éåžžãAWSããŒã䜿çšããã«ã¯ã2ã€ã®ç°å¢å€æ°ãè¿œå ããã ãã§ãã
export AWS_ACCESS_KEY_ID=<key> export AWS_SECRET_ACCESS_KEY=<secret>
ã¹ããŒãž6
ã¢ã«ãŠã³ããã€ã³ã¹ããŒã«ãããæ§æãããŠãããšä»®å®ããŸãïŒSLSãã¬ãŒã ã¯ãŒã¯ã®å Žåã管çè ã¯AWSãªãœãŒã¹ãžã®ã¢ã¯ã»ã¹ã¬ãã«ãå¿ èŠã§ã-ãããªããã°ããã¹ãŠãããŸããããªãçç±ã解æããããã«äœæéãè²»ããããšãã§ããŸãïŒã
第7ã¹ããŒãž
Serverlessãã°ããŒãã«ã¢ãŒãã§ã€ã³ã¹ããŒã«ããŸãã
npm install -g serverless@beta
ããŒã¿çãæå®ããã«ããããã0.5ãã©ã³ããã€ã³ã¹ããŒã«ããããšã«æ³šæããŠãã ããã ãããŸã§ã0.5ãš1.0ã¯å€©ãšå°ã®ããã«ç°ãªã£ãŠãããããããŒãžã§ã³0.5ã®1.0ã®æ瀺ã¯ãŸã£ããæ©èœããŸããã
ã¹ããŒãžãšã€ã
ãããžã§ã¯ããã£ã¬ã¯ããªãäœæããŸãã ãããŠããã®æ®µéã§-ãããžã§ã¯ãã®ã¢ãŒããã¯ãã£ã«é¢ããå°ããªäœè«ã
ãµãŒããŒã¬ã¹ãããžã§ã¯ãã¢ãŒããã¯ãã£
ã©ã ãé¢æ°ãAmazonã«ããŒãããæ¹æ³ã«ç§»ããŸãããã ã€ãŸãããããã«ã¯2ã€ã®æ¹æ³ããããŸãã
- Webã³ã³ãœãŒã«ãã-ç°¡åãªã³ããŒã¢ã³ãããŒã¹ãã ãã®æ¹æ³ã¯ãæãåçŽãªã³ãŒããæã€åé³ç¯é¢æ°ã«ãšã£ãŠéåžžã«ã·ã³ãã«ã§äŸ¿å©ã§ãã æ®å¿µãªããããã®æ¹æ³ã§ã¯ããµãŒãããŒãã£ã®ã©ã€ãã©ãªãé¢æ°ã«å«ããããšã¯ã§ããŸããïŒ Amazonããã¥ã¡ã³ãã®ã©ã ãé¢æ°ã§ãµããŒããããŠããã©ã€ãã©ãªã®ãªã¹ãã«ã€ããŠèªãããšãã§ããŸãããååãšããŠãããã¯ããã«äœ¿çšã§ããèšèªããã¯ã§ãããAWS SKD-ãã以äžã§ããã以äžã§ããããŸããïŒã
- AWS SKDã䜿çšããŠãé¢æ°ããã±ãŒãžã«å ¥åã§ããŸãã ããã¯ãå¿ èŠãªãã¹ãŠã®ãã¡ã€ã«ãšã©ã€ãã©ãªãå«ãéåžžã®zipã¢ãŒã«ã€ãã§ãïŒãã®å Žåãæ倧ã¢ãŒã«ã€ããµã€ãºã«ã¯50MBã®å¶éããããŸãïŒã lambdaã¯ãã€ã¯ããµãŒãã¹ã§ããããœãããŠã§ã¢ããã±ãŒãžå šäœã1ã€ã®é¢æ°ã«ã¢ããããŒãããŠãæå³ããªãããšãå¿ããªãã§ãã ããã é¢æ°ã®æ¯æãã¯ã³ãŒãã®å®è¡æã«è¡ããããããæé©åãå¿ããªãã§ãã ããã
ãã®å ŽåãServerlessã¯2çªç®ã®æ¹æ³ã䜿çšããŸããã€ãŸããæ¢åã®ãããžã§ã¯ããæºåããããããå¿
èŠãªzipããã±ãŒãžãäœæããŸãã 以äžã«NodeJSã®ãµã³ãã«ãããžã§ã¯ãã瀺ããŸããããããªããšãåãããžãã¯ãä»ã®èšèªã«é©çšããã®ãé£ãããªããŸããã
|__ lib // |__ handler.js // |__ serverless.env.yaml // |__ serverless.yml // |__ node_modules // |__ package.json
ç§ã¯æ¬åœã«èšäºãèªã¿éããããããŸããããæ®å¿µãªããããã¬ãŒã ã¯ãŒã¯ã®æ§æã«é¢ããããã¥ã¡ã³ãã¯éåžžã«äžå®å šã§æçåãããŠããããããã¥ãŒãã³ã°ã®å®è·µããäŸãæããããšæããŸãã ãµãŒãã¹ã®èšå®å šäœã¯ã次ã®æ§é ãæã€serverless.ymlãã¡ã€ã«ã«ãããŸãã
service:
provider:
name: aws
runtime: nodejs4.3
iamRoleStatement:
$ref: ../custom_iam_role.json #JSON , IAM . http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_policy-examples.html. JSON Statements
vpc: # VPC ( , VPC )
securityGroupIds:
- securityGroupId1
subnetIds:
- subnetId1
stage: dev # ( , , - )
region: us-west-2 #
package: #
includee: # â , , , â (handler). , , .
- lib
- node_module # , , â .
exclude: # , , , .
- tmp
- .git
functions: # . â . , . , , , lambda .
hello:
name: hello #
handler: handler.hello #
MemorySize: 512 #
timeout: 10 #
events: # ,
- s3: bucketName
- schedule: rate(10 minutes)
- http:
path: users/create
method: get
cors: true
- sns: topic-name
vpc: # VPC
securityGroupIds:
- securityGroupId1
- securityGroupId2
subnetIds:
- subnetId1
- subnetId2
resources:
Resources:
$ref: ../custom_resources.json # JSON , .
ã»ãšãã©ã®å Žåããã®æ§æãã¡ã€ã«ã¯Amazon CloudFormationã®æ§æã«éåžžã«ãã䌌ãŠããŸããããã«ã€ããŠã¯ããããã次ã®èšäºã§èª¬æããŸãã ããããç°¡åã«èšãã°-ããã¯ãAmazonã¢ã«ãŠã³ãã®ãã¹ãŠã®ãªãœãŒã¹ãå¶åŸ¡ããããã®ãµãŒãã¹ã§ãã ãµãŒããŒã¬ã¹ã¯ãã®ãµãŒãã¹ã«å®å
šã«äŸåããŠãããéåžžãé¢æ°ã®ã€ã³ã¹ããŒã«äžã«ç解ã§ããªããšã©ãŒãçºçããå ŽåãCloudFormationã³ã³ãœãŒã«ããŒãžã§ãšã©ãŒã«é¢ãã詳现æ
å ±ãèŠã€ããããšãã§ããŸãã
ãµãŒããŒã¬ã¹ãããžã§ã¯ãã«é¢ããéèŠãªè©³çŽ°ã«æ³šç®ããŸãããããžã§ã¯ãããªãŒããããã£ã¬ã¯ããªããªãŒã®äžäœã«ãããã£ã¬ã¯ããªããã¡ã€ã«ãå«ããããšã¯ã§ããŸããã ããæ£ç¢ºã«ã¯-../libã¯å®è¡ã§ããŸããã
ããã§èšå®ãå®äºããŸãããé¢æ°èªäœã«é²ã¿ãŸãããã
ã¹ããŒãžãã€ã³
ããã©ã«ãæ§æã§ãããžã§ã¯ããäœæãã
sls create âtemplate aws-nodejs
ãã®ã³ãã³ãã®åŸã«ããããžã§ã¯ãæ§é ã衚瀺ãããŸã-äžèšã§èª¬æãããã®ãšåæ§ã§ãã
ã¹ããŒãž10
é¢æ°èªäœã¯handler.jsãã¡ã€ã«ã«ãããŸãã é¢æ°ã®èšè¿°ã®ååã¯ã Amazonã®ããã¥ã¡ã³ãã«èšèŒãããŠããŸãã ããããäžè¬çã«èšãã°ãã¢ã¯ã»ã¹ãã€ã³ãã¯3ã€ã®åŒæ°ãæã€é¢æ°ã§ãã
- event-ã€ãã³ããªããžã§ã¯ãã ãã®ãªããžã§ã¯ãã«ã¯ãæ©èœãåŒãèµ·ãããã€ãã³ãã«é¢ãããã¹ãŠã®ããŒã¿ãå«ãŸããŠããŸãã AWS API Gatewayã®å Žåããã®ãªããžã§ã¯ãã«ã¯HTTPãªã¯ãšã¹ããå«ãŸããŸãïŒå®éãServerlessã¯Gateway APIã§HTTPãªã¯ãšã¹ãã®ããã©ã«ãããããŒãèšå®ããããããŠãŒã¶ãŒãèªåã§èšå®ããå¿
èŠã¯ãããŸããããããã¯ã»ãšãã©ã®ãããžã§ã¯ãã«éåžžã«äŸ¿å©ã§ãïŒã
- ã³ã³ããã¹ã-ç°å¢ã®çŸåšã®ç¶æ
ãå«ããªããžã§ã¯ã-çŸåšã®æ©èœã®ARNãªã©ã®æ
å ±ãããã³å Žåã«ãã£ãŠã¯èªèšŒæ
å ±ã NodeJS 4.3 Amazon Lambdaã®æ°ããããŒãžã§ã³ã§ã¯ãé¢æ°ã®çµæã¯ã³ã³ããã¹ãã§ã¯ãªã callBackãä»ããŠè¿ãããå¿
èŠãããããšãæãåºããŠãã ããïŒäŸïŒ{doneãsuccessãfail}ïŒ
- ã³ãŒã«ããã¯ã¯ãã€ãã³ãã®çµæãè¿ãã³ãŒã«ããã¯ïŒãšã©ãŒãããŒã¿ïŒåœ¢åŒã®é¢æ°ã§ãã
ããšãã°ãæãåçŽãªHello Worldé¢æ°ãäœæããŠã¿ãŸãããã
exports.hello = function(event, context, callback) { callback({'Hello':'World', 'event': event}); }
ã¹ããŒãž11
ããŠã³ããŒãïŒ
sls deploy
éåžžããã®ããŒã ã¯ãããžã§ã¯ããããã±ãŒãžåããAWSèªäœã§æ©èœãšç°å¢ãæºåããã®ã«æéãããããŸãã ãã ããæåŸã«ãServerlessã¯ARNãšãšã³ããã€ã³ããè¿ããŸããããã«ãããçµæã確èªã§ããŸãã
çµè«ãšããŠ
ãã®èšäºã¯ãµãŒããŒã¬ã¹ãã¯ãããžãŒã®åºæ¬çãªäœ¿çšæ³ã®ã¿ãæ±ã£ãŠãããšããäºå®ã«ãããããããå®éã«ã¯ãã®ãã¯ãããžãŒã®é©çšç¯å²ã¯ã»ãšãã©ç¡å¶éã§ãã ããã¯ãšã³ããšã©ã ãé¢æ°ã®ããžãã¯ãåããåçŽãªããŒã¿ã«ïŒReactãŸãã¯Angularã䜿çšããéçããŒãžãšããŠäœæïŒãããS3ã¹ãã¬ãŒãžãä»ããã¢ãŒã«ã€ããŸãã¯ãã¡ã€ã«ã®åŠçãšãè² è·åæ£ã䌎ãããªãè€éãªæ°åŠçæäœãŸã§ã ç§ã®æèŠã§ã¯ããã®æè¡ã¯ãŸã å§ãŸã£ãã°ããã§ããã確å®ã«ããã«çºå±ããã§ãããã ãã®ãããããŒããŒããæã«åããè©ŠããŠã¿ãŠãã ããïŒAmazon Free Tierã®å©ç¹ã«ãããæåã¯ãããå®å šã«ç¡æã§è¡ãããšãã§ããŸãïŒã
ãæž èŽããããšãããããŸãã-ã³ã¡ã³ãã§ææ³ãã³ã¡ã³ããå ±æããŠãã ããïŒ ãããŠããã®èšäºãã楜ãã¿ãã ããããã®å Žåããã¯ãããžãŒã®æ·±åã®ãµã€ã¯ã«ãç¶ããŠãããŸãã