{"id":1710,"date":"2021-08-20T17:08:12","date_gmt":"2021-08-20T08:08:12","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=1710"},"modified":"2022-04-03T16:04:06","modified_gmt":"2022-04-03T07:04:06","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%e5%ae%9f%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=1710","title":{"rendered":"AWS CLI \u3092\u4f7f\u7528\u3057\u305f Lambda\u95a2\u6570\u306e\u5b9f\u884c"},"content":{"rendered":"\n<p>\u4eca\u307e\u3067 \u30ed\u30fc\u30ab\u30eb\u304b\u3089Lambda\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u3001Api Gateway \u3092\u8a2d\u5b9a\u3057Http\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u3066Lambda\u95a2\u6570\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Api Gateway\u306e\u8a2d\u5b9a\u306f\u305d\u3046\u96e3\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u304c\u3001Api Gateway \u3092\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u4f5c\u6210\u3057\u305fLambda\u95a2\u6570\u3092\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u5b9f\u884c\u3067\u304d\u306a\u3044\u306e\u3082\u3069\u3046\u306a\u306e\u304b\u3068\u601d\u3063\u3066\u3044\u307e\u3057\u305f\u3002<br>\u3057\u304b\u3057\u3001Api Gateway\u3092\u4f7f\u7528\u3057\u306a\u304f\u3066\u3082 AWS CLI \u3092\u4f7f\u7528\u3057\u3066Lambda\u95a2\u6570\u304c\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u524d\u63d0<\/h1>\n\n\n\n<p>\u4e88\u3081AWS\u3078Lambda\u95a2\u6570\u3092\u4f5c\u6210\u3057\u3066\u304a\u3044\u3066\u4e0b\u3055\u3044\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\">Lambda\u95a2\u6570<\/h1>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306aLambda\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<br>\u95a2\u6570\u540d\u3092 test_func \u3068\u3057\u3066\u3044\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\">\u30b3\u30de\u30f3\u30c9<\/h1>\n\n\n\n<p>\u4ee5\u4e0b\u306f AWS CLI \u3092\u4f7f\u7528\u3057\u305fLambda\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u30b3\u30de\u30f3\u30c9\u306e\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>aws lambda invoke --function-name test_func --payload $(echo &#39;{ &quot;name&quot;: &quot;\u3042\u3042\u3042&quot; }&#39; | base64) outputfile.txt<\/code><\/pre><\/div>\n\n\n\n<p>outputfile.txt \u3078\u5b9f\u884c\u7d50\u679c\u304c\u8a18\u8f09\u3055\u308c\u307e\u3059\u3002<br>\u30da\u30a4\u30ed\u30fc\u30c9\u306bBase64\u3092\u4f7f\u7528\u3057\u306a\u3044\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>string argument should contain only ASCII characters<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u5b9f\u884c\u7d50\u679c<\/h1>\n\n\n\n<p>\u6210\u529f\u3059\u308b\u3068\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9200\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;StatusCode&quot;: 200,\n    &quot;ExecutedVersion&quot;: &quot;$LATEST&quot;\n}<\/code><\/pre><\/div>\n\n\n\n<p>\u307e\u305f\u3001\u8fd4\u5374\u3055\u308c\u305f\u5185\u5bb9(body)\u306foutputfile.txt\u3078\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<br>\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{&quot;statusCode&quot;:200,&quot;body&quot;:{&quot;name&quot;:&quot;\u3042\u3042\u3042&quot;}}<\/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\u304b\u3089Lambda\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u3001Api Gateway \u3092\u8a2d\u5b9a\u3057Http\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u3066Lambda\u95a2\u6570\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":1258,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,20],"tags":[],"class_list":["post-1710","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\/1710","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=1710"}],"version-history":[{"count":2,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/1710\/revisions"}],"predecessor-version":[{"id":3422,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/1710\/revisions\/3422"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/1258"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}