{"id":368,"date":"2017-05-19T13:11:58","date_gmt":"2017-05-19T04:11:58","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2017\/05\/19\/ServerlessFrameworkWithNode"},"modified":"2017-05-19T13:11:58","modified_gmt":"2017-05-19T04:11:58","slug":"ServerlessFrameworkWithNode","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2017\/05\/19\/ServerlessFrameworkWithNode\/","title":{"rendered":"Serverless Framework+Node.js\u3067\u666e\u901a\u306b\u8a2d\u8a08\u3059\u308b"},"content":{"rendered":"
<\/head><\/p>\n\u6700\u8fd1\u306fAWS Lambda\u306e\u95a2\u6570\u3092Node.js\u3067\u66f8\u3044\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u306e\u8a2d\u8a08\u3092\u7d39\u4ecb\u3057\u3088\u3046\u3068\u601d\u3046\u3002<\/p>\n
\u307e\u305aServerless Framework\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3066\u3086\u304f\u3002\u57fa\u672c\u7684\u306b\u306f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u3084[\u30ea\u30f3\u30af](## \u53c2\u8003)\u3092\u307f\u308c\u3070\u8ff7\u3046\u3053\u3068\u306f\u306a\u3044\u3068\u601d\u3046\u306e\u3067\u7701\u7565\u3059\u308b\u304c\u3001\u5c11\u3057\u6c17\u3092\u3064\u3051\u305f\u70b9\u3092\u66f8\u3044\u3066\u307f\u308b\u3002<\/p>\n Serverless Framework\u3067\u306f\u3001CLI\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3054\u3068\u306b\u56fa\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b<\/a>\u304c\u3001\u8907\u6570\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067Serverless Framework\u3092\u3064\u304b\u3063\u3066\u3044\u308b\u3068\u3001\u5404\u81ea\u306e\u74b0\u5883\u3067CLI\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3092\u3059\u308b\u306e\u304c\u82e5\u5e72\u9762\u5012\u306b\u306a\u308b\u3002<\/p>\n \u305d\u3053\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u306e Credentials\u30b3\u30de\u30f3\u30c9<\/a>\u3092\u4f7f\u3063\u3066\u3044\u308b\u3060\u3051\u3060\u304c\u3001\u30c7\u30d7\u30ed\u30a4\u306b\u5fc5\u8981\u306a\u30e6\u30fc\u30b6\u30fccredentials\u3092\u30b3\u30de\u30f3\u30c9\u3092\u6d41\u3059\u3060\u3051\u3067\u8a2d\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u3002\u3053\u308c\u306b\u3088\u308a\u8907\u6570\u4eba\u958b\u767a\u306e\u3068\u304d\u3067\u3082\u7c21\u5358\u306b\u74b0\u5883\u69cb\u7bc9\u304c\u3067\u304d\u308b\u3002<\/p>\n Serverless Framework\u306eCLI\u3092\u3001yarn\u30b3\u30de\u30f3\u30c9\u3067\u6d41\u305b\u308b\u3088\u3046\u306b\u3057\u305f\u3002Serverless Framework\u306b\u9650\u3063\u305f\u8a71\u3067\u306f\u306a\u3044\u304c\u3001\u3053\u308c\u3067\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u7d71\u4e00\u3067\u304d\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u4e88\u6e2c\u304c\u5bb9\u6613\u3068\u306a\u308b\u3002<\/p>\n Lambda\u3067\u306fstage\u3068\u3044\u3046\u3082\u306e\u304c\u6307\u5b9a\u3067\u304d\u3066\u3001\u4f8b\u3048\u3070\u3001\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u74b0\u5883\u3084\u30d7\u30ed\u30c0\u30af\u30b7\u30e7\u30f3\u74b0\u5883\u306a\u3069\u3092\u4f5c\u6210\u3057\u3066\u3001\u5404\u3005\u306e\u74b0\u5883\u3067\u95a2\u6570\u3092\u30c6\u30b9\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002stage\u306e\u5207\u308a\u5206\u3051\u306fServerless Framework\u3067\u3067\u304d\u308b\u306e\u3067\u3001\u4f8b\u3048\u3070\u30c7\u30d7\u30ed\u30a4\u306e\u30b3\u30de\u30f3\u30c9\u306a\u3069\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u305f\u3002<\/p>\n \u5b9f\u969b\u306b\u6d41\u3059\u6642\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9f\u884c\u3059\u308b\u3002<\/p>\n \u5f8c\u8ff0\u3059\u308b\u304c\u3001\u95a2\u6570\u306e\u30c6\u30b9\u30c8\u306f\u57fa\u672c\u7684\u306bAVA\u3092\u4f7f\u3063\u3066\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3001Serverless Framework\u3067\u30c6\u30b9\u30c8\u3059\u308b\u306e\u306f\u3001\u95a2\u6570\u3092\u7d50\u5408\u3057\u305f\u3068\u304d\u306e\u6319\u52d5\u304c\u30e1\u30a4\u30f3\u3068\u306a\u308b\u3002<\/p>\n \u30af\u30e9\u30a6\u30c9\u74b0\u5883\u3067\u306fInvoke\u30b3\u30de\u30f3\u30c9<\/a>\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u306fInvoke Local\u30b3\u30de\u30f3\u30c9<\/a>\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u52d5\u4f5c\u78ba\u8a8d\u304c\u53ef\u80fd\u3068\u306a\u308b\u3002\u3053\u308c\u3092\u306a\u306b\u304b\u3057\u3089\u306e\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3057\u3066\u81ea\u52d5\u5316\u3059\u308c\u3070\u3001\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30c6\u30b9\u30c8\u3092CI\u4e0a\u3067\u3082\u6d41\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n \u3053\u3053\u307e\u3067\u306fServerless Framework\u306e\u8a2d\u5b9a\u3060\u3063\u305f\u304c\u3001\u3053\u3053\u304b\u3089\u3001 \u307e\u305a\u306f\u3001webpack+Babel\u3067ECMAScript\u3092\u30d3\u30eb\u30c9\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u3002\u3053\u308c\u306fserverless-webpack<\/a>\u3092\u4f7f\u7528\u3059\u308b\u304c\u3001\u57fa\u672c\u7684\u306b\u5927\u5dee\u306f\u306a\u3044\u3002\u8a73\u7d30\u306f\u3001[\u30ea\u30f3\u30af](## \u53c2\u8003)\u3092\u53c2\u8003\u306b\u3057\u3066\u6b32\u3057\u3044\u3002<\/p>\n AVA\u3067\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u3002\u3068\u306f\u3044\u3063\u3066\u3082\u3001\u3044\u3064\u3082\u901a\u308a\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u3092\u66f8\u3044\u3066\u3086\u304f\u3060\u3051\u3067\u3042\u308b\u3002<\/p>\n \u3072\u3068\u3064\u6c17\u3092\u3064\u3051\u305f\u70b9\u306f\u3001\u8cac\u52d9\u3092\u306a\u308b\u3079\u304f\u5206\u96e2\u3057\u3066\u3001\u30af\u30e9\u30a6\u30c9\u5074\u306b\u4f9d\u5b58\u3057\u306a\u3044\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u304f\u3089\u3044\u3060\u308d\u3046\u304b(webpack+Babel\u3092\u5c0e\u5165\u3057\u305f\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u5c0f\u3055\u306aJS\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u308f\u3051\u3066\u95a2\u6570\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u308b)\u3002\u305d\u308c\u306b\u95a2\u3057\u3066\u306f\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306b\u3082\u4f8b\u304c\u51fa\u3066\u3044\u308b\u306e\u3067\u3001\u53c2\u8003\u306b\u3059\u308b\u3068\u3044\u3044\u3068\u601d\u3046\u3002<\/p>\n Flow\u306b\u3088\u3063\u3066\u9759\u7684\u578b\u4ed8\u3051\u3092\u5c0e\u5165\u3057\u305f\u3002<\/p>\n eslint\u306b\u3088\u308a\u3001Lint\u3092\u884c\u3046\u3088\u3046\u306b\u3057\u305f\u3002Lint\u306f\u3042\u3068\u304b\u3089\u5c0e\u5165\u3059\u308b\u3068\u3001\u30eb\u30fc\u30eb\u3092\u76f4\u3057\u3066\u3044\u304f\u4f5c\u696d\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u3082\u3057\u5c0f\u3055\u3044\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u3042\u3063\u3066\u3082\u6700\u521d\u304b\u3089\u5c0e\u5165\u3057\u305f\u307b\u3046\u304c\u3044\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3002<\/p>\n State\u7ba1\u7406\u306b\u95a2\u3057\u3066\u306f\u3001\u306a\u3093\u3089\u304b\u306eObserver Pattern(Redux\u306a\u3069)\u3067\u66f8\u3051\u3070\u3044\u3044\u3068\u601d\u3046\u304c\u3001State\u3092\u6301\u3064\u3068\u3044\u3046\u3053\u3068\u304c\u73fe\u6642\u70b9\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u5fc5\u8981\u306b\u306a\u3063\u305f\u3089\u306a\u306b\u304b\u3092\u5c0e\u5165\u3057\u3088\u3046\u3068\u8003\u3048\u3066\u3044\u308b\u3002Lambda\u95a2\u6570\u306e\u6027\u8cea\u4e0a\u3042\u307e\u308a\u5fc5\u8981\u306b\u306a\u308b\u5834\u9762\u304c\u601d\u3044\u6d6e\u304b\u3070\u306a\u3044\u304c\u3001State\u7ba1\u7406\u3068\u3044\u3046\u3088\u308a\u3082\u3001RxJS\u306a\u3069\u3067\u30a4\u30d9\u30f3\u30c8\u30b9\u30c8\u30ea\u30fc\u30e0\u3092\u6271\u3046\u3053\u3068\u304c\u3067\u3066\u304f\u308b\u304b\u3082\u306a\u3068\u601d\u3063\u3066\u3044\u308b\u3002<\/p>\n \u4ee5\u4e0a\u3001Serverless Framework+Node.js\u3092\u4f7f\u7528\u3057\u305fLambda\u306e\u8a2d\u8a08\u3092\u66f8\u3044\u3066\u307f\u305f\u3002\u7279\u306b\u666e\u6bb5\u3068\u5909\u308f\u3089\u305a\u306b\u8a2d\u8a08\u3067\u304d\u305f\u306e\u3067\u3001\u3042\u3068\u306f <\/body><\/html><\/p>\n","protected":false},"excerpt":{"rendered":" \u6700\u8fd1\u306fAWS Lambda\u306e\u95a2\u6570\u3092Node.js\u3067\u66f8\u3044\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u306e\u8a2d\u8a08\u3092\u7d39\u4ecb\u3057\u3088\u3046\u3068\u601d\u3046\u3002 \u76ee\u6b21 Serverless Framework\u3067\u6c17\u3092\u3064\u3051\u305f\u3053\u3068\u3044\u304f\u3064\u304b \u30ed\u30fc\u30ab\u30ebCLI\u3092\u4f7f\u7528\u3059\u308b Credentials\u3092\u5bb9\u6613\u306b\u8ffd\u52a0 yarn\u30b3\u30de\u30f3\u30c9\u3067\u7d71\u4e00\u3059\u308b stage\u3092\u5207\u308a\u5206\u3051\u308b \u30c6\u30b9\u30c8 JavaScript\u5074\u306e\u8a2d\u8a08 webpack+Babel AVA Flow Lint State\u7ba1\u7406 \u307e\u3068\u3081 […]<\/p>\n","protected":false},"author":1,"featured_media":826,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,21,7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/368"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=368"}],"version-history":[{"count":0,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/368\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media\/826"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\u30ed\u30fc\u30ab\u30ebCLI\u3092\u4f7f\u7528\u3059\u308b<\/h3>\n
node_modules<\/code>\u304b\u3089CLI\u3092\u8d70\u3089\u305b\u308b\u3053\u3068\u306b\u3057\u305f\u3002\u3053\u308c\u3067\u3001
yarn install<\/code>\u3055\u3048\u3059\u308c\u3070\u5404\u4eba\u306e\u74b0\u5883\u3067CLI\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u3002\u4f8b\u3048\u3070\u3001\u30c7\u30d7\u30ed\u30a4\u306e\u30b3\u30de\u30f3\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3002<\/p>\n
$(npm bin)\/serverless deploy<\/code><\/pre>\n
Credentials\u3092\u5bb9\u6613\u306b\u8ffd\u52a0<\/h3>\n
$(npm bin)\/serverless config credentials --provider aws --key KEY --secret SECRET --profile PROFILE<\/code><\/pre>\n
yarn\u30b3\u30de\u30f3\u30c9\u3067\u7d71\u4e00\u3059\u308b<\/h3>\n
{\n \"scripts\": {\n \"deploy\": \"$(npm bin)\/serverless deploy\",\n \"deploy:list\": \"$(npm bin)\/serverless deploy list\",\n \"invoke\": \"$(npm bin)\/serverless webpack invoke --function\",\n \"serve\": \"$(npm bin)\/serverless webpack serve\"\n }\n}<\/code><\/pre>\n
stage\u3092\u5207\u308a\u5206\u3051\u308b<\/h3>\n
{\n \"scripts\": {\n \"deploy\": \"$(npm bin)\/serverless deploy --stage\",\n }\n}<\/code><\/pre>\n
$ yarn deploy staging\n$ yarn deploy production<\/code><\/pre>\n
\u30c6\u30b9\u30c8<\/h3>\n
JavaScript\u5074\u306e\u8a2d\u8a08<\/h2>\n
\u666e\u6bb5\u306e\u958b\u767a\u3092\u6d3b\u304b\u3057\u3064\u3064\u3001Serverless Framework\u4e0a\u3067\u3069\u3046Node.js\u3092\u66f8\u3044\u3066\u3086\u304f\u304b<\/code>\u3068\u3044\u3046\u3068\u3053\u308d\u3092\u66f8\u3053\u3046\u3068\u601d\u3046\u3002\u57fa\u672c\u7684\u306b\u306f\u4ed6\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u4f7f\u7528\u3057\u305f\u8a2d\u8a08\u3092\u305d\u306e\u307e\u307e\u6d41\u7528\u3067\u304d\u308b\u3068\u8003\u3048\u3066\u3044\u308b\u3002<\/p>\n
webpack+Babel<\/h3>\n
AVA<\/h3>\n
Flow<\/h3>\n
Lint<\/h3>\n
State\u7ba1\u7406<\/h3>\n
\u307e\u3068\u3081<\/h2>\n
\u30af\u30ea\u30fc\u30f3\u30b3\u30fc\u30c9<\/code>\u3092\u66f8\u3044\u3066\u3086\u304f\u3060\u3051\u3067\u3059\u306d\u3002\u256d( \uff65\u3142\uff65)\u0648<\/p>\n
\u53c2\u8003<\/h2>\n
\n