{"id":16044,"date":"2016-06-17T18:10:04","date_gmt":"2016-06-17T09:10:04","guid":{"rendered":"http:\/\/labs.gree.jp\/blog\/?p=16044"},"modified":"2016-06-18T14:43:59","modified_gmt":"2016-06-18T05:43:59","slug":"capistrano-%e3%81%a7%e3%81%af%e3%81%98%e3%82%81%e3%82%8b%e3%82%aa%e3%83%bc%e3%83%88%e3%82%b9%e3%82%b1%e3%83%bc%e3%83%aa%e3%83%b3%e3%82%b0","status":"publish","type":"post","link":"https:\/\/labs.gree.jp\/blog\/2016\/06\/16044\/","title":{"rendered":"Capistrano \u3067\u306f\u3058\u3081\u308b\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0"},"content":{"rendered":"<div id=\"md\" class=\"markdown-body\">\n<p>\u30a4\u30f3\u30d5\u30e9\u306e\u99d2\u5d0e\u3067\u3059\u3002<\/p>\n<p>Capistrano \u3092\u4f7f\u3063\u305f\u30c7\u30d7\u30ed\u30a4\u304b\u3089\u3001\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u3092\u30b9\u30e0\u30fc\u30ba\u306b\u5c0e\u5165\u3059\u308b\u305f\u3081\u306e\u5f0a\u793e\u4e8b\u4f8b\u3092\u7d39\u4ecb\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h1>\u3053\u3093\u306a\u65b9\u3078<\/h1>\n<p>\u672c\u7a3f\u3067\u60f3\u5b9a\u3059\u308b\u306e\u306f\u3053\u306e\u3088\u3046\u306a\u72b6\u6cc1\u3067\u3059\u3002<\/p>\n<ul>\n<li>Capistrano \u3092\u4f7f\u3063\u3066\u4e2d\u592e\u7ba1\u7406\u578b\u30c7\u30d7\u30ed\u30a4\u3092\u3057\u3066\u3044\u308b<\/li>\n<li>AWS \u306a\u3069\u306e\u30af\u30e9\u30a6\u30c9\u30a4\u30f3\u30d5\u30e9\u3092\u4f7f\u3063\u3066\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u3092\u3084\u308a\u305f\u3044<\/li>\n<li>\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u6642\u306e\u30c7\u30d7\u30ed\u30a4\u3092\u3069\u3046\u3059\u308b\u304b\u691c\u8a0e\u3057\u3066\u3044\u308b<\/li>\n<li>\u30b3\u30f3\u30c6\u30ca\u30d9\u30fc\u30b9\u306e\u30c7\u30d7\u30ed\u30a4\u3084\u30d6\u30eb\u30fc\u30b0\u30ea\u30fc\u30f3\u30c7\u30d7\u30ed\u30a4\u306b\u306f\u6e96\u5099\u304c\u8db3\u308a\u306a\u3044<\/li>\n<\/ul>\n<p>\u7406\u60f3\u306f\u898b\u3048\u3066\u3044\u308b\u3082\u306e\u306e\u306a\u304b\u306a\u304b\u9032\u307e\u306a\u3044\u72b6\u6cc1\u304b\u3089\u3001\u3067\u304d\u308b\u3060\u3051\u30b9\u30e0\u30fc\u30ba\u306b\u6539\u5584\u3092\u91cd\u306d\u308b\u3053\u3068\u3092\u76ee\u6307\u3057\u307e\u3059\u3002<\/p>\n<p>\u672c\u7a3f\u306e\u30b4\u30fc\u30eb\u306f AWS \u3067\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u904e\u5ea6\u306a\u4e00\u822c\u5316\u3092\u907f\u3051\u308b\u305f\u3081\u3001\u672c\u7a3f\u3067\u306f AWS \u74b0\u5883\u3092\u524d\u63d0\u3068\u3057\u3066\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<h1>\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u306b\u5fc5\u8981\u306a\u3082\u306e<\/h1>\n<p>\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u306e\u30b5\u30a4\u30af\u30eb\u306f\u3001\u304a\u304a\u307e\u304b\u306b\u6b21\u306e\u3088\u3046\u306b\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<ol>\n<li>\u30a4\u30e1\u30fc\u30b8\u304b\u3089\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u8d77\u52d5\u3059\u308b<\/li>\n<li>\u8d77\u52d5\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u6700\u65b0\u306e\u72b6\u614b\u306b\u3059\u308b<\/li>\n<li>\u30ed\u30fc\u30c9\u30d0\u30e9\u30f3\u30b5\u306b\u95a2\u9023\u4ed8\u3051\u30b5\u30fc\u30d3\u30b9\u30a4\u30f3<\/li>\n<li>\u4e0d\u5fc5\u8981\u306b\u306a\u3063\u305f\u3089\u30b5\u30fc\u30d3\u30b9\u30a2\u30a6\u30c8<\/li>\n<li>\u30ed\u30b0\u306e\u78ba\u5b9f\u306a\u56de\u53ce\u306a\u3069\u7d42\u4e86\u51e6\u7406\u3092\u884c\u3046<\/li>\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u7834\u68c4\u3059\u308b<\/li>\n<\/ol>\n<p>AWS \u306e Auto Scaling Group (ASG) \u3092\u4f7f\u3046\u3068\u30012, 5 \u3092\u9664\u304f\u5168\u3066\u3092 AWS \u306b\u4efb\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b ASG \u306e Lifecycle Hook \u3092\u4f7f\u3046\u3053\u3068\u3067\u30012, 5 \u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u30e6\u30fc\u30b6\u304c\u4efb\u610f\u306e\u51e6\u7406\u3092\u884c\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3057\u3001 AWS CodeDeploy \u304c\u4f7f\u3048\u308b\u306e\u3067\u3042\u308c\u3070\u3001<a href=\"http:\/\/blogs.aws.amazon.com\/application-management\/post\/Tx1NRS217K1YOPJ\/Under-the-Hood-AWS-CodeDeploy-and-Auto-Scaling-Integration\">AWS \u30d6\u30ed\u30b0\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>\u306e\u3088\u3046\u306b\u3001\u3053\u306e\u30d7\u30ed\u30bb\u30b9\u3082 AWS \u306b\u4efb\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h1>\u9023\u7d9a\u7684\u306a\u79fb\u884c<\/h1>\n<p>\u5b9f\u969b\u306e\u3068\u3053\u308d\u3001\u4f8b\u3048\u3070\u3001Capistrano \u30d9\u30fc\u30b9\u304b\u3089 CodeDeploy \u30d9\u30fc\u30b9\u3078\u65e2\u5b58\u306e\u30c7\u30d7\u30ed\u30a4\u30d5\u30ed\u30fc\u3092\u5237\u65b0\u3059\u308b\u3053\u3068\u306f\u4e0d\u9023\u7d9a\u3067\u5287\u7684\u306a\u5909\u5316\u306b\u306a\u308a\u304c\u3061\u3067\u3059\u3002\u3053\u306e\u6642\u306b\u76f4\u9762\u3059\u308b\u8ab2\u984c\u306e\u4e00\u3064\u306f\u3001\u5909\u5316\u306b\u5bfe\u3059\u308b\u95a2\u4fc2\u8005\u306e\u4e0d\u5b89\u3092\u53d6\u308a\u9664\u304f\u3053\u3068\u3067\u3042\u308a\u3001\u305d\u306e\u305f\u3081\u306e\u30b3\u30b9\u30c8\u306f\u81a8\u3089\u3093\u3067\u3057\u307e\u3046\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u5c0e\u5165\u306b\u5bfe\u3059\u308b\u5fc3\u7406\u7684\u306a\u969c\u58c1\u3092\u4e0b\u3052\u3001\u5b89\u5168\u6027\u3092\u4fdd\u3061\u7d9a\u3051\u308b\u305f\u3081\u306e\u9023\u7d9a\u7684\u306a\u5909\u5316\u3092\u8003\u3048\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u65e2\u5b58\u306e Capistrano \u30d9\u30fc\u30b9\u306e\u30d5\u30ed\u30fc\u3092\u6b8b\u3057\u306a\u304c\u3089\u3001\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u306b\u5bfe\u5fdc\u3067\u304d\u308b\u5c0f\u3055\u306a\u4fee\u6b63\u3092\u8ffd\u52a0\u3057\u3001\u9023\u7d9a\u7684\u306a\u79fb\u884c\u3092\u884c\u3046\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\u5b9f\u969b\u306b\u4e00\u90e8\u306e\u5546\u7528\u74b0\u5883\u306b\u5c0e\u5165\u3057\u305f\u969b\u306e\u4e8b\u4f8b\u3067\u3059\u3002<\/p>\n<h2>\u524d\u63d0<\/h2>\n<p>\u5f0a\u793e\u3067\u306f\u3001\u904b\u7528\u4e2d\u306b\u5909\u66f4\u304c\u306a\u3044\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u7b49\u3092\u8a2d\u5b9a\u3057\u305f AMI \u3092\u30b5\u30fc\u30d3\u30b9\u6bce\u306b\u7528\u610f\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u8d77\u52d5\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b Capistrano \u30c7\u30d7\u30ed\u30a4\u3092\u884c\u3046\u3053\u3068\u3067\u30b5\u30fc\u30d3\u30b9\u30a4\u30f3\u3067\u304d\u308b\u72b6\u6cc1\u3067\u3059\u3002<\/p>\n<h2>Capistrano \u4e0b\u6e96\u5099<\/h2>\n<p>\u7c21\u5358\u306e\u305f\u3081\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u7528\u306b\u8a2d\u5b9a\u3055\u308c\u305f Capistrano \u30b3\u30fc\u30c9\u3092 <code>cap<\/code> \u30b3\u30fc\u30c9\u3068\u66f8\u304f\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u901a\u5e38\u3068\u540c\u3058 <code>cap<\/code> \u3092\u4f7f\u3063\u3066\u3001\u8d77\u52d5\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u81ea\u5206\u81ea\u8eab\u3078\u30c7\u30d7\u30ed\u30a4\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f <code>cap<\/code> \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3078<\/p>\n<ul>\n<li>\u81ea\u5206\u3078\u306e\u30c7\u30d7\u30ed\u30a4\u6307\u793a<\/li>\n<li><code>cap<\/code> \u30b3\u30fc\u30c9\u3092 S3 \u3078\u4fdd\u5b58<\/li>\n<\/ul>\n<p>\u3059\u308b\u51e6\u7406\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002\u5f8c\u8005\u306f\u8d77\u52d5\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c cap \u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3067\u3059\u3002\u3053\u308c\u3089\u306f\u975e\u7834\u58ca\u7684\u306a\u5909\u66f4\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30b3\u30fc\u30c9\u306e\u5909\u66f4\u90e8\u5206\u306f\u3001\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u3092\u5b9a\u7fa9\u3059\u308b\u90e8\u5206\u3067\u3059\u3002Capistrano \u3092 AWS \u3067\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u7d30\u90e8\u306f\u9055\u3048\u3069\u5bfe\u8c61\u3092\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\u304c\u3042\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<pre><code class=\"language-ruby:config\/deploy\/production.rb\"># ...\n# \u5909\u6570\u8a2d\u5b9a\u306a\u3069\u306a\u3069\u2026\n# ...\n\n# EC2 API \u3092\u53e9\u3044\u3066\u5bfe\u8c61\u3092\u53d6\u5f97\u3059\u308b\u3088\u3046\u306a\u30b3\u30fc\u30c9\nec2_describe_instances_etc(params).each do |instance|\n  server instance.private_ip_address, roles: [...], user: 'xxx', ssh_options: {...}\nend\n<\/code><\/pre>\n<p>\u3053\u306e\u90e8\u5206\u306b\u3001<code>deploy_local=1<\/code> \u304c\u3042\u308c\u3070\u81ea\u5206\u3078\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u3088\u3046\u8a2d\u5b9a\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002Capfile \u306b gem \u3082\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"\"><code class=\"language-ruby:config\/deploy\/production.rb\"># ...\n# \u5909\u6570\u8a2d\u5b9a\u306a\u3069\u306a\u3069\u2026\n# ...\n\nif ENV['deploy_local']\n  server 'localhost', roles: [...]\nelse\n  set :release_deploy, true\n  # EC2 API \u3092\u53e9\u3044\u3066\u5bfe\u8c61\u3092\u53d6\u5f97\u3059\u308b\u3088\u3046\u306a\u30b3\u30fc\u30c9\n  ec2_describe_instances_etc(params).each do |instance|\n    server instance.private_ip_address, roles: [...], user: 'xxx', ssh_options: {...}\n  end\nend<\/code><\/pre>\n<pre class=\"\"><code class=\"language-ruby:Capfile\"># In Capfile\nrequire 'capistrano-locally'\n<\/code><\/pre>\n<p>\u3053\u3053\u3067\u306f <code>localhost<\/code> \u3078\u306e SSH \u3092\u7c21\u7565\u5316\u3059\u308b <a href=\"https:\/\/github.com\/komazarari\/capistrano-locally\">capistrano-locally<\/a> \u3068\u3044\u3046 gem \u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u5404\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3078 SSH \u9375\u3092\u914d\u7f6e\u3057\u3066\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u901a\u5e38\u306e\u65b9\u6cd5\u3067\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u6b21\u306b\u3001Capistrano \u30b3\u30fc\u30c9\u81ea\u8eab\u3068\u3001\u6700\u5f8c\u306b\u30c7\u30d7\u30ed\u30a4\u6210\u529f\u3057\u305f\u30ea\u30d3\u30b8\u30e7\u30f3\u3092 S3 \u306b\u7f6e\u3044\u3066\u304a\u304f\u30bf\u30b9\u30af\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-ruby:lib\/capistrano\/tasks\/\"># In lib\/capistrano\/tasks\/xxxx.rake\nnamespace :deploy\n\u00a0 desc \"Store current deployed revision\"\n  task store_revision: :set_current_revision do\n    if fetch(:release_deploy)\n      run_locally do\n        info \"Store #{fetch(:current_revision)} to s3:\/\/#{fetch(:bucket_name)}\/metadata\/#{fetch(:stage)}\/release_version\"\n        options = fetch(:s3_client_options, { region: 'ap-northeast-1' })\n        Aws::S3::Client.new(options).put_object(bucket: fetch(:bucket_name),\n          key: \"metadata\/#{fetch(:stage)}\/release_version\",\n          body: StringIO.new(fetch(:current_revision))\n        )\n      end\n    end\n  end\n\n  desc \"Upload deploy tool to S3\"\n  task :upload_deploy_tool do\n    tool_root = Pathname(__FILE__).dirname.parent.parent.parent\n    run_locally do\n      execute :aws, 's3', 'sync', '--exclude \"vendor*\", --exclude \".git*\", --exclude \"\u4e2d\u7565\" --no-follow-symlinks --delete', tool_root, \"s3:\/\/#{fetch(:bucket_name)}\/autolaunch\/deploy_tool\"\n    end\n  end\n\n  after :finished, :store_revision\n  after :finished, :upload_deploy_tool\nend\n<\/code><\/pre>\n<p>Capistrano \u5074\u306f\u3053\u308c\u3067\u5341\u5206\u3067\u3059\u3002\u3053\u308c\u307e\u3067\u306e\u30c7\u30d7\u30ed\u30a4\u3082\u554f\u984c\u306a\u304f\u884c\u3048\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u30b5\u30a4\u30af\u30eb\u3078\u306e\u9069\u7528<\/h2>\n<p>\u3055\u3066\u3001\u3053\u3053\u304b\u3089\u306f\u3069\u306e\u3088\u3046\u306b\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u30b5\u30a4\u30af\u30eb\u3092\u5b9f\u73fe\u3059\u308b\u304b\u3092\u8003\u3048\u307e\u3059\u3002 \u524d\u8ff0\u3057\u305f\u3088\u3046\u306b\u3001ASG \u3092\u4f7f\u3046\u306e\u3067\u3042\u308c\u3070\u30e6\u30fc\u30b6\u304c\u884c\u3046\u306e\u306f\u8d77\u52d5\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3078\u306e\u30c7\u30d7\u30ed\u30a4\u3068\u7d42\u4e86\u51e6\u7406\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u4e00\u3064\u306f cloud-init \u306b\u3088\u308b\u8d77\u52d5\u6642\u306e\u30c7\u30d7\u30ed\u30a4\u304c\u8003\u3048\u3089\u308c\u307e\u3059\u304c\u3001\u8d77\u52d5\u6642\u306e\u5b9f\u884c\u9806\u756a\u306e\u5236\u5fa1\u3084\u5931\u6557\u6642\u30ea\u30c8\u30e9\u30a4\u3092\u30b1\u30a2\u3059\u308b\u306e\u304c\u9762\u5012\u3067\u3059\u3002 \u305b\u3063\u304b\u304f\u306e\u81ea\u52d5\u5316\u3067\u3059\u306e\u3067\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u72b6\u6cc1\u3092\u5224\u65ad\u3057\u81ea\u5f8b\u7684\u306b\u52d5\u304d\u3001\u72b6\u614b\u306e\u53ce\u675f\u3092\u56f3\u3063\u3066\u304f\u308c\u308b\u3068\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n<h3>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u81ea\u5f8b\u5316<\/h3>\n<p>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u72b6\u6cc1\u5224\u65ad\u3092\u884c\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002 \u3068\u8a00\u3063\u3066\u3082\u3001\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u30d7\u30ed\u30bb\u30b9\u3092\u914d\u7f6e\u3059\u308b\u307b\u3069\u3067\u3082\u306a\u3044\u306e\u3067\u3001cron \u3067\u6e08\u307e\u305b\u307e\u3059\u3002\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u884c\u3063\u3066\u307b\u3057\u3044\u81ea\u5f8b\u884c\u52d5\u306f\u4e0b\u56f3\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16049\" src=\"http:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2016\/06\/autolaunch_webinstance-502x400.png\" alt=\"\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u81ea\u5f8b\u884c\u52d5\u306e\u56f3\" width=\"502\" height=\"400\" srcset=\"https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2016\/06\/autolaunch_webinstance-502x400.png 502w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2016\/06\/autolaunch_webinstance-251x200.png 251w, https:\/\/labs.gree.jp\/blog\/wp-content\/uploads\/2016\/06\/autolaunch_webinstance.png 618w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/p>\n<p>\u3053\u3061\u3089\u306f\u305d\u308c\u3092\u884c\u306a\u3046\u305f\u3081\u306e\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u5b9f\u88c5\u306e\u4e00\u90e8\u3067\u3059\u3002<\/p>\n<pre><code>critial_section_begin\n# ...\n# EC2 \u306e\u30bf\u30b0\u306a\u3069\u304b\u3089\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u304a\u304f\n# ...\ncase $automode in # \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u8d77\u52d5\u4e2d\u304b\u7d42\u4e86\u4e2d\u304b\u3092\u5224\u65ad\n    'in'|'once')\n        if is_up_to_date $environment; then\n            if [ \"$monitoring\" = 'on' ]; then\n                state='ready'\n            else\n                state='up_to_date'\n            fi\n        else\n            state='update_available'\n        fi\n        case $state in\n            'update_available')\n                update $environment\n                retry=true\n                ;;\n            'up_to_date')\n                enable_monitoring\n                retry=true\n                ;;\n            'ready')\n                if [ \"$auto\" = \"once\" ]; then\n                    disable_automode\n                fi\n                service_in\n                ;;\n        esac\n        ;;\n    'out')\n        if is_finalized; then\n            state='finished'\n        else\n            state='finishing'\n        fi\n        case $state in\n            'finishing')\n                finalize $environment $role\n                retry=true\n                ;;\n            'finished')\n                service_out\n                ;;\n        esac\n        ;;\n    *)\n        log \"$automode \u304c\u7279\u5b9a\u306e\u5024\u3067\u306a\u3051\u308c\u3070\u4f55\u3082\u3057\u306a\u3044\"\n        ;;\nesac\n# ... retry \u51e6\u7406\u3001\u5931\u6557\u304c\u7d9a\u3044\u305f\u5834\u5408\u306e\u30a2\u30e9\u30fc\u30c8\u306a\u3069\ncritical_section_end\n<\/code><\/pre>\n<p>\u3053\u3061\u3089\u3067\u4f7f\u308f\u308c\u3066\u3044\u308b\u4e3b\u306a\u30b7\u30a7\u30eb\u95a2\u6570\u306e\u5b9f\u88c5\u6982\u8981\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li><code>is_up_to_date<code>: S3 \u306b\u3042\u308b\u6307\u5b9a\u30ea\u30d3\u30b8\u30e7\u30f3\u3068\u3001\u81ea\u8eab\u306e <code>deploy_to\/revisions.log<\/code>\u3092\u6bd4\u8f03<\/code><\/code><\/li>\n<li><code>update<code>: S3 \u306b\u3042\u308b <code>cap<\/code>\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3001<code>deploy_local=1<\/code> \u3067\u30c7\u30d7\u30ed\u30a4<\/code><\/code><\/li>\n<li><code>service_in<code>: ELB Health Check \u304c\u901a\u308b\u72b6\u614b\u306b\u3057\u3001cron \u306e\u9593\u9694\u8abf\u6574<\/code><\/code><\/li>\n<li><code>finalize<code>: \u30ed\u30b0\u30d0\u30c3\u30d5\u30a1\u306e flush \u306a\u3069\u3092\u5b9f\u884c<\/code><\/code><\/li>\n<li><code>is_finalized<code>: \u6b8b\u3063\u3066\u3044\u308b\u30ed\u30b0\u30d0\u30c3\u30d5\u30a1\u304c\u7121\u3044\u304b\u306a\u3069\u306e\u78ba\u8a8d<\/code><\/code><\/li>\n<li><code>service_out<code>: ASG \u306b Lifecycle Hook \u304c\u5b8c\u4e86\u3057\u305f\u3053\u3068\u3092\u4f1d\u3048\u308b (complete-lifecycle-action)<\/code><\/code><\/li>\n<\/ul>\n<p>\u7d42\u4e86\u4e2d\u304b\u3069\u3046\u304b\uff1f\u306e\u5224\u65ad\u306b\u306f\u3001\u5f8c\u8ff0\u3059\u308b Lifecycle Hook \u3092\u4f7f\u3044\u307e\u3059\u3002Lifecycle Hook \u306e\u72b6\u614b\u304c <code>Terminating:Wait<\/code> \u306b\u306a\u3063\u3066\u3044\u305f\u3089\u30b5\u30fc\u30d3\u30b9\u30a2\u30a6\u30c8\u3092\u793a\u3059\u72b6\u614b\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>cron \u30b9\u30af\u30ea\u30d7\u30c8\u304c\u3067\u304d\u305f\u3089\u3053\u308c\u3082 S3 \u306b\u5165\u308c\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h3>ASG \u3078\u7d44\u307f\u8fbc\u3080<\/h3>\n<p>ASG \u3078\u7d44\u307f\u8fbc\u3080\u306b\u306f\u3001Launch Configuration \u3067\u30e6\u30fc\u30b6\u30c7\u30fc\u30bf\u306b\u5148\u307b\u3069\u306e cron \u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8a2d\u5b9a\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<pre><code>#!\/bin\/bash\n\n\/usr\/local\/bin\/aws s3 sync s3:\/\/yourbucketname\/autolaunch\/scripts \/home\/deployuser\/scripts\n\nchown -R deployuser:deployuser \/home\/deployuser\/scripts\nchmod +x -R \/home\/deployuser\/scripts\/*.sh\n\n{\n    echo \"* * * * * deployuser \/home\/deployuser\/scripts\/main.sh\"\n} &gt; \/etc\/cron.d\/autolaunch<\/code><\/pre>\n<p>\u3053\u3053\u3067\u306e cron \u306f\u5206\u6bce\u306b\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u5148\u307b\u3069\u306e\u30b7\u30a7\u30eb\u95a2\u6570\u4e2d\u306e\u9077\u79fb\u304c\u843d\u3061\u7740\u3044\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u9593\u9694\u3092\u8abf\u6574\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u8d77\u52d5\u6642\u306f\u4ee5\u4e0a\u3067\u3059\u3002<\/p>\n<p>\u7d42\u4e86\u51e6\u7406\u306f Lifecycle Hook \u3092\u4f7f\u3044\u307e\u3059\u3002Lifecycle Hook \u306f 2016\/06\u00a0\u73fe\u5728\u3001Web \u30b3\u30f3\u30bd\u30fc\u30eb\u3067\u8a2d\u5b9a\u3067\u304d\u306a\u3044\u306e\u3067 CLI \u3067\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre><code>$ aws autoscaling put-lifecycle-hook \\\n  --lifecycle-hook-name AppFinalize \\\n  --auto-scaling-group-name yourgroupname \\\n  --lifecycle-transition autoscaling:EC2_INSTANCE_TERMINATING \\\n  --notification-target-arn arn:aws:sns:ap-northeast-1:************:yournotifyname \\\n  --role-arn arn:aws:iam::************:role\/YourAsgNotificationRole<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>Hook \u306e\u540d\u524d\u306f cron \u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u88c5\u3068\u5408\u308f\u305b\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u308c\u3067\u30b9\u30b1\u30fc\u30eb\u30a4\u30f3\u6642\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u7834\u68c4\u3055\u308c\u308b\u307e\u3048\u306b\u00a0<code>Terminating:Wait<\/code>\u00a0\u3067\u6b62\u307e\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30d5\u30ed\u30fc\u306e\u307e\u3068\u3081<\/h2>\n<p>\u3053\u3053\u307e\u3067\u3067\u3001\u672c\u7a3f\u30bf\u30a4\u30c8\u30eb\u3067\u3042\u308b\u300cCapistrano \u3067\u306f\u3058\u3081\u308b\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u300d\u306f\u5b9f\u73fe\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u4e00\u5ea6\u3001\u5b9f\u969b\u306e\u52d5\u4f5c\u3092\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u5e73\u5e38\u6642\n<ul>\n<li><code>cap<\/code> \u306e\u8a2d\u7f6e\u3055\u308c\u3066\u3044\u308b\u30b5\u30fc\u30d0\u304b\u3089\u30c7\u30d7\u30ed\u30a4<\/li>\n<li>\u30c7\u30d7\u30ed\u30a4\u6210\u529f\u6642\u3001<code>cap<\/code> \u30b3\u30fc\u30c9\u3068\u30ea\u30d3\u30b8\u30e7\u30f3\u3092 S3 \u306b\u4fdd\u5b58<\/li>\n<\/ul>\n<\/li>\n<li>ASG \u52d5\u4f5c\u6642\n<ul>\n<li>\u30b9\u30b1\u30fc\u30eb\u30a2\u30a6\u30c8\n<ul>\n<li>ASG \u304c\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u8d77\u52d5<\/li>\n<li>cloud-init (\u30e6\u30fc\u30b6\u30c7\u30fc\u30bf) \u3067 cron \u30b9\u30af\u30ea\u30d7\u30c8\u8a2d\u7f6e<\/li>\n<li>cron \u30b9\u30af\u30ea\u30d7\u30c8\u304c <code>cap<\/code> \u30b3\u30fc\u30c9\u3092\u4f7f\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u6700\u65b0\u306b<\/li>\n<li>\u6700\u65b0\u72b6\u614b\u306b\u306a\u3063\u305f\u3053\u3068\u3067 ELB Health Check \u3092 pass, \u30b5\u30fc\u30d3\u30b9\u958b\u59cb<\/li>\n<\/ul>\n<\/li>\n<li>\u30b9\u30b1\u30fc\u30eb\u30a4\u30f3\n<ul>\n<li>ASG \u304c\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u7d42\u4e86\u51e6\u7406\u958b\u59cb<\/li>\n<li>Lifecycle Hook \u304c\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u7d42\u4e86\u4e2d\u306b\u8a2d\u5b9a<\/li>\n<li>cron \u304c\u7d42\u4e86\u4e2d\u72b6\u614b\u3092\u691c\u77e5\u3001\u30ed\u30b0\u306e\u30d5\u30e9\u30c3\u30b7\u30e5\u306a\u3069\u7d42\u4e86\u51e6\u7406<\/li>\n<li>cron \u304c ASG \u306b\u51e6\u7406\u304c\u7d42\u308f\u3063\u305f\u3053\u3068\u3092\u901a\u77e5\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u7834\u68c4<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u6ce8\u610f\u70b9<\/h3>\n<p>\u9023\u7d9a\u7684\u306a\u5909\u5316\u3092\u4e3b\u5f35\u3057\u3066\u66f8\u3044\u3066\u304a\u308a\u307e\u3057\u305f\u304c\u3001\u4e00\u3064\u65e2\u5b58\u306e\u30d5\u30ed\u30fc\u3068\u4e92\u63db\u6027\u304c\u7121\u304f\u306a\u308b\u70b9\u304c\u3042\u308a\u307e\u3059\u3002 \u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u6642\u306b\u305d\u308c\u305e\u308c\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u500b\u5225\u306b\u30c7\u30d7\u30ed\u30a4\u3055\u308c\u308b\u305f\u3081\u3001Capistrano \u306e \"<code>#{deploy_to}\/releases\"<\/code> \u306e\u69cb\u6210\u304c\u30b0\u30eb\u30fc\u30d7\u3067\u7d71\u4e00\u3055\u308c\u306a\u304f\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001deploy:rollback \u304c\u5b9f\u8cea\u4f7f\u3048\u306a\u304f\u306a\u308b\u3053\u3068\u306b\u306f\u6ce8\u610f\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<h1>\u6b21\u306e\u30b9\u30c6\u30c3\u30d7<\/h1>\n<p>Capistrano \u3092\u4f7f\u3063\u305f\u65e2\u5b58\u306e\u4e2d\u592e\u7ba1\u7406\u578b\u30c7\u30d7\u30ed\u30a4\u3092\uff08\u307b\u307c\uff09\u6709\u52b9\u306b\u3057\u305f\u307e\u307e\u3001AWS \u3067\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3057\u305f\u3002\u3053\u306e\u5148\u306f\u904b\u7528\u5f62\u614b\u306b\u5fdc\u3058\u3066\u9032\u3080\u65b9\u5411\u3092\u8003\u3048\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>\u5206\u6563\u578b\u3078<\/h3>\n<p>\u975e\u5e38\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u306e\u53f0\u6570\u304c\u591a\u304f\u3001\u30c7\u30d7\u30ed\u30a4\u306e\u6642\u9593\u304c\u554f\u984c\u306b\u306a\u308b\u5834\u5408\u306f\u5206\u6563\u578b\u30c7\u30d7\u30ed\u30a4\u3092\u8003\u3048\u308b\u306e\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u90aa\u9053\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u3001CodeDeploy \u3092\u4f7f\u3046\u8a2d\u5b9a\u3092\u96d1\u306b\u66f8\u304f\u3068\u3059\u308b\u3068\u3001<code>cap<\/code> \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u8a2d\u7f6e\u3059\u308c\u3070\u3088\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre><code>$ cat scripts\/deploy.sh\n#!\/bin\/bash\n\nSCRIPT_ROOT=$(cd $(dirname $0) &amp;&amp; pwd -P) TOOLS_ROOT=$(dirname $SCRIPT_ROOT)\n(\n  cd $TOOLS_ROOT &amp;&amp; \\\n  bundle install \u2013path vendor\/bundle &amp;&amp; \\\n  bundle exec cap production deploy deploy_local=1 2&gt;&amp;1 | tee \/tmp\/deploy.log\n)\n\n$ cat appspec.yml\nversion: 0.0\nos: linux\nfiles:\n  - source: \/\n    destination: \/var\/tmp\/deploy\/local\npermissions:\n  - object: \/var\/tmp\/deploy\n    owner: deployuser\n    group: deployuser\nhooks:\n  AfterInstall:\n    - location: scripts\/cd_deploy.sh\n      timeout: 300\n      runas: deployuser\n  ApplicationStart:\n    - location: scripts\/atosyori.sh\n\n$ cat scripts\/cd_deploy.sh\n#!\/bin\/bash\n\/var\/tmp\/deploy\/local\/scripts\/deploy.sh<\/code><\/pre>\n<p>\u3053\u308c\u306f CodeDeploy \u3092\u4f7f\u3063\u3066\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u672c\u4f53\u3067\u306f\u306a\u304f <code>cap<\/code> \u3092\u914d\u308a\u5b9f\u884c\u3059\u308b\u8a2d\u5b9a\u3067\u3059\uff08\u304c\u3001\u5f0a\u793e\u3067\u306f\u5546\u7528\u74b0\u5883\u3067\u3053\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u74b0\u5883\u306f\u3042\u308a\u307e\u305b\u3093\uff09\u3002\u3042\u304f\u307e\u3067\u5206\u6563\u578b\u3078\u3046\u3064\u308b\u904e\u6e21\u671f\u3068\u3057\u3066\u3001 Capistrano \u3068\u306e\u30cf\u30a4\u30d6\u30ea\u30c3\u30c9\u3092\u7528\u3044\u308b\u3053\u3068\u3067\u3001CodeDeploy \u3084 Surf \/ Consul \u30d9\u30fc\u30b9\u306e\u30c7\u30d7\u30ed\u30a4\u30c4\u30fc\u30eb\u3068\u3044\u3063\u305f\u3001\u5b8c\u5168\u306a\u5206\u6563\u578b\u30c7\u30d7\u30ed\u30a4\u3078\u79fb\u308b\u305f\u3081\u306e\u5fc3\u7406\u7684\u969c\u58c1\u3092\u4e0b\u3052\u308b\u52b9\u679c\u306f\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30ec\u30dd\u30b8\u30c8\u30ea\u306e\u8ca0\u8377\u3092\u8efd\u6e1b\u3059\u308b<\/h3>\n<p>Capistrano \u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u3001\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u304b\u3089 GIT \u30ec\u30dd\u30b8\u30c8\u30ea\u3078\u30a2\u30af\u30bb\u30b9\u3057\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u53d6\u5f97\u3059\u308b\u52d5\u4f5c\u3092\u3057\u307e\u3059\u3002\u898f\u6a21\u304c\u81a8\u308c\u306a\u3044\u3046\u3061\u306f\u554f\u984c\u306b\u306a\u308a\u307e\u305b\u3093\u304c\u3001\u5206\u6563\u578b\u3092\u8003\u3048\u308b\u3088\u3046\u306a\u898f\u6a21\u306e\u5927\u304d\u3044\u30b1\u30fc\u30b9\u3067\u306f \u30ec\u30dd\u30b8\u30c8\u30ea\u30b5\u30fc\u30d0\u306e\u8ca0\u8377\u304c\u30cd\u30c3\u30af\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3057\u3001\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u306f SPOF \u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u70b9\u306b\u304a\u3044\u3066 AWS CodeDeploy \u3067\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092 ZIP \u30a2\u30fc\u30ab\u30a4\u30d6\u3068\u3057 S3 \u304b\u3089\u53d6\u5f97\u3055\u305b\u308b\u3053\u3068\u3067\u3001S3 \u306e\u53ef\u7528\u6027\u3068\u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3\u3092\u6d3b\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5f0a\u793e\u3067\u306f\u3001Capistrano \u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3068\u3057\u3066<\/p>\n<ul>\n<li>Capistrano \u306e deploy \u30d5\u30ed\u30fc\u3067\u914d\u5e03\u3057\u305f\u30b3\u30fc\u30c9\u304b\u3089 ZIP \u3092\u4f5c\u6210\u3057\u3066 S3 \u306b\u4e0a\u3052\u308b gem<\/li>\n<li>S3 \u304b\u3089 ZIP \u3092\u53d6\u5f97\u3057 <code>deploy<\/code> \u3067\u914d\u5e03\u3059\u308b gem<\/li>\n<\/ul>\n<p>\u3092\u4f5c\u6210\u3057\u3001S3 \u3092\u7d4c\u7531\u3057\u305f\u30c7\u30d7\u30ed\u30a4\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u4e2d\u592e\u7ba1\u7406\u578b\u3092\u4f7f\u3044\u7d9a\u3051\u308b<\/h3>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u306e\u53f0\u6570\u304c\u591a\u304f\u306a\u304f\u3001\u4e2d\u592e\u7ba1\u7406\u578b\u306e\u30c7\u30d7\u30ed\u30a4\u6642\u9593\u304c\u554f\u984c\u306b\u306a\u3063\u3066\u3044\u306a\u3044\u306e\u3067\u3042\u308c\u3070\u3001\u7121\u7406\u306b\u5206\u6563\u578b\u3092\u53d6\u308a\u5165\u308c\u308b\u5fc5\u8981\u6027\u306f\u4f4e\u3044\u304b\u3068\u601d \u3044\u307e\u3059\u3002<\/p>\n<p>\u500b\u4eba\u7684\u306b\u306f\u3001\u5c0f\u3055\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b0\u30eb\u30fc\u30d7\u306e\u30d5\u30ed\u30fc\u306b\u304a\u3044\u3066\u306f\u4e2d\u592e\u7ba1\u7406\u578b\u306e\u65b9\u304c\u624b\u8efd\u3067\u9069\u3057\u3066\u3044\u308b\u3068\u8003\u3048\u3066\u3044\u307e\u3059\u3002\u5b9f\u969b\u3001\u6700\u8fd1\u306e\u5f0a\u793e\u30b5\u30fc\u30d3\u30b9\u3067\u306f \u5c0f\u898f\u6a21\u591a\u6570\u306e\u69cb\u6210\u3078\u3068\u5909\u5316\u3057\u3066\u304d\u3066\u304a\u308a\u3001\u591a\u69d8\u306a\u8981\u4ef6\u306b\u5bfe\u5fdc\u3059\u308b\u305f\u3081\u306b\u500b\u5225\u306e Capistrano \u30ec\u30dd\u30b8\u30c8\u30ea\u304c\u591a\u304f\u751f\u307e\u308c\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<h3>AWS \u4ee5\u5916\u3067\u9069\u7528\u3059\u308b<\/h3>\n<p>\u5192\u982d\u3067\u66f8\u304d\u307e\u3057\u305f\u3088\u3046\u306b\u672c\u7a3f\u3067\u306f AWS \u3092\u524d\u63d0\u3068\u3057\u3066\u8a2d\u5b9a\u3092\u884c\u3063\u3066\u304a\u308a\u3001AWS \u3092\u6d3b\u7528\u3057\u3066\u3044\u308b\u306e\u306f\u4ee5\u4e0b\u306e\u70b9\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u6761\u4ef6\u306b\u5fdc\u3058\u3066\u81ea\u52d5\u7684\u306b\u8d77\u52d5\u3001\u7d42\u4e86 (ASG)\n<ul>\n<li>\u8d77\u52d5\u3001\u7d42\u4e86\u6642\u306b\u30e6\u30fc\u30b6\u30d5\u30c3\u30af\u304c\u633f\u5165\u53ef\u80fd (ASG, Lifecycle Hook)<\/li>\n<\/ul>\n<\/li>\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304b\u3089\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u306a\u9ad8\u53ef\u7528\u6027\u306e\u30b9\u30c8\u30ec\u30fc\u30b8 (S3)<\/li>\n<li>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u8a2d\u5b9a\u53ef\u80fd\u306a\u30e1\u30bf\u30c7\u30fc\u30bf (EC2 \u30bf\u30b0)<\/li>\n<\/ul>\n<p>\u3053\u308c\u3089\u3068\u540c\u69d8\u306e\u6a5f\u80fd\u304c\u4f7f\u3048\u308b\u30a4\u30f3\u30d5\u30e9\u3067\u3042\u308c\u3070\u3001\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u90e8\u5206\u306e\u5bfe\u5fdc\u3067\u6d41\u7528\u306f\u53ef\u80fd\u3068\u8003\u3048\u307e\u3059\u3002<\/p>\n<h1>\u3055\u3044\u3054\u306b<\/h1>\n<p>\u5148\u306b\u3082\u5c11\u3057\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u7406\u60f3\u3068\u73fe\u5b9f\u3068\u306e\u9593\u306b\u5370\u8c61\u7684\u306a\u5909\u5316\u304c\u3042\u308b\u5834\u5408\u306b\u306f\u3001\u5fc3\u7406\u7684\u306a\u969c\u58c1\u304c\u751f\u307e\u308c\u3084\u3059\u304f\u4f59\u8a08\u306a\u529b\u304c\u50cd\u3044\u3066\u3057\u307e\u3046\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u95a2\u4fc2\u8005\u304c\u601d\u3046\u4e0d\u9023\u7d9a\u306a\u7b87\u6240\u306f\u3069\u3053\u306a\u306e\u304b\uff1f\u306b\u6ce8\u76ee\u3057\u3001\u9023\u7d9a\u7684\u306a\u5909\u5316\u3092\u91cd\u306d\u308b\u3053\u3068\u3067\u5b89\u5168\u304b\u3064\u30b9\u30e0\u30fc\u30ba\u306a\u79fb\u884c\u3092\u9032\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u8003\u3048\u307e\u3059\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u30a4\u30f3\u30d5\u30e9\u306e\u99d2\u5d0e\u3067\u3059\u3002 Capistrano \u3092\u4f7f\u3063\u305f\u30c7\u30d7\u30ed\u30a4\u304b\u3089\u3001\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u3092\u30b9\u30e0\u30fc\u30ba\u306b\u5c0e\u5165\u3059\u308b\u305f\u3081\u306e\u5f0a\u793e\u4e8b\u4f8b\u3092\u7d39\u4ecb\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u3053\u3093\u306a\u65b9\u3078 \u672c\u7a3f\u3067\u60f3\u5b9a\u3059\u308b\u306e\u306f\u3053\u306e\u3088\u3046\u306a\u72b6\u6cc1\u3067\u3059\u3002 Capist [&hellip;]<\/p>\n","protected":false},"author":158,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[114,61,171],"class_list":["post-16044","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-info","tag-aws","tag-capistrano","tag-info"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/16044","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/users\/158"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/comments?post=16044"}],"version-history":[{"count":3,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/16044\/revisions"}],"predecessor-version":[{"id":16070,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/posts\/16044\/revisions\/16070"}],"wp:attachment":[{"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/media?parent=16044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/categories?post=16044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labs.gree.jp\/blog\/wp-json\/wp\/v2\/tags?post=16044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}