{"id":538,"date":"2019-04-18T06:00:00","date_gmt":"2019-04-17T21:00:00","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2019\/04\/18\/nested-applications"},"modified":"2019-04-18T06:00:00","modified_gmt":"2019-04-17T21:00:00","slug":"nested-applications","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2019\/04\/18\/nested-applications\/","title":{"rendered":"\u30b5\u30fc\u30d0\u30fc\u30ec\u30b9\u3067\u6d3b\u7528\u3059\u308bCloudFormation\u306eNested Applications"},"content":{"rendered":"
\u5f0a\u793e\u306e\u30b5\u30fc\u30d0\u30ec\u30b9\u958b\u767a\u4e8b\u4f8b\u306b\u3066\u5229\u7528\u3057\u3066\u3044\u308b \u91cd\u8981\u306a\u5236\u9650\u3068\u3057\u3066\u3001\u30ea\u30bd\u30fc\u30b9\u6570\u306e\u5236\u9650<\/font>\u304c\u3042\u308a\u307e\u3059\u3002 \u4f8b\u3048\u3070\u3001\u30b7\u30f3\u30d7\u30eb\u306aAWS Lambda\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u5b9a\u7fa9\u3057\u305f\u5834\u5408\u3001 \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u8a18\u8f09\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u6570\u306f <\/p>\n \u3067\u306f\u3001\u3069\u306e\u3088\u3046\u306b\u3059\u308c\u3070\u3088\u3044\u306e\u3067\u3057\u3087\u3046\u304b\u3002 AWS Serverless Application Model(SAM)\u306f\u62e1\u5f35\u3055\u308c\u305f\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306e\u305f\u3081\u3001 \u4ee3\u66ff\u624b\u6bb5\u3068\u3057\u3066\u3001 Nested Applications\u306e Nested Applications\u306f \u305d\u308c\u3067\u306f\u3001\u5b9f\u969b\u306b\u3084\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002 \u7b46\u8005\u672c\u4eba\u306eGitHub\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u3066\u30ea\u30dd\u30b8\u30c8\u30ea\u3082\u516c\u958b\u3057\u3066\u304a\u308a\u307e\u3059\u306e\u3067\u3001 \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306f \u30b5\u30f3\u30d7\u30eb\u3067\u306f\u3001\u30cd\u30b9\u30c8\u3055\u308c\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u305d\u308c\u305e\u308c\u306b \u30c7\u30d7\u30ed\u30a4\u306f <\/p>\n Nested Applications\u306e\u4f5c\u6210\u306b\u6210\u529f\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\uff01<\/strong><\/p>\n \u30b5\u30fc\u30d0\u30ec\u30b9\u958b\u767a\u306e\u5834\u5408\u3001\u6c17\u3065\u3044\u305f\u3089\u30ea\u30bd\u30fc\u30b9\u6570\u304c\u903c\u8feb\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u3082 \u5c11\u3057\u3067\u3082\u3054\u8208\u5473\u3092\u6301\u3061\u307e\u3057\u305f\u3089\u3001\u5f0a\u793e\u306b\u30a8\u30f3\u30c8\u30ea\u30fc\u3057\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u5e78\u3044\u3067\u3059\u3002
\nNested Applications<\/code> \u306b\u3064\u3044\u3066\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n
CloudFormation\u306e\u30ea\u30bd\u30fc\u30b9\u6570\u306e\u5236\u9650<\/h2>\n
AWS CloudFormation<\/code> \u306b\u306f\u5236\u9650\u304c\u3042\u308b\u3053\u3068\u3092\u3054\u5b58\u77e5\u3067\u3057\u3087\u3046\u304b\u3002
\n\u5236\u9650\u306e\u307b\u3068\u3093\u3069\u306f\u3001\u4e0a\u9650\u89e3\u653e\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u5236\u9650\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n\n
\n\u30ea\u30bd\u30fc\u30b9\u306f\u4e00\u3064\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u6700\u5927\u3067200<\/font>\u307e\u3067\u3057\u304b\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n\u300c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u8a18\u8f09\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u6570 = \u30ea\u30bd\u30fc\u30b9\u6570\u300d
\u3067\u306f\u306a\u3044<\/h2>\n
\n\u4e0b\u8a182\u3064\u306e\u30ea\u30bd\u30fc\u30b9\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n\n
\n\u6700\u7d42\u7684\u306b\u51fa\u529b\u3055\u308c\u308b\u30ea\u30bd\u30fc\u30b9\u6570\u3068\u306f\u5408\u81f4\u3057\u307e\u305b\u3093\u3002
\n\u30ea\u30bd\u30fc\u30b9\u6570\u306f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3078\u306e\u8a18\u8f09\u3092\u5897\u3084\u3059\u6bce\u306b\u3001\u81a8\u3089\u3093\u3067\u3044\u304d\u307e\u3059\u3002
\n\u7279\u306b\u30b5\u30fc\u30d0\u30fc\u30ec\u30b9\u306e\u5834\u5408\u306fAWS Lambda\u306b\u5bfe\u3057\u3066\u306e\u30a4\u30d9\u30f3\u30c8\u30bd\u30fc\u30b9\u3068\u3057\u3066
\n\u8907\u6570\u306eAPI\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u7d10\u3065\u3051\u308b\u30b1\u30fc\u30b9\u304c\u3042\u308a\u3001
\n\u3059\u3050\u306b\u30ea\u30bd\u30fc\u30b9\u6570\u304c\u3044\u3063\u3071\u3044\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n
\n\u89e3\u6c7a\u7b56\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\nNested Applications\u3092\u5229\u7528\u3057\u3066\u30cd\u30b9\u30c8\u3055\u308c\u305f\u30b9\u30bf\u30c3\u30af\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n
\nAWS::CloudFormation::Stack<\/code> \u5b9a\u7fa9\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n
\nAWS::Serverless::Application<\/code> \u304c\u5229\u7528\u53ef\u80fd\u3067\u3059\u3002
\nNested Applications\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067 \u6700\u5927\u306740,000<\/strong> \u306e
\n\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002
\n\u307e\u305f\u3001\u30cd\u30b9\u30c8\u3055\u308c\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u81ea\u52d5\u7684\u306bS3\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u307e\u3059\u3002<\/strong><\/p>\n\n
Serverless Application Repository<\/code> \u306e
\n\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30cd\u30b9\u30c8\u3067\u304d\u308b\u3053\u3068\u306b\u6ce8\u76ee\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001
\n\u30ed\u30fc\u30ab\u30eb\u306b\u3042\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30cd\u30b9\u30c8\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\u30ed\u30fc\u30ab\u30eb\u306b\u3042\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30cd\u30b9\u30c8\u3059\u308b\u5834\u5408\u306e\u8a18\u8ff0\u4f8b\uff1a<\/h3>\n
Transform: AWS::Serverless-2016-10-31\n\nResources:\n applicationaliasname:\n Type: AWS::Serverless::Application\n Properties:\n Location: ..\/my-other-app\/template.yaml<\/code><\/pre>\n
Nested Applications\u3092\u5229\u7528\u3057\u3066\u3001\u30b5\u30fc\u30d0\u30fc\u30ec\u30b9\u306e\u30b9\u30bf\u30c3\u30af\u3092\u4f5c\u6210<\/h2>\n
\n\u30b5\u30f3\u30d7\u30eb\u306f\u4e0b\u56f3\u306e\u30d5\u30a9\u30eb\u30c0\u69cb\u6210\u3068\u306a\u308a\u307e\u3059\u3002
\n<\/p>\n
\n\u3088\u308d\u3057\u3051\u308c\u3070\u3054\u53c2\u7167\u4e0b\u3055\u3044\u3002<\/p>\n\n
\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb(template.yml)<\/h3>\n
AWS::Serverless::Application<\/code> \u306e\u30ea\u30bd\u30fc\u30b9\u3092\u5b9a\u7fa9\u3057
\n\u30cd\u30b9\u30c8\u3055\u308c\u305f\u30b9\u30bf\u30c3\u30af\u3092\u69cb\u7bc9\u3057\u307e\u3059\u3002\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u53d7\u3051\u6e21\u3059\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002
\n\u4e0b\u8a18\u306e\u8a18\u8ff0\u4f8b\u3067\u306f\u3001 Parameters<\/code> \u306b\u5b9a\u7fa9\u3055\u308c\u305f\u5909\u6570\u3068S3\u306e\u30d0\u30b1\u30c3\u30c8\u540d\u3092\u53d7\u3051\u6e21\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n
AWSTemplateFormatVersion: '2010-09-09'\nTransform: AWS::Serverless-2016-10-31\n\nParameters:\n Stage:\n Type: String\n Default: test\n\nResources:\n app1:\n Type: AWS::Serverless::Application\n Properties:\n Location: .\/template_app1.yml\n app2:\n Type: AWS::Serverless::Application\n Properties:\n Location: .\/template_app2.yml\n Parameters:\n Stage: !Ref Stage\n BucketTest: !Ref S3Bucket\n\n S3Bucket:\n Type: AWS::S3::Bucket\n Properties:\n BucketName: aws-sam-nested-application-test-bucket-0-001<\/code><\/pre>\n
\u30cd\u30b9\u30c8\u3055\u308c\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb<\/h3>\n
AWS::Serverless::Function<\/code> \u306e\u30ea\u30bd\u30fc\u30b9\u3092\u5b9a\u7fa9\u3057\u307e\u3057\u305f\u3002
\n\u89aa\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u53d7\u3051\u6e21\u3055\u308c\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u3082\u53c2\u7167\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\u30c6\u30f3\u30d7\u30ec\u30fc\u30c81(template_app1.yml)<\/h4>\n
AWSTemplateFormatVersion: 2010-09-09\nTransform: AWS::Serverless-2016-10-31\n\nResources:\n App1Function:\n Type: AWS::Serverless::Function\n Properties:\n FunctionName: app1\n CodeUri: handlers\/app1\n Handler: app1\n Runtime: go1.x\n\n S3Bucket001:\n Type: AWS::S3::Bucket\n Properties:\n BucketName: aws-sam-nested-application-test-bucket-1-001<\/code><\/pre>\n
\u30c6\u30f3\u30d7\u30ec\u30fc\u30c82(template_app2.yml)<\/h4>\n
AWSTemplateFormatVersion: 2010-09-09\nTransform: AWS::Serverless-2016-10-31\n\nParameters:\n Stage:\n Type: String\n Default: dev\n BucketTest:\n Type: String\n\nGlobals:\n Function:\n Runtime: go1.x\n Timeout: 900\n Environment:\n Variables:\n STAGE: !Ref Stage\n\nResources:\n App2Function:\n Type: AWS::Serverless::Function\n Properties:\n FunctionName: app2\n CodeUri: handlers\/app2\n Handler: app2\n\n S3Bucket2001:\n Type: AWS::S3::Bucket\n Properties:\n BucketName: aws-sam-nested-application-test-bucket-2-001<\/code><\/pre>\n
\u30c7\u30d7\u30ed\u30a4<\/h2>\n
sam deploy<\/code> \u306e\u5b9f\u884c\u6642\u306bCAPABILITY_AUTO_EXPAND<\/font>\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u4e0e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n
#!\/bin\/sh\n\n# Create Package\nsam package \n --template-file .\/template.yml \n --output-template-file .\/template-output.yml \n --s3-bucket aws-sam-nested-application-packages \n --profile temp_profile\n\n# Deploy\nsam deploy \n --template-file .\/template-output.yml \n --stack-name aws-sam-nested-application \n --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND \n --profile temp_profile<\/code><\/pre>\n
\u5b9f\u884c\u7d50\u679c<\/h2>\n
\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u5206\u5272\u306f\u8a08\u753b\u7684\u306b<\/h2>\n
\n\u73cd\u3057\u304f\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u4e2d\u30fb\u5927\u898f\u6a21\u306e\u30b5\u30fc\u30d0\u30ec\u30b9\u958b\u767a\u306a\u3089\u5c1a\u66f4\u3067\u3059\u3002
\n\u30ea\u30bd\u30fc\u30b9\u306e\u6574\u7406\u306b\u4f34\u3046\u518d\u4f5c\u6210\u304c\u4f59\u5100\u306a\u304f\u3055\u308c\u308b\u524d\u306b\u3001\u8a08\u753b\u7684\u306b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u5206\u5272\u3059\u308b\u3053\u3068\u3092\u30aa\u30b9\u30b9\u30e1\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n\u5f0a\u793e\u3067\u306fGo\u3068AWS SAM\u3092\u6d3b\u7528\u3057\u305f\u30b5\u30fc\u30d0\u30ec\u30b9\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u5b9f\u7e3e\u304c\u3042\u308a\u307e\u3059<\/h2>\n
\n\u4e00\u7dd2\u306b\u697d\u3057\u304f\u6210\u9577\u3057\u3042\u3048\u308b\u4ef2\u9593\u3092\u52df\u96c6\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n