{"id":6043,"date":"2022-06-06T21:25:27","date_gmt":"2022-06-06T13:25:27","guid":{"rendered":"http:\/\/123.57.164.21\/?p=6043"},"modified":"2022-06-06T21:25:27","modified_gmt":"2022-06-06T13:25:27","slug":"%e4%bd%bf%e7%94%a8-aws-codepipeline-%e6%9d%a5%e6%9b%b4%e6%96%b0-ec2-%e4%b8%8a%e9%9d%a2%e7%9a%84%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=6043","title":{"rendered":"\u4f7f\u7528 AWS CodePipeline \u6765\u66f4\u65b0 EC2 \u4e0a\u9762\u7684\u4ee3\u7801"},"content":{"rendered":"\n<p>\u8f6c\u8f7d\uff1ahttps:\/\/blog.csdn.net\/wangzan18\/article\/details\/105011866<\/p>\n\n\n\n<p><strong>\u4e00\u3001\u80cc\u666f\u4ecb\u7ecd<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5047\u5b9a\u6211\u4eec\u6709\u4e00\u4e2a PHP \u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u4ee3\u7801\u53d1\u5e03\u4e0d\u9700\u8981\u8fdb\u884c\u7f16\u8bd1\uff0c\u5e94\u7528\u7a0b\u5e8f\u5728 <a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=AWS&amp;spm=1001.2101.3001.7020\" target=\"_blank\">AWS<\/a> \u7684 EC2 \u4e0a\u9762\u6216\u8005 On-Premises\uff0c\u5728\u5b9e\u73b0 CI\/CD \u7684\u65b9\u5f0f\u4e0a\u9762\u6709\u5f88\u591a\u65b9\u6cd5\uff0c\u90a3\u6211\u4eec\u5982\u4f55\u5229\u7528 AWS \u7684 Develop Tooles \u53bb\u5b9e\u73b0\u5462\uff1f<\/p>\n\n\n\n<p>\u5728\u8fd9\u91cc\uff0c\u6211\u9996\u5148\u4ecb\u7ecd\u4e00\u4e0b\u6211\u4eec\u53ef\u80fd\u4f1a\u7528\u5230\u7684 AWS \u670d\u52a1\uff1a<\/p>\n\n\n\n<ul><li>IAM\uff1a\u914d\u7f6e CodeDeploy\uff0cCodePipeline \u76f8\u5173\u7684\u6743\u9650\uff1b<\/li><li>CodeCommit\uff1a\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u5b58\u50a8\u5e93\uff1b<\/li><li>CodeDeploy\uff1aEC2\/On-premises \u5e73\u53f0\u7684\u5e94\u7528\u90e8\u7f72\u7a0b\u5e8f\uff1b<\/li><li>S3\uff1aCodePipeline \u8fc7\u7a0b\u4e2d\u6587\u4ef6\u7684\u5b58\u50a8\u4f4d\u7f6e\uff0c\u4e3a\u6574\u4e2a pipeline \u8fc7\u7a0b\u63d0\u4f9b\u6587\u4ef6\u6765\u6e90\uff1b<\/li><li>CodePipeline\uff1a\u7ba1\u7406\u6574\u4e2a pipeline \u8fc7\u7a0b\u3002<\/li><li>Amazon EC2\uff1a\u5e94\u7528\u7a0b\u5e8f\u5b58\u653e\u7684\u670d\u52a1\u5668\u3002<\/li><\/ul>\n\n\n\n<p><strong>\u4e8c\u3001\u914d\u7f6e EC2<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>2.1 \u4e3a EC2 \u521b\u5efa Service role<\/strong><\/p>\n\n\n\n<p>\u56e0\u4e3a\u5728\u6574\u4e2a CI\/CD \u8fc7\u7a0b\u4e2d\uff0cEC2 \u670d\u52a1\u5668\u9700\u8981\u4ece S3 \u83b7\u53d6\u8d44\u6e90\uff0c\u6211\u4eec\u8fd9\u91cc\u5c31\u7d22\u6027\u7ed9\u4e86AmazonS3FullAccess\u3002<\/p>\n\n\n\n<p>https:\/\/docs.aws.amazon.com\/zh_cn\/codedeploy\/latest\/userguide\/getting-started-create-iam-instance-profile.html#getting-started-create-iam-instance-profile-console<\/p>\n\n\n\n<p><strong>2.2 \u4e3a EC2 \u5b89\u88c5 CodeDeploy Agent<\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u7684 EC2 \u7cfb\u7edf\u662f Amazon Linux 2\uff0c\u5b89\u88c5\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo yum update -y\nsudo yum install ruby -y\nsudo yum install wget -y\ncd \/home\/ec2-user\nwget https:\/\/aws-codedeploy-us-east-2.s3.us-east-2.amazonaws.com\/latest\/install\nchmod +x .\/install\nsudo .\/install auto\nsudo service codedeploy-agent status<\/pre>\n\n\n\n<p>\u5982\u679c\u662f\u5176\u4ed6\u7cfb\u7edf\u7684\u5b89\u88c5\uff0c\u5927\u5bb6\u53ef\u4ee5\u53c2\u7167\u5b98\u65b9\u6587\u6863\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.aws.amazon.com\/zh_cn\/codedeploy\/latest\/userguide\/codedeploy-agent-operations-install.html\">https:\/\/docs.aws.amazon.com\/zh_cn\/codedeploy\/latest\/userguide\/codedeploy-agent-operations-install.html<\/a><\/p>\n\n\n\n<p><strong>2.3 \u5b89\u88c5 nginx<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">yum install nginx -y<\/pre>\n\n\n\n<p><strong>\u4e09\u3001\u914d\u7f6e CodeCommit<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>3.1 \u521b\u5efa\u4ed3\u5e93<\/strong><\/p>\n\n\n\n<p>\u9009\u62e9\u597d\u6211\u4eec\u7684\u533a\u57df\uff0c\u6253\u5f00 CodeCommit \u63a7\u5236\u53f0\uff0c\u70b9\u51fb\u521b\u5efa\u4ee3\u7801\u4ed3\u5e93\uff0c\u5bf9\u4e8e Java \u7a0b\u5e8f\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u542f\u4ee3\u7801\u68c0\u6d4b\u529f\u80fd\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1024x876.png\" alt=\"\" class=\"wp-image-6045\" width=\"488\" height=\"416\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1024x876.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-300x257.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-768x657.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-830x710.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-230x197.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-350x299.png 350w\" sizes=\"(max-width: 488px) 100vw, 488px\" \/><\/figure><\/div>\n\n\n\n<p><br>\u5173\u4e8e\u4e3a CodeCommit \u914d\u7f6e IAM User\uff0c\u6211\u8fd9\u91cc\u5c31\u4e0d\u518d\u8bf4\u4e86\uff0c\u5927\u5bb6\u53ef\u4ee5\u53c2\u52a0\u5b98\u65b9\u6587\u6863\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.aws.amazon.com\/zh_cn\/codecommit\/latest\/userguide\/setting-up-gc.html\">https:\/\/docs.aws.amazon.com\/zh_cn\/codecommit\/latest\/userguide\/setting-up-gc.html<\/a><\/p>\n\n\n\n<p><strong>3.2 \u63d0\u4ea4\u4ee3\u7801<\/strong><\/p>\n\n\n\n<p>\u53ea\u662f\u4e3a\u4e86\u6f14\u793a\uff0c\u7b2c\u4e00\u6b65\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a index.html \u6587\u4ef6\uff0c\u5199\u4e0a\u5982\u4e0b\u5185\u5bb9\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;h1>this is test one&lt;\/h1><\/pre>\n\n\n\n<p>\u7136\u540e\u4e0a\u4f20\u5230\u4ed3\u5e93\u4e2d\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ git add .\n \n$ git commit -m \"one\"\n[master (root-commit) 969e50f] one\n 1 file changed, 1 insertion(+)\n create mode 100644 index.html\n \n$ git push origin master\nEnumerating objects: 3, done.\nCounting objects: 100% (3\/3), done.\nWriting objects: 100% (3\/3), 230 bytes | 230.00 KiB\/s, done.\nTotal 3 (delta 0), reused 0 (delta 0)\nTo https:\/\/git-codecommit.us-east-2.amazonaws.com\/v1\/repos\/www.wzlinux.com\n * [new branch]      master -> master<\/pre>\n\n\n\n<p><strong>\u56db\u3001\u914d\u7f6e CodeDeploy<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>CodeDeploy \u662f\u4e00\u9879\u90e8\u7f72\u670d\u52a1\uff0c\u53ef\u4ee5\u5411 Amazon EC2 \u5b9e\u4f8b\u3001\u672c\u5730\u5b9e\u4f8b\u3001\u65e0\u670d\u52a1\u5668 Lambda \u51fd\u6570\u6216 Amazon ECS \u670d\u52a1\u81ea\u52a8\u6267\u884c\u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72\uff0c\u5728 EC2 \u5e73\u53f0\u4e0a\u9762\u7684\u90e8\u7f72\u7ec4\u4ef6\u5982\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1.png\" alt=\"\" class=\"wp-image-6046\" width=\"454\" height=\"281\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1.png 960w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1-300x186.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1-768x477.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1-830x515.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1-230x143.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1-350x217.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-1-480x298.png 480w\" sizes=\"(max-width: 454px) 100vw, 454px\" \/><\/figure><\/div>\n\n\n\n<p>\u90e8\u7f72\u5de5\u4f5c\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-2.png\" alt=\"\" class=\"wp-image-6047\" width=\"274\" height=\"360\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-2.png 500w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-2-229x300.png 229w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-2-230x302.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-2-350x459.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-2-480x630.png 480w\" sizes=\"(max-width: 274px) 100vw, 274px\" \/><\/figure><\/div>\n\n\n\n<p><strong>4.1 \u4e3a CodeDeploy \u521b\u5efa Service role<\/strong><\/p>\n\n\n\n<p>\u4e3a CodeDeploy \u521b\u5efa\u7684\u670d\u52a1\u89d2\u8272\u5fc5\u987b\u6388\u4e88\u5bf9\u60a8\u7684\u8ba1\u7b97\u5e73\u53f0\u6240\u9700\u7684\u6743\u9650\uff0c\u5bf9\u4e8e EC2\/\u672c\u5730 \u90e8\u7f72\uff0c\u9644\u52a0 <code>AWSCodeDeployRole<\/code> \u7b56\u7565\uff0c\u8bf7\u770b\u6211\u521b\u5efa\u7684\u89d2\u8272\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-3-1024x653.png\" alt=\"\" class=\"wp-image-6048\" width=\"492\" height=\"313\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-3-1024x653.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-3-300x191.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-3-768x489.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-3-830x529.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-3-230x147.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-3-350x223.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-3-480x306.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-3.png 1456w\" sizes=\"(max-width: 492px) 100vw, 492px\" \/><\/figure><\/div>\n\n\n\n<p>\u5173\u4e8e\u66f4\u65b0\u8be6\u7ec6\u7684\u8fc7\u7a0b\uff0c\u5927\u5bb6\u8bf7\u67e5\u770b\u5b98\u65b9\u6587\u6863\uff1a<\/p>\n\n\n\n<p>https:\/\/docs.aws.amazon.com\/zh_cn\/codedeploy\/latest\/userguide\/getting-started-create-service-role.html#getting-started-create-service-role-console<br><\/p>\n\n\n\n<p><strong>4.2 \u521b\u5efa Applications<\/strong><\/p>\n\n\n\n<p>\u914d\u7f6e\u5b9e\u4f8b\u540e\uff0c\u5fc5\u987b\u5148\u5728 CodeDeploy \u4e2d\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f\uff0c\u7136\u540e\u624d\u80fd\u90e8\u7f72\u4fee\u8ba2(<a href=\"https:\/\/docs.aws.amazon.com\/zh_cn\/codedeploy\/latest\/userguide\/application-revisions-appspec-file.html#add-appspec-file-server\">appspec.yaml<\/a>)\u3002\u5e94\u7528\u7a0b\u5e8f \u53ea\u662f\u4e00\u4e2a\u540d\u79f0\u6216\u5bb9\u5668\uff0cCodeDeploy \u4f7f\u7528\u6b64\u540d\u79f0\u6216\u5bb9\u5668\u6765\u786e\u4fdd\u5728\u90e8\u7f72\u671f\u95f4\u5f15\u7528\u6b63\u786e\u7684\u4fee\u8ba2\u3001\u90e8\u7f72\u914d\u7f6e\u548c\u90e8\u7f72\u7ec4\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-4-1024x571.png\" alt=\"\" class=\"wp-image-6049\" width=\"509\" height=\"283\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-4-1024x571.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-4-300x167.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-4-768x429.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-4-830x463.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-4-230x128.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-4-350x195.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-4-480x268.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-4.png 1344w\" sizes=\"(max-width: 509px) 100vw, 509px\" \/><\/figure><\/div>\n\n\n\n<p><strong>4.3 \u521b\u5efa Deployment groups<\/strong><\/p>\n\n\n\n<p>\u53ef\u4ee5\u4e3a CodeDeploy \u5e94\u7528\u7a0b\u5e8f\u6307\u5b9a\u4e00\u4e2a\u6216\u591a\u4e2a\u90e8\u7f72\u7ec4\u3002\u6bcf\u4e2a\u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72\u4f7f\u7528\u5176\u4e2d\u4e00\u4e2a\u90e8\u7f72\u7ec4\u3002\u90e8\u7f72\u7ec4\u5305\u542b\u5728\u90e8\u7f72\u671f\u95f4\u4f7f\u7528\u7684\u8bbe\u7f6e\u548c\u914d\u7f6e\u3002\u5927\u591a\u6570\u90e8\u7f72\u7ec4\u8bbe\u7f6e\u53d6\u51b3\u4e8e\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u7684\u8ba1\u7b97\u5e73\u53f0\u3002\u53ef\u4ee5\u4e3a\u4efb\u4f55\u8ba1\u7b97\u5e73\u53f0\u7684\u90e8\u7f72\u7ec4\u914d\u7f6e\u67d0\u4e9b\u8bbe\u7f6e\uff0c\u4f8b\u5982\u56de\u6eda\u3001\u89e6\u53d1\u5668\u548c\u8b66\u62a5\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u4e3a\u9879\u76eewww.wzlinux.com\u521b\u5efa\u4e00\u4e2a\u90e8\u7f72\u7ec4\uff0c\u6211\u4e00\u822c\u90fd\u662f\u4ee5\u8bbf\u95ee\u7684\u57df\u540d\u8fdb\u884c\u547d\u540d\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-5-1024x836.png\" alt=\"\" class=\"wp-image-6050\" width=\"519\" height=\"423\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-5-1024x836.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-5-300x245.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-5-768x627.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-5-830x678.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-5-230x188.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-5-350x286.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-5-480x392.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-5.png 1340w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/figure><\/div>\n\n\n\n<p>\u90e8\u7f72\u65b9\u5f0f\u6211\u4eec\u9009\u62e9\u5c31\u5730\u90e8\u7f72\uff0c\u7136\u540e\u901a\u8fc7 tag \u6807\u7b7e\u9009\u62e9\u6211\u4eec\u7684\u76ee\u6807\u670d\u52a1\u5668\uff0c\u6211\u4eec\u8fd9\u91cc\u662f EC2\uff0c\u5982\u679c\u662f <a href=\"https:\/\/docs.aws.amazon.com\/zh_cn\/codedeploy\/latest\/userguide\/instances-on-premises.html\">On-premises instances<\/a> \u7684\u673a\u5668\uff0c\u6211\u4eec\u9700\u8981\u5148\u53bb\u6ce8\u518c\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6-1020x1024.png\" alt=\"\" class=\"wp-image-6051\" width=\"556\" height=\"558\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6-1020x1024.png 1020w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6-300x300.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6-150x150.png 150w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6-768x771.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6-830x833.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6-230x231.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6-350x351.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6-480x482.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-6.png 1154w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/figure><\/div>\n\n\n\n<p>\u6211\u4eec\u8fd9\u91cc\u5c31\u4e0d\u662f\u6709 ALB\u4e86\uff0c\u53d6\u6d88\u52fe\u9009\uff0c\u5176\u4ed6\u9009\u9879\u9ed8\u8ba4\u5373\u53ef\uff0c\u6211\u4eec\u70b9\u51fb\u521b\u5efa\u3002<\/p>\n\n\n\n<p><strong>4.4 \u521b\u5efa Application Revisions<\/strong><\/p>\n\n\n\n<p>\u4fee\u8ba2\u5305\u542b CodeDeploy \u5c06\u90e8\u7f72\u5230\u5b9e\u4f8b\u7684\u6e90\u6587\u4ef6\u7248\u672c\u6216\u8005 CodeDeploy \u5c06\u5728\u5b9e\u4f8b\u4e0a\u8fd0\u884c\u7684\u811a\u672c\u3002<\/p>\n\n\n\n<p>\u60a8\u89c4\u5212\u4fee\u8ba2\u3001\u5c06 AppSpec file \u6dfb\u52a0\u5230\u4fee\u8ba2\uff0c\u7136\u540e\u5c06\u4fee\u8ba2\u63a8\u9001\u5230 Amazon S3 \u6216 GitHub\u3002\u5728\u63a8\u9001\u4fee\u8ba2\u4e4b\u540e\uff0c\u60a8\u53ef\u4ee5\u90e8\u7f72\u5b83\uff0c\u76ee\u524d\u4e0d\u652f\u6301\u4ece CodeCommit \u83b7\u53d6\u4fee\u8ba2\uff0c\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u5229\u7528 CodePipeline\uff0c\u540e\u9762\u6211\u4eec\u518d\u8bf4\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6ca1\u6709 AppSpec file\uff0cCodeDeploy \u65e0\u6cd5\u5c06\u5e94\u7528\u7a0b\u5e8f\u4fee\u8ba2\u4e2d\u7684\u6e90\u6587\u4ef6\u6620\u5c04\u5230\u5176\u76ee\u6807\uff0c\u4e5f\u65e0\u6cd5\u4e3a\u60a8\u5411 EC2\/\u672c\u5730 \u8ba1\u7b97\u5e73\u53f0\u4e2d\u8fdb\u884c\u7684\u90e8\u7f72\u8fd0\u884c\u811a\u672c\u3002<\/p>\n\n\n\n<p><br><strong>1 \u89c4\u5212\u4ed3\u5e93\u7ed3\u6784<\/strong><\/p>\n\n\n\n<p>\u73b0\u5728\u6211\u4eec\u8981\u89c4\u5212\u4e00\u4e0b\u4ed3\u5e93\u4ee3\u7801\u7684\u7ed3\u6784\u4e86\uff0c\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    \u251c\u2500\u2500 appspec.yml\n    \u251c\u2500\u2500 htdocs\n    \u2502   \u2514\u2500\u2500 index.html\n    \u2514\u2500\u2500 scripts\n        \u2514\u2500\u2500 update.sh<\/pre>\n\n\n\n<ul><li><strong>appspec.yaml<\/strong>\uff1a\u7528\u4e8e\u90e8\u7f72\u7684\u4fee\u8ba2\u6587\u4ef6\uff1b<\/li><li><strong>htdocs<\/strong>\uff1a\u5b58\u653e\u7f51\u7ad9\u4ee3\u7801\u7684\u6587\u4ef6\u5939\uff1b<\/li><li><strong>scripts<\/strong>\uff1a\u90e8\u7f72\u8fc7\u7a0b\u4e2d\u9700\u8981\u7684\u811a\u672c\u6587\u4ef6\u5b58\u653e\u6587\u4ef6\u5939\u3002<\/li><\/ul>\n\n\n\n<p><strong>2 \u521b\u5efa appspec.yml<\/strong><\/p>\n\n\n\n<p>\u6211\u8fd9\u91cc\u7b80\u5355\u5199\u4e00\u4e2a<a href=\"https:\/\/docs.aws.amazon.com\/zh_cn\/codedeploy\/latest\/userguide\/reference-appspec-file-example.html#appspec-file-example-server\">\u793a\u4f8b\u6587\u4ef6<\/a>\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">version: 0.0\nos: linux\nfiles:\n  - source: htdocs\n    destination: \/usr\/share\/nginx\/html\nhooks:\n  AfterInstall:\n    - location: scripts\/update.sh\n      timeout: 60\n<\/pre>\n\n\n\n<p>\u4ee5\u9012\u5f52\u65b9\u5f0f\u5c06 <code>htdocs<\/code> \u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u590d\u5236\u5230 <code>\/usr\/share\/nginx\/html<\/code> \u76ee\u5f55\u4e2d\u3002<\/p>\n\n\n\n<p>\u8fd0\u884c\u4f4d\u4e8e <code>scripts\/update.sh<\/code> \u4e2d\u7684\u811a\u672c\uff0c\u8d85\u65f6\u65f6\u95f4\u4e3a 60 \u79d2\u3002<\/p>\n\n\n\n<p>\u66f4\u591a\u76f8\u5173\u914d\u7f6e\u4fe1\u606f\u8bf7\u53c2\u7167\u5b98\u65b9\u6587\u6863\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.aws.amazon.com\/zh_cn\/codedeploy\/latest\/userguide\/application-revisions-appspec-file.html#add-appspec-file-server\">https:\/\/docs.aws.amazon.com\/zh_cn\/codedeploy\/latest\/userguide\/application-revisions-appspec-file.html#add-appspec-file-server<\/a><\/p>\n\n\n\n<p><strong>3 \u521b\u5efa update.sh<\/strong><\/p>\n\n\n\n<p>\u811a\u672c\u6211\u5c31\u7b80\u5355\u5199\u4e86\u4e00\u4e2a\u6dfb\u52a0\u65f6\u95f4\u7684\u8bb0\u5f55\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\necho Build time is $(date '+%Y-%m-%d %H:%M:%S') >> \/usr\/share\/nginx\/html\/index.html<\/pre>\n\n\n\n<p>\u8fd9\u6837\u6bcf\u6b21\u9875\u9762\u4e0a\u90fd\u6709\u90e8\u7f72\u7684\u65f6\u95f4\uff0c\u5927\u5bb6\u6709\u4ec0\u4e48\u9700\u8981\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u9700\u6c42\u8fdb\u884c\u586b\u5199\u3002<\/p>\n\n\n\n<p><strong>\u4e94\u3001\u914d\u7f6e CodePipeline<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>AWS CodePipeline \u662f\u4e00\u79cd\u6301\u7eed\u4ea4\u4ed8\u670d\u52a1\uff0c\u53ef\u7528\u4e8e\u5efa\u6a21\u3001\u53ef\u89c6\u5316\u548c\u81ea\u52a8\u6267\u884c\u53d1\u5e03\u8f6f\u4ef6\u6240\u9700\u7684\u6b65\u9aa4\u3002\u60a8\u53ef\u4ee5\u5feb\u901f\u5bf9\u8f6f\u4ef6\u53d1\u5e03\u8fc7\u7a0b\u7684\u4e0d\u540c\u9636\u6bb5\u8fdb\u884c\u5efa\u6a21\u548c\u914d\u7f6e\u3002CodePipeline \u4f1a\u81ea\u52a8\u6267\u884c\u6301\u7eed\u53d1\u5e03\u8f6f\u4ef6\u66f4\u6539\u6240\u9700\u7684\u6b65\u9aa4\u3002<\/p>\n\n\n\n<p><strong>5.1 \u914d\u7f6e<\/strong><\/p>\n\n\n\n<p>\u670d\u52a1\u89d2\u8272\u6211\u4eec\u9009\u62e9\u8ba9 Codepipeline \u521b\u5efa\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-7-937x1024.png\" alt=\"\" class=\"wp-image-6052\" width=\"432\" height=\"471\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-7-937x1024.png 937w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-7-274x300.png 274w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-7-230x251.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-7-350x383.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-7.png 1028w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/><\/figure><\/div>\n\n\n\n<p><strong>5.2 \u6dfb\u52a0\u6570\u636e\u6e90<\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u8fd9\u91cc\u9009\u62e9 CodeCommit\uff0cpipeline \u8fd8\u652f\u6301 ECR\u3001S3\u3001Bitbucket\u3001Github\u4f5c\u4e3a\u6570\u636e\u6e90\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-8-1024x799.png\" alt=\"\" class=\"wp-image-6053\" width=\"449\" height=\"350\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-8-1024x799.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-8-300x234.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-8-768x599.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-8-830x648.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-8-230x180.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-8-350x273.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-8-480x375.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-8.png 1030w\" sizes=\"(max-width: 449px) 100vw, 449px\" \/><\/figure><\/div>\n\n\n\n<p><strong>5.3 \u6dfb\u52a0\u90e8\u7f72<\/strong><\/p>\n\n\n\n<p>\u56e0\u4e3a\u6211\u4eec\u6211\u4eec\u662f\u4e0d\u9700\u8981\u7f16\u8bd1\u7684\u6587\u4ef6\uff0c\u6240\u4ee5\u4e0d\u9700\u8981 CodeBuild \u8fd9\u4e00\u9636\u6bb5\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-9-1024x913.png\" alt=\"\" class=\"wp-image-6054\" width=\"443\" height=\"394\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-9-1024x913.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-9-300x267.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-9-768x684.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-9-830x740.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-9-230x205.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-9-350x312.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-9-480x428.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-9.png 1030w\" sizes=\"(max-width: 443px) 100vw, 443px\" \/><\/figure><\/div>\n\n\n\n<p>CodePipeline \u8fd8\u652f\u6301\u4e00\u4e0b\u51e0\u79cd\u90e8\u7f72\u7a0b\u5e8f\uff1a<\/p>\n\n\n\n<ul><li><strong>CodeDeploy<\/strong><\/li><li><strong>AWS Elastic Beanstalk<\/strong><\/li><li><strong>AWS OpsWorks Stacks<\/strong><\/li><li><strong>AWS CloudFormation<\/strong><\/li><li><strong>Amazon ECS<\/strong><\/li><li><strong>Amazon ECS\uff08\u84dd\/\u7eff\uff09<\/strong><\/li><li><strong>AWS Service Catalog<\/strong><\/li><li><strong>Alexa Skills Kit<\/strong><\/li><li><strong>Amazon S3<\/strong><\/li><\/ul>\n\n\n\n<p><strong>\u516d\u3001\u9a8c\u8bc1<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u521b\u5efa\u597d\u4e86\uff0c\u6211\u4eec\u5c31\u4e0a\u4f20\u4ee3\u7801\u5427<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-10.png\" alt=\"\" class=\"wp-image-6055\" width=\"497\" height=\"539\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-10.png 938w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-10-276x300.png 276w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-10-768x834.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-10-830x901.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-10-230x250.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-10-350x380.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-10-480x521.png 480w\" sizes=\"(max-width: 497px) 100vw, 497px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-11.png\" alt=\"\" class=\"wp-image-6056\" width=\"500\" height=\"278\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-11.png 910w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-11-300x167.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-11-768x429.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-11-830x463.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-11-230x128.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-11-350x195.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/06\/\u56fe\u7247-11-480x268.png 480w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\uff1ahttps:\/\/blog.csdn.net\/wangzan18\/article\/details\/1050 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6043"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6043"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6043\/revisions"}],"predecessor-version":[{"id":6057,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6043\/revisions\/6057"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}