{"id":8344,"date":"2022-07-06T05:43:07","date_gmt":"2022-07-05T20:43:07","guid":{"rendered":"https:\/\/yumishin.com\/?p=8344"},"modified":"2022-07-06T05:43:07","modified_gmt":"2022-07-05T20:43:07","slug":"aws-lambda","status":"publish","type":"post","link":"https:\/\/yumishin.com\/?p=8344","title":{"rendered":"AWS lambda\u3067nmp\u95a2\u9023\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3084\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u7528\u3059\u308b\u3068\u304d\u306e\u3084\u308a\u65b9"},"content":{"rendered":"<h2 id=\"i-0\">AWS lambda\u3067nmp\u95a2\u9023\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3084\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u7528\u3059\u308b\u3068\u304d\u306e\u3084\u308a\u65b9<\/h2>\n<h3 id=\"i-1\">\u524d\u63d0\u6761\u4ef6<\/h3>\n<p>node.js\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067lambda\u95a2\u6570\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3002<\/p>\n<p>\u30ed\u30fc\u30ab\u30eb\u306e\u74b0\u5883\u306bnpm\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3002<\/p>\n<h3 id=\"i-2\">\u624b\u9806\u6982\u8981<\/h3>\n<ol>\n<li>\u4f7f\u7528\u3059\u308b\u4e88\u5b9a\u306enpm\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30ed\u30fc\u30ab\u30ebPC\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n<ul>\n<li>\u30d5\u30a9\u30eb\u30c0\u540d\u306a\u3069\u304c\u7d50\u69cb\u91cd\u8981\u3067\u3001\u9069\u5f53\u306b\u3064\u3051\u308b\u3068\u5f8c\u3067\u4f7f\u3046\u306e\u304c\u5927\u5909\u306b\u306a\u308a\u307e\u3059\uff01<\/li>\n<\/ul>\n<\/li>\n<li>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305fnpm\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30d5\u30a9\u30eb\u30c0\u5168\u4f53\u3067zip\u5316<\/li>\n<li>zimp\u5316\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u3092\u3001lambda\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3001lambda layer\u3092\u8ffd\u52a0\u3059\u308b\n<ul>\n<li>lambda layer\u3068\u3044\u3046\u3068\u3001\u96e3\u3057\u305d\u3046\u306b\u805e\u3053\u3048\u307e\u3059\u304c\u3001\u7c21\u5358\u3067\u3059\uff01<\/li>\n<li>\u4e8b\u524d\u306b\u4f7f\u3044\u305f\u3044\u30e9\u30a4\u30d6\u30e9\u30ea\u306a\u3069\u3092\u3001\u767b\u9332\u3057\u3066\u3042\u3052\u3066\u3001lambda\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u3042\u3052\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li>lambda\u95a2\u6570\u304b\u3089\u3001npm\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u547c\u3073\u51fa\u3059<\/li>\n<\/ol>\n<h4 id=\"i-3\">\u4f7f\u7528\u3059\u308b\u4e88\u5b9a\u306enpm\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30ed\u30fc\u30ab\u30ebPC\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h4>\n<p>\u307e\u305a\u306f\u4f7f\u7528\u4e88\u5b9a\u306enpm\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30ed\u30fc\u30ab\u30ebPC\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u521d\u306b<code>nodejs<\/code>\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u3069\u3053\u3067\u3082\u826f\u3044\u306e\u3067\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div class=\"memo \">\n<div class=\"memo_ttl dfont\"> MEMO<\/div>\n<p>\u3053\u306e\u540d\u524d\u304c\u7d50\u69cb\u91cd\u8981\u3067\u3001lambda\u3092\u4f7f\u7528\u3059\u308b\u3068\u304d\u306b\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067AWS lambda\u304c\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u63a2\u3057\u306b\u884c\u304f\u5834\u6240\u3068\u3044\u3046\u306e\u304c\u6c7a\u307e\u3063\u3066\u307e\u3057\u3066\u3001\u305d\u306e\u540d\u524d\u306b\u306a\u308a\u307e\u3059\u3002<\/p><\/div>\n<p>\u7d9a\u3044\u3066\u3001<code>nodejs<\/code>\u306e\u4e2d\u306b\u5165\u3063\u3066\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<div class=\"pre_tag\"><span><i class=\"fa fa-code\"><\/i> \u30bf\u30fc\u30df\u30ca\u30eb #nodejs\u306e\u30d5\u30a9\u30eb\u30c0\u306e\u4e2d\u3067\u5b9f\u884c<\/span><\/p>\n<pre><code>$ npm install pg<\/code><\/pre>\n<\/div>\n<p>\u3059\u308b\u3068\u3001node_modules\u306a\u3069\u304c\u4f5c\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h4 id=\"i-4\">\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305fnpm\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30d5\u30a9\u30eb\u30c0\u5168\u4f53\u3067zip\u5316<\/h4>\n<p>\u4eca\u5ea6\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u3089\u30e9\u30a4\u30d6\u30e9\u30ea\u3092zip\u5316\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30de\u30f3\u30c9\u3067<code>nodejs<\/code>\u306e\u30d5\u30a9\u30eb\u30c0\u3054\u3068zip\u5316\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div class=\"pre_tag\"><span><i class=\"fa fa-code\"><\/i> \u30bf\u30fc\u30df\u30ca\u30eb #nodejs\u304c\u3042\u308b\u30d5\u30a9\u30eb\u30c0<\/span><\/p>\n<pre><code>$ zip -r nodejs.zip .<\/code><\/pre>\n<\/div>\n<h4 id=\"i-5\">zimp\u5316\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u3092\u3001lambda\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3001lambda layer\u3092\u8ffd\u52a0\u3059\u308b<\/h4>\n<p>\u4ee5\u4e0b\u306e\u30b5\u30a4\u30c8\u304c\u3059\u3054\u304f\u308f\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<p>\u5148\u7a0b\u306ezip\u30d5\u30a1\u30a4\u30eb\u3092lambda layer\u306b\u8ffd\u52a0\u3059\u308b\u90e8\u5206\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" title=\"AWS Lambda Layers\u3067node_modules\u3092\u4f7f\u3046 - \u30af\u30ed\u30b9\u30d1\u30ef\u30fc\u30af\u30e9\u30a6\u30c9\u30d6\u30ed\u30b0\" src=\"https:\/\/hatenablog-parts.com\/embed?url=https%3A%2F%2Fxp-cloud.jp%2Fblog%2F2019%2F01%2F12%2F4630%2F#?secret=coSHwlX3eG\" data-secret=\"coSHwlX3eG\" scrolling=\"no\" frameborder=\"0\"><\/iframe><\/p>\n<h4 id=\"i-6\">lambda\u95a2\u6570\u304b\u3089\u3001npm\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u547c\u3073\u51fa\u3059<\/h4>\n<p>\u3042\u3068\u306f\u3001lambda\u95a2\u6570\u304b\u3089\u3001npm\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u547c\u3073\u51fa\u305b\u308b\u304b\u3069\u3046\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<div class=\"pre_tag\"><span><i class=\"fa fa-code\"><\/i> \u30b3\u30fc\u30c9<\/span><\/p>\n<pre><code>const { Client } = require('pg');\nconst client = new Client();\nconsole.log(client);\n<\/code><\/pre>\n<\/div>\n<p>\u3061\u3083\u3093\u3068require\u304c\u4f7f\u3048\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0a\u3067\u3059\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AWS lambda\u3067nmp\u95a2\u9023\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3084\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u7528\u3059\u308b\u3068\u304d\u306e\u3084\u308a\u65b9 \u524d\u63d0\u6761\u4ef6 node.js\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067lambda\u95a2\u6570\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3002 \u30ed\u30fc\u30ab\u30eb\u306e\u74b0\u5883\u306bnpm\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3002 \u624b\u9806\u6982\u8981 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":8345,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[256],"tags":[],"class_list":{"0":"post-8344","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-it","8":"entry"},"_links":{"self":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts\/8344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8344"}],"version-history":[{"count":1,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts\/8344\/revisions"}],"predecessor-version":[{"id":8346,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts\/8344\/revisions\/8346"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/media\/8345"}],"wp:attachment":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}