{"id":1700,"date":"2021-08-20T16:14:24","date_gmt":"2021-08-20T07:14:24","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=1700"},"modified":"2022-04-04T22:25:08","modified_gmt":"2022-04-04T13:25:08","slug":"aws-cli-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f-lambda%e9%96%a2%e6%95%b0%e3%81%ae%e3%83%87%e3%83%97%e3%83%ad%e3%82%a4","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=1700","title":{"rendered":"AWS CLI \u3092\u4f7f\u7528\u3057\u305f Lambda\u95a2\u6570\u306e\u30c7\u30d7\u30ed\u30a4"},"content":{"rendered":"\n<p>\u4eca\u307e\u3067\u30ed\u30fc\u30ab\u30eb\u3067\u4f5c\u6210\u3057\u305fLambda\u95a2\u6570\u3092AWS \u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u3066\u30c7\u30d7\u30ed\u30a4(zip\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9)\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Lambda\u95a2\u6570\u304c\u591a\u3044\u5834\u5408\u3001\u30d6\u30e9\u30a6\u30b6(AWS \u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb)\u3092\u4f7f\u7528\u3057\u3066\u306e\u30c7\u30d7\u30ed\u30a4\u306f\u7d50\u69cb\u306a\u624b\u9593\u306b\u306a\u308a\u307e\u3059\u3002<br>\u305d\u3053\u3067\u3001AWS CLI \u3092\u4f7f\u7528\u3057\u3066\u30b3\u30de\u30f3\u30c9\u30d9\u30fc\u30b9\u3067\u30c7\u30d7\u30ed\u30a4\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u524d\u63d0<\/h1>\n\n\n\n<p>\u4e88\u3081AWS\u306b\u4f5c\u6210\u3055\u308c\u3066\u3044\u308bLambda\u95a2\u6570\u3092\u3001\u30ed\u30fc\u30ab\u30eb\u3067\u4f5c\u6210\u3057\u305fLambda\u95a2\u6570\u3067\u66f4\u65b0(\u30c7\u30d7\u30ed\u30a4)\u3057\u307e\u3059\u3002<br>\u3057\u305f\u304c\u3063\u3066\u3001AWS\u3078Lambda\u95a2\u6570\u3092\u4f5c\u6210\u3057\u3066\u304a\u3044\u3066\u4e0b\u3055\u3044\u3002<br>\u672c\u7a3f\u3067\u306fLambda\u95a2\u6570\u540d\u3092 &#8220;test_deploy&#8221; \u3068\u3044\u3046\u540d\u524d\u3067\u4f5c\u6210\u3057\u3066\u308b\u3053\u3068\u3068\u3057\u307e\u3059\u3002<br>Lambda\u95a2\u6570\u306e\u4f5c\u6210\u306b\u3064\u3044\u3066\u306f\u8aac\u660e\u3057\u307e\u305b\u3093\u3002<br>\u306a\u304a\u3001AWS CLI \u3092\u4f7f\u3046\u70ba\u3001AWS CLI\u3092\u4f7f\u7528\u3067\u304d\u308b\u72b6\u614b\u306b\u3057\u3066\u304a\u3044\u3066\u4e0b\u3055\u3044\u3002<br>AWS CLI \u306e\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u306f\u8aac\u660e\u3057\u307e\u305b\u3093\u3002<br>\u958b\u767a\u8a00\u8a9e\u306fnode.js\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u6982\u8981<\/h1>\n\n\n\n<p>AWS \u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u3067\u3082\u540c\u3058\u3067\u3059\u304c\u3001\u30ed\u30fc\u30ab\u30eb\u3067\u4f5c\u6210\u3057\u305f\u30c7\u30d7\u30ed\u30a4\u5bfe\u8c61\u306eLambda\u95a2\u6570\u3092zip\u30d5\u30a1\u30a4\u30eb\u306b\u3057\u307e\u3059\u3002<br>\u305d\u306e\u5f8c\u3001AWS CLI \u306e\u30b3\u30de\u30f3\u30c9\u4f7f\u7528\u3057\u3066\u30c7\u30d7\u30ed\u30a4(AWS \u3078zip\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9)\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30ed\u30fc\u30ab\u30eb\u306eLambda\u95a2\u6570\u4f5c\u6210<\/h1>\n\n\n\n<p>\u30ed\u30fc\u30ab\u30eb\u3067Lambda\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br>\u30d5\u30a1\u30a4\u30eb\u540d\u306findex.js\u3068\u3057\u307e\u3059\u3002<br>Lambda\u95a2\u6570\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067index.js\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306fLambda\u95a2\u6570\u306e\u4f8b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>const aws = require(&quot;aws-sdk&quot;);\n\nexports.handler = async (event, context) =&gt; {\n    context.succeed({\n        statusCode: 200,\n        body      : event,\n    });\n};<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u30c7\u30d7\u30ed\u30a4\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210<\/h1>\n\n\n\n<p>\u4f5c\u6210\u3057\u305fLambda\u95a2\u6570(index.js)\u3092zip\u30d5\u30a1\u30a4\u30eb\u306b\u3057\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306fzip\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u30b3\u30de\u30f3\u30c9\u306e\u4f8b\u306b\u306a\u308a\u307e\u3059\u3002<br>\u30b3\u30de\u30f3\u30c9\u306findex.js\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u884c\u3063\u3066\u4e0b\u3055\u3044\u3002<br>\u4e00\u3064\u4e0a\u306e\u968e\u5c64\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b test_deploy.zip \u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>zip -r ..\/test_deploy.zip .\/* -x \\*\/.DS_Store\/\\*<\/code><\/pre><\/div>\n\n\n\n<p>zip\u30d5\u30a1\u30a4\u30eb\u306e\u8aac\u660e\u306f\u4ee5\u4e0b\u3092\u53c2\u8003\u306b\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n\n\n\n<div class=\"title_box\"><span class=\"box-title\">zip \u30d5\u30a1\u30a4\u30eb\u4f5c\u6210<\/span>\n<p><a href=\"https:\/\/dennie.tokyo\/it\/?p=1692\" rel=\"noopener noreferrer\" target=\"_blank\">zip \u30d5\u30a1\u30a4\u30eb\u4f5c\u6210<\/a><\/p>\n<\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u30c7\u30d7\u30ed\u30a4\u5b9f\u884c<\/h1>\n\n\n\n<p>\u5148\u307b\u3069\u4f5c\u6210\u3057\u305fzip\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3078\u79fb\u52d5\u3057\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>aws lambda update-function-code --function-name test_deploy --zip-file fileb:\/\/test_deploy.zip<\/code><\/pre><\/div>\n\n\n\n<p>&#8211;function-name \u3067\u30c7\u30d7\u30ed\u30a4\u5148\u306eLambda\u95a2\u6570\u540d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6210\u529f\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u8fd4\u5374\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;FunctionName&quot;: &quot;test_deploy&quot;,\n    &quot;FunctionArn&quot;: &quot;arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXXX:function:test_deploy&quot;,\n    &quot;Runtime&quot;: &quot;nodejs14.x&quot;,\n    &quot;Role&quot;: &quot;arn:aws:iam::XXXXXXXXXXXXX:role\/exec-lambda&quot;,\n    &quot;Handler&quot;: &quot;index.handler&quot;,\n    &quot;CodeSize&quot;: 317,\n    &quot;Description&quot;: &quot;&quot;,\n    &quot;Timeout&quot;: 3,\n    &quot;MemorySize&quot;: 128,\n    &quot;LastModified&quot;: &quot;2021-08-20T06:49:26.193+0000&quot;,\n    &quot;CodeSha256&quot;: &quot;XXXXXXXXXXXXXXX&quot;,\n    &quot;Version&quot;: &quot;$LATEST&quot;,\n    &quot;TracingConfig&quot;: {\n        &quot;Mode&quot;: &quot;PassThrough&quot;\n    },\n    &quot;RevisionId&quot;: &quot;a66b51f4-1071-4d57-8403-973854008f7a&quot;,\n    &quot;State&quot;: &quot;Active&quot;,\n    &quot;LastUpdateStatus&quot;: &quot;Successful&quot;,\n    &quot;PackageType&quot;: &quot;Zip&quot;\n}<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u6700\u5f8c\u306b<\/h1>\n\n\n\n<p>\u7279\u306b\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u307e\u3067\u30ed\u30fc\u30ab\u30eb\u3067\u4f5c\u6210\u3057\u305fLambda\u95a2\u6570\u3092AWS \u30de\u30cd\u30b8\u30e1\u30f3\u30c8\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u3066\u30c7\u30d7\u30ed\u30a4(zip\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9)\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":6,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,20],"tags":[],"class_list":["post-1700","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws","category-lambda"],"_links":{"self":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/1700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1700"}],"version-history":[{"count":9,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/1700\/revisions"}],"predecessor-version":[{"id":3430,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/1700\/revisions\/3430"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/6"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}