{"id":26132,"date":"2024-03-19T11:19:51","date_gmt":"2024-03-19T02:19:51","guid":{"rendered":"https:\/\/www.skyarch.net\/blog\/?p=26132"},"modified":"2024-03-19T11:19:51","modified_gmt":"2024-03-19T02:19:51","slug":"aws-chalice%e3%81%a7%e4%b8%80%e9%83%a8api-gateway%e3%81%aemock%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b%ef%bc%88merge-template%e6%a9%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/aws-chalice%e3%81%a7%e4%b8%80%e9%83%a8api-gateway%e3%81%aemock%e3%82%92%e5%88%a9%e7%94%a8%e3%81%99%e3%82%8b%ef%bc%88merge-template%e6%a9%9f%e8%83%bd\/","title":{"rendered":"AWS Chalice\u3067\u4e00\u90e8API Gateway\u306eMock\u3092\u5229\u7528\u3059\u308b\uff08merge-template\u6a5f\u80fd)"},"content":{"rendered":"<h2>\u76ee\u6b21<\/h2>\n<ul>\n<li><a href=\"#overview\">\u80cc\u666f<\/a><\/li>\n<li><a href=\"#jissou\">\u5b9f\u88c5\/\u30ec\u30b9\u30dd\u30f3\u30b9\u5207\u308a\u66ff\u3048<\/a><\/li>\n<li><a href=\"#matome\">\u307e\u3068\u3081<\/a><\/li>\n<\/ul>\n<h2 id=\"overview\">\u80cc\u666f<\/h2>\n<p>Chalice\uff08\uff0bCI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\uff09\u3092\u5229\u7528\u3057\u305fAPI\u958b\u767a\u306b\u304a\u3044\u3066\u3001APIGateway\u3084Lambda\u306b\u5bfe\u3059\u308b\u8ffd\u52a0\u8a2d\u5b9a\u3067 chalice \u306e config\u30d5\u30a1\u30a4\u30eb\u304c\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u500b\u4eba\u7684\u306b\u906d\u9047\u3057\u305f\u7269\u3067\u4f8b\u3048\u3070\u3001EFS\u30de\u30a6\u30f3\u30c8 \u3084 APIGateway\u306e\u30ed\u30b0\u51fa\u529b\u8a2d\u5b9a\u3001\u30ab\u30b9\u30bf\u30e0\u30ec\u30b9\u30dd\u30f3\u30b9\u7b49\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u524d\u56de (EFS\u30de\u30a6\u30f3\u30c8) \u306b\u5f15\u304d\u7d9a\u304d\u3001\u4e00\u90e8\u30ec\u30b9\u30dd\u30f3\u30b9\u3092APIGateway\u306eMock\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3057\u305f\u3044\u3068\u3044\u3046\u8981\u671b\u304c\u3042\u308a\u5b9f\u73fe\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\uff08\u76f8\u5f53\u6570\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u60f3\u5b9a\u3055\u308c\u308b\u305f\u3081\u3001Lambda\u3092\u901a\u3055\u305a\u306b\u76f4\u63a5\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u5374\u3057\u305f\u3044\uff09<\/p>\n<p>\u524d\u56de\u8a18\u4e8b\u306f<a href=\"https:\/\/www.skyarch.net\/blog\/aws-chalice%e3%81%a7efs%e3%83%9e%e3%82%a6%e3%83%b3%e3%83%88%e3%82%92%e5%ae%9f%e6%96%bd%e3%81%99%e3%82%8b%ef%bc%88merge-template%e6%a9%9f%e8%83%bd\/\" title=\"AWS Chalice\u3067EFS\u30de\u30a6\u30f3\u30c8\u3092\u5b9f\u65bd\u3059\u308b\uff08merge-template\u6a5f\u80fd)\">\u3053\u3061\u3089<\/a><\/p>\n<p>AWS Chalice \u306e AWS CloudFormation Support<br \/>\n<a href=\"https:\/\/aws.github.io\/chalice\/topics\/cfn.html\" rel=\"noopener\" target=\"_blank\">https:\/\/aws.github.io\/chalice\/topics\/cfn.html<\/a><\/p>\n<h2 id=\"jissou\">\u5b9f\u88c5<\/h2>\n<p>\/status \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306bGET\u30e1\u30bd\u30c3\u30c9\u3067\u30a2\u30af\u30bb\u30b9\u3057\u305f\u969b\u306b\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u30b3\u30fc\u30c9: 200\u3001{\"status\": \"OK\"} \u3092\u8fd4\u5374\u3059\u308b MergeTemplate\u304c\u4e0b\u8a18\u306e\u3088\u3046\u306a\u5f62\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u5f53\u7136\u3067\u3059\u304c\u4e0b\u8a18\u306e\u3088\u3046\u306a\u52d5\u4f5c\u306e\u305f\u3081\u3001Chalice\u306b\u3066\u65e2\u306b \/status \u3078\u306eRoute\u3092\u4f5c\u6210\u3057\u3066\u3044\u308b\u3068\u4eca\u56de\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u4e0a\u66f8\u304d\u3055\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u8981\u6ce8\u610f\u3067\u3059\u3002<br \/>\nChalice \u2192 SAMTemplate \u2190 \u672cTemplate\u3092Merge<\/p>\n<p>\u307e\u305f\u3001\"title\": \"APIGateway-ResourceName\"\u306e\u5ba3\u8a00\u3092\u629c\u304f\u3068CloudFormtation\u30c7\u30d7\u30ed\u30a4\u30a8\u30e9\u30fc\u3068\u306a\u308b\u305f\u3081<br \/>\nChalice\u306eapp_name\u30922\u91cd\u7ba1\u7406\u305b\u3056\u308b\u3092\u5f97\u306a\u3044\u5f62\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\uff08\u6700\u7d42\u7684\u306b \u4e0b\u8a18 DefinitionBody.title \u306e\u540d\u524d\u3067\u4e0a\u66f8\u304d\u3055\u308c\u3066\u3057\u307e\u3046\uff09<\/p>\n<h3>extras.json<\/h3>\n<pre>\n{\n  \"Resources\" : {\n    \"RestAPI\" : {\n      \"Properties\": {\n        \"DefinitionBody\": {\n          \"swagger\": \"2.0\",\n          \"info\": {\n            \"title\": \"APIGateway-ResourceName\"\n          },\n          \"paths\": {\n            \"\/status\": {\n              \"get\": {\n                \"responses\": {\n                  \"200\": {\n                    \"description\": \"OK\"\n                  },\n                  \"503\": {\n                    \"description\": \"Maintenance\"\n                  }\n                },\n                \"x-amazon-apigateway-integration\": {\n                  \"type\": \"mock\",\n                  \"httpMethod\": \"GET\",\n                  \"requestTemplates\": {\n                    \"application\/json\": \"{\\\"statusCode\\\": 200}\"\n                  },\n                  \"responses\": {\n                    \"200\": {\n                      \"statusCode\": \"200\",\n                      \"responseTemplates\": {\n                        \"application\/json\": \"{\\\"status\\\": \\\"OK\\\"}\"\n                      }\n                    },\n                    \"503\": {\n                      \"statusCode\": \"503\",\n                      \"responseTemplates\": {\n                        \"application\/json\": \"{\\\"status\\\": \\\"Maintenance\\\"}\"\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}\n<\/pre>\n<h3>\u4f5c\u6210\u3055\u308c\u305f\u30ea\u30bd\u30fc\u30b9<\/h3>\n<p>\/status \u30ea\u30bd\u30fc\u30b9\u304c\u4f5c\u6210\u3055\u308c\u3001GET\u30e1\u30bd\u30c3\u30c9\u304cMock\u7d71\u5408\u3055\u308c\u3066\u3044\u308b\u72b6\u614b\u3068\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWResource.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWResource-1024x370.png\" alt=\"\" width=\"728\" height=\"263\" class=\"alignnone size-large wp-image-26136\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWResource-1024x370.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWResource-300x108.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWResource-768x278.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWResource-1536x556.png 1536w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWResource-2048x741.png 2048w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWResource-728x263.png 728w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<h3>\u30ec\u30b9\u30dd\u30f3\u30b9\u5207\u308a\u66ff\u3048<\/h3>\n<p>\u4e00\u6642\u5bfe\u5fdc\u7b49\u3001\u624b\u52d5\u306e\u5834\u5408\u306f\u3000\/status \u30ea\u30bd\u30fc\u30b9\u306eGET\u30e1\u30bd\u30c3\u30c9\u306e<strong>\u7d71\u5408\u30ea\u30af\u30a8\u30b9\u30c8<\/strong>\u8a2d\u5b9a\u4e2d\u306e<strong>\u30de\u30c3\u30d4\u30f3\u30b0\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<\/strong>\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u30b3\u30fc\u30c9\u3092\u5909\u66f4\u5f8c\u3001API\u3092\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u4e8b\u3067\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u4e0b\u8a18\u306e\u3088\u3046\u306b\u5909\u5316\u3057\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWIntegRequest.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWIntegRequest-1024x261.png\" alt=\"\" width=\"728\" height=\"186\" class=\"alignnone size-large wp-image-26135\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWIntegRequest-1024x261.png 1024w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWIntegRequest-300x76.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWIntegRequest-768x196.png 768w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWIntegRequest-1536x391.png 1536w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWIntegRequest-2048x522.png 2048w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2024\/03\/APIGWIntegRequest-728x185.png 728w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<p>\u203bAPI\u30c7\u30d7\u30ed\u30a4\u5f8c\u300120\u79d2\u7a0b\u5f85\u3064\u5fc5\u8981\u3042\u308a<\/p>\n<pre>\n% curl https:\/\/xxxxxx.execute-api.ap-northeast-1.amazonaws.com\/api\/status\n{\"status\": \"OK\"}\n\n\u30de\u30c3\u30d4\u30f3\u30b0\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5207\u308a\u66ff\u3048\u5f8c\n% curl https:\/\/xxxxxx.execute-api.ap-northeast-1.amazonaws.com\/api\/status\n{\"status\": \"Maintenance\"}\n<\/pre>\n<h2 id=\"matome\">\u307e\u3068\u3081<\/h2>\n<p>\u5229\u7528\u983b\u5ea6\u306f\u5c11\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u9ad8\u983b\u5ea6\u3067\u30a2\u30af\u30bb\u30b9\u3055\u308c\u308b\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u5834\u5408Lambda\u8d77\u52d5\u3092\u6291\u3048\u308b\u4e8b\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u70b9\u3067\u6709\u7528\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u307e\u305f\u3001\u672c\u984c\u3068\u306f\u305d\u308c\u307e\u3059\u304c\u3001\u30de\u30fc\u30b8\u7528\u306eSAM Template\u3092\u751f\u6210\u7cfbAI\u306b\u4f5c\u6210\u3057\u3066\u3082\u3089\u3044\u8abf\u6574\u3057\u305f\u4e8b\u3067\u8abf\u67fb\u6642\u9593\u3092\u5927\u304d\u304f\u524a\u6e1b\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\nBedrock (Anthropic Claude3\u30b7\u30ea\u30fc\u30ba) \u30ec\u30b9\u30dd\u30f3\u30b9\u7206\u2606\u901f\u3067\u304a\u52e7\u3081\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21 \u80cc\u666f \u5b9f\u88c5\/\u30ec\u30b9\u30dd\u30f3\u30b9\u5207\u308a\u66ff\u3048 \u307e\u3068\u3081 \u80cc\u666f Chalice\uff08\uff0bCI\/CD\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\uff09\u3092\u5229\u7528\u3057\u305fAPI\u958b\u767a\u306b\u304a\u3044\u3066\u3001APIGateway\u3084Lambda\u306b\u5bfe\u3059\u308b\u8ffd\u52a0\u8a2d\u5b9a\u3067 chalice \u306e config\u30d5\u30a1\u30a4\u30eb\u304c&#8230;<\/p>\n","protected":false},"author":2,"featured_media":23164,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"https:\/\/www.skyarch.net\/blog\/?p=26132","footnotes":""},"categories":[20,276],"tags":[],"class_list":{"0":"post-26132","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-aws","8":"category-serverless","9":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/26132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=26132"}],"version-history":[{"count":3,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/26132\/revisions"}],"predecessor-version":[{"id":26139,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/26132\/revisions\/26139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/23164"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=26132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=26132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=26132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}