{"id":19407,"date":"2018-12-07T09:00:44","date_gmt":"2018-12-07T00:00:44","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=19407"},"modified":"2018-12-03T10:20:03","modified_gmt":"2018-12-03T01:20:03","slug":"aws-sam-tips","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2018\/12\/07\/aws-sam-tips\/","title":{"rendered":"\u77e5\u3063\u3066\u304a\u304d\u305f\u304b\u3063\u305fAWS SAM \u306e\u5c0f\u30cd\u30bf4\u9078"},"content":{"rendered":"<p>\u3053\u308c\u306f <a href=\"\/blog\/2018\/11\/22\/techscore-advent-calendar-2018\/\">TECHSCORE Advent Calendar 2018<\/a> \u306e7\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n<p>\u3053\u3093\u306b\u3061\u306f\u3001\u571f\u5c4b\u3067\u3059\u3002<br \/>\n\u4eca\u5e741\u6708\u306b <a href=\"https:\/\/aws.amazon.com\/jp\/blogs\/compute\/announcing-go-support-for-aws-lambda\/\">AWS Lambda \u304c Go \u306e\u30b5\u30dd\u30fc\u30c8\u3092\u958b\u59cb<\/a>\u3057\u307e\u3057\u305f\u306d\u3002<br \/>\nGopher \u305f\u3061\u304c\u8cd1\u308f\u3046\u4e2d\u3001\u79c1\u3082 Go \u306e\u30a2\u30d7\u30ea\u3092 Lambda \u3067\u4f5c\u308a\u305f\u3044\u306a\u3042\u3068\u601d\u3044\u3001 <a href=\"https:\/\/docs.aws.amazon.com\/serverless-application-model\/latest\/developerguide\/what-is-sam.html\">AWS SAM<\/a>\u3092\u4f7f\u3063\u3066\u74b0\u5883\u69cb\u7bc9\u3092\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u74b0\u5883\u69cb\u7bc9\u306f\u30c1\u30e3\u30c1\u30e3\u30c3\u3068\u7d42\u308f\u3089\u305b\u305f\u3044\uff01\u3068\u601d\u3044\u3064\u3064\u3082\u3001\u5b9f\u969b\u306bSAM\u3092\u4f7f\u3063\u3066\u307f\u308b\u3068\u3001\u81ea\u5206\u304c\u3084\u308a\u305f\u3044\u3053\u3068\u3092\u5b9f\u73fe\u3059\u308b\u65b9\u6cd5\u304c\u308f\u304b\u3089\u305a\u3001\u8abf\u3079\u308b\u306e\u306b\u610f\u5916\u306b\u6642\u9593\u304c\u304b\u304b\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3053\u3067\u4eca\u56de\u306f\u300c\u5148\u306b\u77e5\u3063\u3066\u308c\u3070\u3082\u3063\u3068\u5de5\u6570\u524a\u6e1b\u3067\u304d\u305f\u306a\u30fc\u300d\u3068\u601d\u3063\u305f\u3001AWS SAM \u306b\u95a2\u3059\u308b\u5c0f\u30cd\u30bf\u30924\u3064\u3092\u307e\u3068\u3081\u307e\u3057\u305f\u3002<\/p>\n<p>\u203bAWS SAM \u306f\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e <a href=\"https:\/\/docs.aws.amazon.com\/serverless-application-model\/latest\/developerguide\/what-is-sam.html#benefits-of-using-sam\">Benefits of Using AWS SAM<\/a> \u306b\u66f8\u304b\u308c\u3066\u3044\u308b\u901a\u308a\u3001AWS CloudFormation \u306e\u62e1\u5f35\u3067\u3059\u3002\u672c\u8a18\u4e8b\u306e\u5185\u5bb9\u306f\u3001CloudFormation \u306b\u3082\u5f53\u3066\u306f\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>1. \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u3067\u74b0\u5883\u3054\u3068\u306b\u7570\u306a\u308b\u5024\u3092\u6e21\u3057\u305f\u3044<\/h2>\n<p>\u958b\u767a\u74b0\u5883\u3068\u672c\u756a\u74b0\u5883\u306f\u3067\u304d\u308b\u3060\u3051\u540c\u3058\u6761\u4ef6\u306b\u3057\u305f\u3044\u3082\u306e\u3067\u3059\u304c\u3001\u3069\u3046\u3057\u3066\u3082\u74b0\u5883\u3054\u3068\u306b\u7570\u306a\u308b\u5024\u3092\u6e21\u3057\u305f\u3044\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3088\u306d\u3002<br \/>\n\u300c\u74b0\u5883\u3054\u3068\u306b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308b\uff01\u300d\u3068\u3044\u3046\u65b9\u6cd5\u3067\u3082\u89e3\u6c7a\u3067\u304d\u307e\u3059\u304c\u3001\u307b\u307c\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u3044\u304f\u3064\u3082\u7ba1\u7406\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3057\u3001\u958b\u767a\u74b0\u5883\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u884c\u3063\u305f\u5909\u66f4\u3092\u672c\u756a\u74b0\u5883\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u53cd\u6620\u3057\u5fd8\u308c\u3066\u3044\u305f...\u306a\u3069\u306e\u30ea\u30b9\u30af\u3092\u8003\u3048\u308b\u3068\u3042\u307e\u308a\u5b09\u3057\u304f\u306a\u3044\u3067\u3059\u3002<br \/>\n\u305d\u3093\u306a\u6642\u306f <a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/AWSCloudFormation\/latest\/UserGuide\/parameters-section-structure.html\">Parameters<\/a> \u3068 <a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/AWSCloudFormation\/latest\/UserGuide\/mappings-section-structure.html\">Mappings<\/a> \u3092\u4f7f\u3046\u3068\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<p>\u3056\u3063\u304f\u308a\u3068\u3057\u305f\u4f7f\u3044\u65b9\u306f<\/p>\n<ol>\n<li>Parameters \u3067\u74b0\u5883\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u6210<\/li>\n<li>Mappings \u3067\u30ea\u30b9\u30c8\u3054\u3068\u306b\u30de\u30c3\u30d7\u3092\u5b9a\u7fa9<\/li>\n<li>\u30de\u30c3\u30d7\u306e\u5024\u3092\u4f7f\u3044\u305f\u3044\u7b87\u6240\u3067\u57cb\u3081\u8fbc\u307f<\/li>\n<li>\u74b0\u5883\u3092\u6307\u5b9a\u3057\u3066\u30c7\u30d7\u30ed\u30a4<\/li>\n<\/ol>\n<p>\u3068\u3044\u3046\u6d41\u308c\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3068\u3057\u3066\u74b0\u5883\u3054\u3068\u306b\u7570\u306a\u308b\u30a2\u30e9\u30fc\u30c8\u306e\u901a\u77e5\u5148\u3092 SNS \u306b\u8a2d\u5b9a\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\n\u307e\u305a Parameters \u3092\u4f7f\u3063\u305f\u74b0\u5883\u306e\u30ea\u30b9\u30c8\u306f\u6b21\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u958b\u767a\u74b0\u5883\u3001\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u74b0\u5883\u3001\u672c\u756a\u74b0\u5883\u3092\u7528\u610f\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\" title=\"template.yml\">\nParameters:\n Environment:\n   Type: String\n   AllowedValues:\n   - development # \u958b\u767a\u74b0\u5883\n   - staging # \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u74b0\u5883\n   - production # \u672c\u756a\u74b0\u5883\n   Default: development\n<\/pre>\n<p>Mappings \u306f\u6b21\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u74b0\u5883\u3054\u3068\u306b\u901a\u77e5\u5148\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\" title=\"template.yml\">\nMappings:\n EnvironmentMap:\n   development:\n     alertEndpoint: 'development@example.com'\n   staging:\n     alertEndpoint: 'staging@example.com'\n   production:\n     alertEndpoint: 'production@example.com'\n<\/pre>\n<p>\u4f7f\u3044\u305f\u3044\u7b87\u6240\u306b <a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/AWSCloudFormation\/latest\/UserGuide\/intrinsic-function-reference-findinmap.html\">FindInMap<\/a> \u3092\u4f7f\u3063\u3066\u5024\u3092\u57cb\u3081\u8fbc\u307f\u307e\u3059\u3002\u3053\u3053\u3067\u306f SNS \u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3068\u3057\u3066\u3001\u30a2\u30e9\u30fc\u30c8\u5148\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\" title=\"template.yml\">\nResources:\n  SampleNotice: \n    Type: \"AWS::SNS::Topic\"\n    Properties:\n      # DisplayName \u306a\u3069\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u7701\u7565\n      Subscription:\n      - Endpoint: !FindInMap [ EnvironmentMap, !Ref Environment, alertEndpoint] # \u3053\u3053\n        Protocol: email\n<\/pre>\n<p>\u3042\u3068\u306f\u30c7\u30d7\u30ed\u30a4\u6642\u306b <a href=\"https:\/\/docs.aws.amazon.com\/cli\/latest\/reference\/cloudformation\/deploy\/index.html\">--parameter-overrides<\/a> \u3092\u4f7f\u3063\u3066\u74b0\u5883\u3092\u6307\u5b9a\u3059\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\" >\n# cloudformation\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u81ea\u52d5\u751f\u6210\n$ aws cloudformation package \\\n    --template-file template.yml \\\n    --s3-bucket sample \\\n    --s3-prefix sample \\\n    --output-template-file packaged_template.yml\n\n# \u30c7\u30d7\u30ed\u30a4\n$ aws cloudformation deploy \\\n   --template-file packaged_template.yml \\ \n   --stack-name sample \\\n   --capabilities CAPABILITY_IAM \\\n   --parameter-overrides Environment=development # \u3053\u3053\n<\/pre>\n<h2>2. \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u3067AWS\u306e\u30a2\u30ab\u30a6\u30f3\u30c8ID\u3092\u57cb\u3081\u8fbc\u307f\u305f\u3044<\/h2>\n<p>\u74b0\u5883\u3054\u3068\u306bAWS\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u3066\u30011\u3064\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u7ba1\u7406\u3057\u305f\u3044\u6642\u3001\u30b5\u30fc\u30d3\u30b9\u306e\u540d\u524d\u3092\u540c\u3058\u306b\u3057\u3066\u304a\u3051\u3070\u3001AWS\u306e\u30a2\u30ab\u30a6\u30f3\u30c8ID\u3092\u5909\u66f4\u3059\u308b\u3060\u3051\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff09 A\u3068B\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u305d\u308c\u305e\u308c sample.fifo \u3068\u3044\u3046\u540d\u524d\u306eSQS\u3092\u5b9a\u7fa9\u3057\u305f\u5834\u5408<\/p>\n<ul>\n<li>https:\/\/sqs.ap-northeast-1.amazonaws.com\/[A\u306e\u30a2\u30ab\u30a6\u30f3\u30c8ID]\/sample.fifo<\/li>\n<li>https:\/\/sqs.ap-northeast-1.amazonaws.com\/[B\u306e\u30a2\u30ab\u30a6\u30f3\u30c8ID]\/sample.fifo<\/li>\n<\/ul>\n<p>\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u306e\u30a2\u30ab\u30a6\u30f3\u30c8ID\u306e\u6307\u5b9a\u65b9\u6cd5\u3068\u3057\u3066\u3001\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e<a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/AWSCloudFormation\/latest\/UserGuide\/intrinsic-function-reference-sub.html#w2ab1c21c28c59c11b6\">\u30de\u30c3\u30d4\u30f3\u30b0\u306a\u3057\u306e Fn::Sub<\/a>\u306b\u30b9\u30c3\u30ad\u30ea\u3068\u66f8\u304f\u65b9\u6cd5\u304c\u7d39\u4ecb\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u74b0\u5883\u3054\u3068\u306b\u7570\u306a\u308b sample.fifo \u3068\u3044\u3046 SQS \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306a\u3089\u3001\u6b21\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\" title=\"template.yml\">\nQUEUE_URL: !Sub 'https:\/\/sqs.ap-northeast-1.amazonaws.com\/${AWS::AccountId}\/sample.fifo'\n<\/pre>\n<p>\u305f\u3060\u3057\u30a2\u30ab\u30a6\u30f3\u30c8ID\u306f\u3001\u30c7\u30d7\u30ed\u30a4\u524d\u306b\u8a2d\u5b9a\u3059\u308b <a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/cli\/latest\/userguide\/cli-chap-getting-started.html\">aws configure<\/a> \u3067\u6307\u5b9a\u3057\u305fIAM\u30e6\u30fc\u30b6\u30fc\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u4f9d\u5b58\u3059\u308b\u305f\u3081\u3001\u74b0\u5883\u3054\u3068\u306b\u30c7\u30d7\u30ed\u30a4\u7528\u306eIAM\u30e6\u30fc\u30b6\u30fc\u3092\u4f5c\u6210\u3057\u3001 aws configure \u3067\u30c7\u30d7\u30ed\u30a4\u524d\u306b\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u30c7\u30d7\u30ed\u30a4\u7528\u306eIAM\u30e6\u30fc\u30b6\u30fc\u3068\u306f\u7570\u306a\u308b\u30a2\u30ab\u30a6\u30f3\u30c8ID\u3092\u6307\u5b9a\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u5148\u306b\u7d39\u4ecb\u3057\u305f Parameters \u3068 Mappings \u3092\u4f7f\u3063\u3066\u3001\u30a2\u30ab\u30a6\u30f3\u30c8ID\u3092\u57cb\u3081\u8fbc\u3080\u65b9\u6cd5\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>3. \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u3067\u30ed\u30fc\u30eb\u540d\u3092\u6307\u5b9a\u3057\u3066\u30ed\u30fc\u30eb\u3092\u5b9a\u7fa9\u3057\u305f\u3044<\/h2>\n<p>\u5b9f\u969b\u306b\u30cf\u30de\u3063\u305f\u3053\u3068\u306a\u306e\u3067\u3059\u304c\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u30ed\u30fc\u30eb\u3092\u5b9a\u7fa9\u3059\u308b\u969b\u306b\u30ed\u30fc\u30eb\u540d\u3092\u6307\u5b9a\u3057\u3066\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u3068\u3001\u8a2d\u5b9a\u306f\u9593\u9055\u3048\u3066\u3044\u306a\u3044\u306e\u306b\u3001\u306a\u305c\u304b\u30c7\u30d7\u30ed\u30a4\u3067\u304d\u306a\u304b\u3063\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u3057\u305f\u3002<br \/>\n\u539f\u56e0\u306f\u30c7\u30d7\u30ed\u30a4\u6642\u306b --capabilities \u306e\u5024\u306b \"CAPABILITY_NAMED_IAM\" \u3092\u6307\u5b9a\u3057\u3066\u3044\u306a\u304b\u3063\u305f\u304b\u3089\u3067\u3057\u305f\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\">\naws cloudformation deploy \\\n   --template-file packaged_template.yml \\\n   --stack-name sample \\\n   --capabilities CAPABILITY_NAMED_IAM # \u3053\u3053\n<\/pre>\n<p>\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e<a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/AWSCloudFormation\/latest\/UserGuide\/using-iam-template.html#using-iam-capabilities\">AWS CloudFormation \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u306e IAM \u30ea\u30bd\u30fc\u30b9\u306e\u627f\u8a8d<\/a>\u3092\u898b\u308b\u3068\u3001CloudFormation \u306e\u4ed5\u69d8\u3068\u3057\u3066\u3001AWS\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u306b\u5f71\u97ff\u3059\u308b\u30ea\u30bd\u30fc\u30b9\uff08Role\u306e\u4f5c\u6210\u306a\u3069\uff09\u3092\u542b\u3080\u53ef\u80fd\u6027\u304c\u3042\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u6307\u5b9a\u3059\u308b\u5834\u5408\u3001\u660e\u793a\u7684\u306b --capabilities \u3092\u4f7f\u3063\u3066\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u6a5f\u80fd\u306e\u627f\u8a8d\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u6e21\u3059\u5024\u306f\u3001\u901a\u5e38 \"CAPABILITY_IAM\" \u3067\u554f\u984c\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306e\u3088\u3046\u306b\u81ea\u5206\u3067Role\u540d\u3092\u3064\u3051\u308b\u5834\u5408\u3001 \"CAPABILITY_NAMED_IAM\" \u3092\u6e21\u3055\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e <a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/AWSCloudFormation\/latest\/UserGuide\/aws-resource-iam-role.html\">RoleName<\/a> \u306e\u8aac\u660e\u306b CAPABILITY_NAMED_IAM \u3092\u6307\u5b9a\u3059\u308b\u3088\u3046\u8a18\u8f09\u304c\u3042\u308a\u3001\u5b8c\u5168\u306b\u898b\u9003\u3057\u3066\u3044\u305f\u3060\u3051\u306a\u306e\u3067\u3059\u304c\u3001\u30b0\u30b0\u308b\u3068\u30ed\u30fc\u30eb\u306e\u5b9a\u7fa9\u3067\u30cf\u30de\u3063\u305f\u8a18\u4e8b\u304c\u591a\u304f\u30d2\u30c3\u30c8\u3057\u305f\u306e\u3067\u3001\u610f\u5916\u306b\u3053\u3053\u306e\u8a2d\u5b9a\u3092\u5fd8\u308c\u3066\u3044\u308b\u4eba\u306f\u591a\u3044\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093...<\/p>\n<h2>4. \u30c7\u30d7\u30ed\u30a4\u5931\u6557\u6642\u306e\u30ed\u30b0\u3092\u898b\u3084\u3059\u304f\u3057\u305f\u3044<\/h2>\n<p>\u4f8b\u3048\u3070 sample \u3068\u3044\u3046 stack \u540d\u3092\u6307\u5b9a\u3057\u3066\u30c7\u30d7\u30ed\u30a4\u3057\u305f\u969b\u306b\u3001\u30c7\u30d7\u30ed\u30a4\u306b\u5931\u6557\u3059\u308b\u3068 \"aws cloudformation describe-stack-events --stack-name sample\" \u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<br \/>\n\u300c\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066 stack \u306e\u30a4\u30d9\u30f3\u30c8\u3092\u898b\u3066\u539f\u56e0\u3092\u898b\u3064\u3051\u3066\u306d\u300d\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u307e\u307e\u5b9f\u884c\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306b\u5168\u3066\u306e\u30a4\u30d9\u30f3\u30c8\u60c5\u5831\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\">\n$ aws cloudformation describe-stack-events --stack-name sample\n{\n    \"StackEvents\": [\n        {\n            \"StackId\": \"arn:aws:cloudformation:ap-northeast-1:*************:stack\/sample\/dc2d7f10-f3a6-11e8-b88e-0e7d1a719a58\",\n            \"EventId\": \"8bdcd240-f43c-11e8-9edc-500c44f24c82\",\n            \"StackName\": \"sample\",\n            \"LogicalResourceId\": \"sample\",\n            \"PhysicalResourceId\": \"arn:aws:cloudformation:ap-northeast-1:*************:stack\/sample\/dc2d7f10-f3a6-11e8-b88e-0e7d1a719a58\",\n            \"ResourceType\": \"AWS::CloudFormation::Stack\",\n            \"Timestamp\": \"2018-11-30T01:09:11.611Z\",\n            \"ResourceStatus\": \"UPDATE_ROLLBACK_COMPLETE\"\n        },\n        {\n            \"StackId\": \"arn:aws:cloudformation:ap-northeast-1:*************:stack\/sample\/dc2d7f10-f3a6-11e8-b88e-0e7d1a719a58\",\n            \"EventId\": \"Alarm-b1238910-4cca-4605-b22e-3b1cf5c3a109\",\n            \"StackName\": \"sample\",\n            \"LogicalResourceId\": \"Alarm\",\n            \"PhysicalResourceId\": \"\",\n            \"ResourceType\": \"AWS::CloudWatch::Alarm\",\n            \"Timestamp\": \"2018-11-30T01:09:11.211Z\",\n            \"ResourceStatus\": \"DELETE_COMPLETE\"\n        },\n        {\n            \"StackId\": \"arn:aws:cloudformation:ap-northeast-1:*************:stack\/sample\/dc2d7f10-f3a6-11e8-b88e-0e7d1a719a58\",\n            \"EventId\": \"8a95ac40-f43c-11e8-a355-503a6ff78efe\",\n            \"StackName\": \"sample\",\n            \"LogicalResourceId\": \"sample\",\n            \"PhysicalResourceId\": \"arn:aws:cloudformation:ap-northeast-1:*************:stack\/sample\/dc2d7f10-f3a6-11e8-b88e-0e7d1a719a58\",\n            \"ResourceType\": \"AWS::CloudFormation::Stack\",\n            \"Timestamp\": \"2018-11-30T01:09:09.478Z\",\n            \"ResourceStatus\": \"UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS\"\n        },\n        {\n            \"StackId\": \"arn:aws:cloudformation:ap-northeast-1:*************:stack\/sample\/dc2d7f10-f3a6-11e8-b88e-0e7d1a719a58\",\n            \"EventId\": \"87cb41a0-f43c-11e8-a355-503a6ff78efe\",\n            \"StackName\": \"sample\",\n            \"LogicalResourceId\": \"sample\",\n            \"PhysicalResourceId\": \"arn:aws:cloudformation:ap-northeast-1:*************:stack\/sample\/dc2d7f10-f3a6-11e8-b88e-0e7d1a719a58\",\n            \"ResourceType\": \"AWS::CloudFormation::Stack\",\n            \"Timestamp\": \"2018-11-30T01:09:04.789Z\",\n            \"ResourceStatus\": \"UPDATE_ROLLBACK_IN_PROGRESS\",\n            \"ResourceStatusReason\": \"The following resource(s) failed to create: [Alarm]. \"\n        },\n        {\n            \"StackId\": \"arn:aws:cloudformation:ap-northeast-1:*************:stack\/sample\/dc2d7f10-f3a6-11e8-b88e-0e7d1a719a58\",\n            \"EventId\": \"Alarm-CREATE_FAILED-2018-11-30T01:09:03.197Z\",\n            \"StackName\": \"sample\",\n            \"LogicalResourceId\": \"Alarm\",\n            \"PhysicalResourceId\": \"\",\n            \"ResourceType\": \"AWS::CloudWatch::Alarm\",\n            \"Timestamp\": \"2018-11-30T01:09:03.197Z\",\n            \"ResourceStatus\": \"CREATE_FAILED\",\n            # \u898b\u305f\u3044\u306e\u306f\u3053\u3053\u3060\u3051\u2193\n            \"ResourceStatusReason\": \"Value of property AlarmActions must be of type List of String\"\n        },\n        {\n        ... # \u30a4\u30d9\u30f3\u30c8\u306e\u6570\u3060\u3051\u914d\u5217\u304c\u7d9a\u304f\n<\/pre>\n<p>\u30c7\u30d7\u30ed\u30a4\u306b\u5931\u6557\u3057\u305f\u6642\uff08\u4e0a\u8a18\u306e\u4f8b\u3067\u306f CREATE_FAILED \u3057\u305f\u6642\uff09\u3060\u3051\u306e\u7406\u7531\u3060\u3051\u3092\u77e5\u308a\u305f\u3044\u306e\u306b\u3001\u60c5\u5831\u304c\u591a\u3059\u304e\u3066\u898b\u308b\u306e\u304c\u5c11\u3057\u8f9b\u3044\u3067\u3059\u306d...<\/p>\n<p>\u305d\u3053\u3067\u3001\u6b21\u306e\u3088\u3046\u306b jq \u3092\u4f7f\u3063\u3066\u5931\u6557\u3057\u305f\u7b87\u6240\u3060\u3051\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u5b9f\u884c\u3059\u308b\u3068\u3001\u3044\u3044\u611f\u3058\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"toolbar:1 decode:true\">\n$ aws cloudformation describe-stack-events --stack-name sample | \n  jq -r '.StackEvents[] | select(.ResourceStatus == \"CREATE_FAILED\") | .ResourceStatusReason'\nValue of property AlarmActions must be of type List of String\n<\/pre>\n<p>\u203b--stack-name \u3068 ResourceStatus \u3067\u6307\u5b9a\u3059\u308b\u5024\uff08\u4e0a\u8a18\u306e sample \u3084 CREATE_FAILED\uff09\u306f\u3001\u5b9f\u884c\u6642\u306e\u72b6\u614b\u306b\u5fdc\u3058\u3066\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>\u6700\u5f8c\u306b<\/h2>\n<p>\u4eca\u56de\u306e\u8a18\u4e8b\u3067\u306f<\/p>\n<ul>\n<li>Parameters \u3068 Mappings \u3092\u4f7f\u7528\u3057\u305f\u5024\u306e\u6e21\u3057\u65b9<\/li>\n<li>\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u4f7f\u308f\u306a\u3044 Fn::Sub \u306e\u4f7f\u3044\u65b9<\/li>\n<li>\u30ed\u30fc\u30eb\u540d\u3092\u6307\u5b9a\u3057\u305f\u30ed\u30fc\u30eb\u5b9a\u7fa9\u306e\u30c7\u30d7\u30ed\u30a4\u65b9\u6cd5<\/li>\n<li>\u30c7\u30d7\u30ed\u30a4\u5931\u6557\u6642\u306b\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3060\u3051\u8868\u793a\u3059\u308b\u65b9\u6cd5<\/li>\n<\/ul>\n<p>\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<br \/>\n\u5b9f\u969b\u306b AWS SAM \u3092\u4f7f\u3063\u3066\u307f\u3066\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u66f8\u304d\u65b9\u306a\u3069\u3001\u6163\u308c\u308b\u307e\u3067\u306b\u5c11\u3057\u6642\u9593\u304c\u304b\u304b\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u304c\u3001\u4e00\u5ea6\u6163\u308c\u308b\u3068\u6c17\u8efd\u306b\u8a2d\u5b9a\u3092\u5909\u66f4\u3067\u304d\u3066\u4f7f\u3044\u3084\u3059\u3044\u3068\u601d\u3044\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/github.com\/awslabs\/serverless-application-model\/releases\">\u30ea\u30ea\u30fc\u30b9\u30ce\u30fc\u30c8<\/a>\u3092\u898b\u308b\u3068\u3001\u57f7\u7b46\u3057\u3066\u3044\u308b\u73fe\u5728\u3082\u3069\u3093\u3069\u3093\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3057\u3001\u74b0\u5883\u69cb\u7bc9\u3067AWS SAM\u3092\u4f7f\u3063\u305f\u3053\u3068\u304c\u306a\u3044\u4eba\u306f\u3001\u8a66\u3057\u306b\u4f7f\u3063\u3066\u307f\u3066\u306f\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u6700\u5f8c\u307e\u3067\u8aad\u3093\u3067\u3044\u305f\u3060\u304d\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u308c\u306f TECHSCORE Advent Calendar 2018 \u306e7\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n<p>\u3053\u3093\u306b\u3061\u306f\u3001\u571f\u5c4b\u3067\u3059\u3002<br \/>\n\u4eca\u5e741\u6708\u306b AWS Lambda \u304c Go \u306e\u30b5\u30dd\u30fc\u30c8\u3092\u958b\u59cb\u3057\u307e\u3057\u305f\u306d\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2018\/12\/07\/aws-sam-tips\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":64,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[308,18],"tags":[141,119],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/19407"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=19407"}],"version-history":[{"count":103,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/19407\/revisions"}],"predecessor-version":[{"id":19673,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/19407\/revisions\/19673"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=19407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=19407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=19407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}