{"id":669,"date":"2020-08-20T07:11:41","date_gmt":"2020-08-19T22:11:41","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2020\/08\/20\/blue_green_deployment_eb_cli"},"modified":"2020-08-20T07:11:41","modified_gmt":"2020-08-19T22:11:41","slug":"blue_green_deployment_eb_cli","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2020\/08\/20\/blue_green_deployment_eb_cli\/","title":{"rendered":"AWS Elastic Beanstalk\u3092\u4f7f\u3063\u305fBlue-Green Deployment"},"content":{"rendered":"
\u4eca\u56de\u306f\u3001Blue-Green Deployment(\u30d6\u30eb\u30fc\u30b0\u30ea\u30fc\u30f3\u30c7\u30d7\u30ed\u30a4\u30e1\u30f3\u30c8)\u3092\u3001AWS Elastic Beanstalk<\/a>\u3092\u4f7f\u3063\u3066\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002 <\/p>\n \u540c\u7b49\u306e\u74b0\u5883\u30922\u3064\u7528\u610f\u3057\u3066\u3001\u30ea\u30ea\u30fc\u30b9\u6642\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u5148\u3092\u5207\u308a\u66ff\u3048\u308b\u3053\u3068\u3067\u3001\u30c0\u30a6\u30f3\u30bf\u30a4\u30e0\u3092\u307b\u307c\u30bc\u30ed\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30c7\u30d7\u30ed\u30a4\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n <\/p>\n \u4e0a\u8a18\u306e\u753b\u50cf\u3067\u306f\u3001\u5de6\u5074\u306e \u3010\u53c2\u8003\u3011 <\/p>\n Blue-Green Deployment \u306e\u30e1\u30ea\u30c3\u30c8\u3068\u3057\u3066\u306f\u3001\u4e0b\u8a18\u306e\u3082\u306e\u304c\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n \u4e00\u65b9\u3067\u30c7\u30e1\u30ea\u30c3\u30c8\u3068\u3057\u3066\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n \u300c\u540c\u3058\u3088\u3046\u306a\u74b0\u5883\u30922\u3064\u4f5c\u3089\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u305f\u3081\u3001\u624b\u9593\u304c\u304b\u304b\u308b\u300d\u3068\u3057\u3066\u3001\u30c7\u30e1\u30ea\u30c3\u30c8\u306e\u4e2d\u3067\u8a18\u8f09\u3057\u307e\u3057\u305f\u304c\u3001Elastic Beanstalk\u3092\u4f7f\u3046\u3068AWS\u30a4\u30f3\u30d5\u30e9\u3092\u3042\u307e\u308a\u610f\u8b58\u3057\u306a\u304f\u3066\u3082\u30b5\u30af\u30c3\u3068\u4f5c\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u30a4\u30f3\u30d5\u30e9\u306e\u69cb\u7bc9\u304c\u82e6\u624b\u3001\u3068\u3044\u3046\u65b9\u306b\u3068\u3063\u3066\u306f\u3001\u91cd\u5b9d\u3059\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002 <\/p>\n \u4eca\u56de\u306fAWS\u516c\u5f0f\u30da\u30fc\u30b8<\/a>\u306eDocker\u7528\u306e\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n Elastic Beanstalk CLI\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u3001\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8<\/a>\u3084\u3053\u3061\u3089\u306e\u307a\u30fc\u3058<\/a>\u3092\u53c2\u8003\u306b\u884c\u3044\u307e\u3059\u3002 <\/p>\n \u500b\u4eba\u7684\u306b\u306f\u74b0\u5883\u306b\u4f9d\u5b58\u3057\u306a\u3044\u5f62\u3067\u4f7f\u3048\u308b\u306e\u304c\u597d\u304d\u306a\u306e\u3067\u3001 \u3010 \u3010 \u3010 \u307e\u305a\u59cb\u3081\u306b \u30ea\u30fc\u30b8\u30e7\u30f3\u3092\u9078\u629e\u3059\u308b\u3068\u3001AWS\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u3068\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc\u3092\u805e\u304b\u308c\u307e\u3059\u3002 \u6b21\u306b\u3001\u5229\u7528\u3059\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u805e\u304b\u308c\u307e\u3059\u3002 \u300cDocker\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u6b63\u3057\u3044\u3067\u3059\u304b\uff1f\u300d\u3068\u554f\u308f\u308c\u308b\u306e\u3067\u3001 \u7d9a\u3044\u3066 \u4ee5\u4e0a\u3067\u3001\u521d\u671f\u8a2d\u5b9a\u306f\u5b8c\u4e86\u3067\u3059\u3002 \u6b21\u306b\u3001 \u5206\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u3001\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e \u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u3057\u3066\u3001\u74b0\u5883\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n \u5b9f\u884c\u30ed\u30b0\u3092\u898b\u308b\u3068\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30fc\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\u3084\u3001\u30aa\u30fc\u30c8\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\u3001EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u4f5c\u6210\u3001CloudWatch Alarm\u306e\u4f5c\u6210\u3001\u30ed\u30fc\u30c9\u30d0\u30e9\u30f3\u30b5\u30fc\u306e\u4f5c\u6210\u306a\u3069\u304c\u884c\u308f\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002 \u4f5c\u6210\u5b8c\u4e86\u5f8c\u306b\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n CNAME\u306e\u9805\u76ee\u3067\u51fa\u529b\u3055\u308c\u3066\u3044\u308b <\/p>\n \u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n \u6b21\u306b\u3001\u540c\u3058\u3088\u3046\u306bGreen\u74b0\u5883\u3092\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3059\u3002 \u5206\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u3001\u5148\u307b\u3069\u3068\u540c\u69d8\u306b\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e \u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u3057\u3066\u3001\u74b0\u5883\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n \u74b0\u5883\u4f5c\u6210\u5f8c\u306b\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n \u3053\u3061\u3089\u3082CNAME\u306e\u9805\u76ee\u3067\u8868\u793a\u3055\u308c\u3066\u3044\u308b <\/p>\n \u80cc\u666f\u304c\u7dd1\u306b\u306a\u3063\u305f\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n \u30b5\u30fc\u30d3\u30b9URL\u3068\u3057\u3066\u5206\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b <\/p>\n <\/p>\n \u60f3\u5b9a\u901a\u308aBlue\u74b0\u5883\u3078\u30a2\u30af\u30bb\u30b9\u304c\u884c\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n \u3053\u306e\u72b6\u614b\u3067\u3001 \u3053\u308c\u3092 \u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u304c\u5b8c\u4e86\u3057\u305f\u5f8c\u306b\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001<\/p>\n Blue\u74b0\u5883\u306eCNAME\u304c Green\u74b0\u5883\u306eCNAME\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002 CNAME\u304cBlue\u74b0\u5883\u306e\u3082\u306e\u306b\u5165\u308c\u66ff\u308f\u3063\u3066\u304a\u308a\u3001\u30b5\u30fc\u30d3\u30b9URL\u306e <\/p>\n Green\u74b0\u5883\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002 \u4ee5\u4e0a\u3001\u4eca\u56de\u306fBlue-Green Deployment\u3092Elastic Beanstalk\u3067\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002 \u4eca\u56de\u306f\u3001Blue-Green Deployment(\u30d6\u30eb\u30fc\u30b0\u30ea\u30fc\u30f3\u30c7\u30d7\u30ed\u30a4\u30e1\u30f3\u30c8)\u3092\u3001AWS Elastic Beanstalk\u3092\u4f7f\u3063\u3066\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002 Blue-Green Deployment \u3068\u306f \u540c\u7b49\u306e\u74b0\u5883\u30922\u3064\u7528\u610f\u3057\u3066\u3001\u30ea\u30ea\u30fc\u30b9\u6642\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u5148\u3092\u5207\u308a\u66ff\u3048\u308b\u3053\u3068\u3067\u3001\u30c0\u30a6\u30f3\u30bf\u30a4\u30e0\u3092\u307b\u307c\u30bc\u30ed\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30c7\u30d7\u30ed\u30a4\u65b9\u6cd5\u3067\u3059\u3002 \u4e0a\u8a18\u306e\u753b\u50cf\u3067\u306f\u3001\u5de6\u5074\u306e Blue environment \u3078\u30a2\u30af\u30bb\u30b9 […]<\/p>\n","protected":false},"author":3,"featured_media":684,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,18,9],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/669"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=669"}],"version-history":[{"count":0,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/669\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}Blue-Green Deployment<\/code> \u3068\u306f<\/h2>\n
Blue environment<\/code> \u3078\u30a2\u30af\u30bb\u30b9\u304c\u884c\u304f\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u72b6\u614b\u3067\u3059\u3002
\u3053\u308c\u3092\u30ea\u30ea\u30fc\u30b9\u6642\u306b\u3001\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u914d\u5099\u6e08\u307f\u306e Green environment<\/code> \u3078\u5207\u308a\u66ff\u3048\u308b\u5f62\u3067\u30c7\u30d7\u30ed\u30a4\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n
\n
\u30e1\u30ea\u30c3\u30c8<\/h3>\n
\n
\u30c7\u30e1\u30ea\u30c3\u30c8<\/h3>\n
\n
Elastic Beanstalk \u3067\u3084\u3063\u3066\u307f\u308b<\/h2>\n
\u524d\u63d0<\/h3>\n
\n
Elastic Beanstalk CLI \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n
Dockerfile<\/code> \u3068
docker-compose.yml<\/code> \u3092\u7528\u610f\u3057\u3066\u3001Docker\u74b0\u5883\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u884c\u3044\u307e\u3057\u305f\u3002
\u4ee5\u4e0b\u306f\u3001Docker\u3092\u4f7f\u3046\u969b\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5\u3067\u3059\u304c\u3001\u304a\u597d\u307f\u306e\u65b9\u6cd5\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\nDockerfile<\/code>\u3011<\/p>\n
FROM alpine:latest\n\nRUN apk add --no-cache make g++ libffi-dev openssl-dev python3 py3-pip python3-dev git && \n pip3 install --upgrade --ignore-installed awsebcli\n\nVOLUME \/app\nWORKDIR \/app\nENTRYPOINT ["eb"]<\/code><\/pre>\n
docker-compose.yml<\/code>\u3011<\/p>\n
version: "3.8"\nservices:\n eb:\n build:\n context: .\/\n dockerfile: .\/Dockerfile\n volumes:\n - .:\/app\n env_file:\n - .env<\/code><\/pre>\n
.env<\/code> \u30d5\u30a1\u30a4\u30eb\u306b\u3001
AWS_ACCESS_KEY_ID<\/code> \u3084
AWS_SECRET_ACCESS_KEY<\/code> \u3092\u4e0b\u8a18\u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u304a\u304d\u3001<\/p>\n
AWS_ACCESS_KEY_ID=AKIAJOUAASEXAMPLE\nAWS_SECRET_ACCESS_KEY=5ZRIrtTM4ciIAvd4EXAMPLEDtm+PiPSzpoK<\/code><\/pre>\n
docker-compose build<\/code> \u30b3\u30de\u30f3\u30c9\u3067Docker\u306e\u30d3\u30eb\u30c9\u3092\u3057\u307e\u3059\u3002<\/p>\n
$ docker-compose build<\/code><\/pre>\n
eb<\/code> \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u969b\u306b\u306f\u3001
docker-compose run eb xxx<\/code> \u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n
eb init<\/code> \u3092\u5b9f\u884c\u3057\u305f\u3044\u969b\u306e\u4f8b\u3011<\/p>\n
$ docker-compose run eb init<\/code><\/pre>\n
Elastic Beanstalk \u521d\u671f\u8a2d\u5b9a<\/h3>\n
eb init<\/code> \u3092\u5b9f\u884c\u3057\u3066\u3001Elastic Beanstalk\u306e\u521d\u671f\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002
\u30ea\u30fc\u30b8\u30e7\u30f3\u3092\u805e\u304b\u308c\u308b\u306e\u3067\u3001\u6771\u4eac\u30ea\u30fc\u30b8\u30e7\u30f3\u3067\u3042\u308b 9<\/code> \u3092\u5165\u529b\u3057\u307e\u3059\u3002 <\/p>\n
$ eb init\n\nSelect a default region\n1) us-east-1 : US East (N. Virginia)\n2) us-west-1 : US West (N. California)\n3) us-west-2 : US West (Oregon)\n4) eu-west-1 : EU (Ireland)\n5) eu-central-1 : EU (Frankfurt)\n6) ap-south-1 : Asia Pacific (Mumbai)\n7) ap-southeast-1 : Asia Pacific (Singapore)\n8) ap-southeast-2 : Asia Pacific (Sydney)\n9) ap-northeast-1 : Asia Pacific (Tokyo)\n10) ap-northeast-2 : Asia Pacific (Seoul)\n11) sa-east-1 : South America (Sao Paulo)\n12) cn-north-1 : China (Beijing)\n13) cn-northwest-1 : China (Ningxia)\n14) us-east-2 : US East (Ohio)\n15) ca-central-1 : Canada (Central)\n16) eu-west-2 : EU (London)\n17) eu-west-3 : EU (Paris)\n18) eu-north-1 : EU (Stockholm)\n19) eu-south-1 : EU (Milano)\n20) ap-east-1 : Asia Pacific (Hong Kong)\n21) me-south-1 : Middle East (Bahrain)\n22) af-south-1 : Africa (Cape Town)\n(default is 3): 9<\/code><\/pre>\n
\u9069\u5207\u306a\u6a29\u9650\u3092\u6301\u3063\u305fIAM\u30e6\u30fc\u30b6\u30fc\u3092\u4f5c\u6210\u3057\u3066\u3001\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u3068\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
\u203b \u74b0\u5883\u5909\u6570\u306b\u8a2d\u5b9a\u6e08\u307f\u306e\u5834\u5408\u306f\u3001\u805e\u304b\u308c\u307e\u305b\u3093\u3002<\/p>\nYou have not yet set up your credentials or your credentials are incorrect.\nYou must provide your credentials.\n(aws-access-id): AKIAJOUAASEXAMPLE\n(aws-secret-key): 5ZRIrtTM4ciIAvd4EXAMPLEDtm+PiPSzpoK<\/code><\/pre>\n
\u4f55\u3082\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u7121\u3044\u5834\u5408\u306f\u3001 [ Create new Application ]<\/code> \u9078\u629e\u5f8c\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u540d\u3092\u805e\u304b\u308c\u308b\u306e\u3067\u3001\u5165\u529b\u3057\u307e\u3059\u3002
\u4eca\u56de\u306f\u3001\u4e8b\u524d\u306b\u4f5c\u6210\u6e08\u307f\u306e app<\/code> \u3092\u5229\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n
Select an application to use\n1) app\n2) uchiko-test-app\n3) lightsail_to_eb\n4) Go-Car-API\n5) [ Create new Application ]\n(default is 1):<\/code><\/pre>\n
y<\/code> \u3068\u5165\u529b\u3057\u307e\u3059\u3002
\u30c7\u30d5\u30a9\u30eb\u30c8\u8a2d\u5b9a\u306e Amazon Linux 2<\/code> \u306e
1<\/code> \u3092\u9078\u629e\u3057\u307e\u3057\u305f\u3002<\/p>\n
It appears you are using Docker. Is this correct?\n(Y\/n): y\nSelect a platform branch.\n1) Docker running on 64bit Amazon Linux 2\n2) Multi-container Docker running on 64bit Amazon Linux\n3) Docker running on 64bit Amazon Linux\n(default is 1):<\/code><\/pre>\n
CodeCommit<\/code> \u3092\u5229\u7528\u3059\u308b\u304b\uff1f\u3068\u805e\u304b\u308c\u307e\u3059\u304c\u3001\u4eca\u56de\u306f\u5229\u7528\u3057\u306a\u3044\u306e\u3067
n<\/code> \u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n
Do you wish to continue with CodeCommit? (Y\/n): n<\/code><\/pre>\n
SSH<\/code> \u306e\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u805e\u304b\u308c\u307e\u3059\u3002
\u4eca\u56de\u306f SSH<\/code> \u3092\u3059\u308b\u5fc5\u8981\u306f\u7121\u3044\u306e\u3067
n<\/code> \u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n
Do you want to set up SSH for your instances?\n(Y\/n): n<\/code><\/pre>\n
.elasticbeanstalk\/<\/code> \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306b
config.yml<\/code> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u3067\u304d\u307e\u3059\u3002
\u3053\u308c\u307e\u3067\u5165\u529b\u3057\u3066\u304d\u305f\u5185\u5bb9\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\nbranch-defaults:\n master:\n environment: null\nglobal:\n application_name: app\n branch: null\n default_ec2_keyname: null\n default_platform: Docker running on 64bit Amazon Linux 2\n default_region: ap-northeast-1\n include_git_submodules: true\n instance_profile: null\n platform_name: null\n platform_version: null\n profile: null\n repository: null\n sc: null\n workspace_type: Application<\/code><\/pre>\n
Blue\u74b0\u5883\u4f5c\u6210<\/h3>\n
eb create <\u74b0\u5883\u540d><\/code> \u3092\u5b9f\u884c\u3057\u3001 Blue\u74b0\u5883\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002
\u74b0\u5883\u540d\u306f\u3001 envblue<\/code> \u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n
application.py<\/code> \u306e74\u884c\u76ee\u306e
background-color<\/code> \u3092
blue<\/code> \u4fee\u6b63\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n
.textColumn {\n position: absolute;\n top: 0px;\n right: 50%;\n bottom: 0px;\n left: 0px;\n\n text-align: right;\n padding-top: 11em;\n background-color: blue; \/\/\u3053\u3053\u3092 blue \u306b\u5909\u66f4\n}<\/code><\/pre>\n
$ eb create envblue\nCreating application version archive "app-f56a-200820_045534".\nUploading app\/app-f56a-200820_045534.zip to S3. This may take a while.\nUpload Complete.\nEnvironment details for: envblue\n Application name: app\n Region: ap-northeast-1\n Deployed Version: app-f56a-200820_045534\n Environment ID: e-jywrptwt6c\n Platform: arn:aws:elasticbeanstalk:ap-northeast-1::platform\/Docker running on 64bit Amazon Linux 2\/3.1.0\n Tier: WebServer-Standard-1.0\n CNAME: UNKNOWN\n Updated: 2020-08-20 04:55:37.419000+00:00\nPrinting Status:\n2020-08-20 04:55:36 INFO createEnvironment is starting.\n2020-08-20 04:55:37 INFO Using elasticbeanstalk-ap-northeast-1-111111111111 as Amazon S3 storage bucket for environment data.\n2020-08-20 04:55:59 INFO Created target group named: arn:aws:elasticloadbalancing:ap-northeast-1:111111111111:targetgroup\/awseb-AWSEB-AQC6223EWOQ9\/0b8483a5d06ccf39\n2020-08-20 04:55:59 INFO Created security group named: sg-0929db6bd29b38a61\n2020-08-20 04:56:15 INFO Created security group named: awseb-e-jywrptwt6c-stack-AWSEBSecurityGroup-S4Y5PPX8II3I\n2020-08-20 04:56:15 INFO Created Auto Scaling launch configuration named: awseb-e-jywrptwt6c-stack-AWSEBAutoScalingLaunchConfiguration-53FXXR9QFA81\n2020-08-20 04:57:48 INFO Created Auto Scaling group named: awseb-e-jywrptwt6c-stack-AWSEBAutoScalingGroup-1CZ9R8SWCCMPT\n2020-08-20 04:57:48 INFO Waiting for EC2 instances to launch. This may take a few minutes.\n2020-08-20 04:57:48 INFO Created Auto Scaling group policy named: arn:aws:autoscaling:ap-northeast-1:111111111111:scalingPolicy:2a4a7352-11d2-4104-8edd-46c3e1e5f112:autoScalingGroupName\/awseb-e-jywrptwt6c-stack-AWSEBAutoScalingGroup-1CZ9R8SWCCMPT:policyName\/awseb-e-jywrptwt6c-stack-AWSEBAutoScalingScaleDownPolicy-1XG7ZR7RYCHLD\n2020-08-20 04:57:48 INFO Created Auto Scaling group policy named: arn:aws:autoscaling:ap-northeast-1:111111111111:scalingPolicy:1e833cea-2056-43ed-ad85-81b4d736e173:autoScalingGroupName\/awseb-e-jywrptwt6c-stack-AWSEBAutoScalingGroup-1CZ9R8SWCCMPT:policyName\/awseb-e-jywrptwt6c-stack-AWSEBAutoScalingScaleUpPolicy-T2H16EIIX9CY\n2020-08-20 04:57:48 INFO Created CloudWatch alarm named: awseb-e-jywrptwt6c-stack-AWSEBCloudwatchAlarmLow-OOAK208S5O85\n2020-08-20 04:57:48 INFO Created CloudWatch alarm named: awseb-e-jywrptwt6c-stack-AWSEBCloudwatchAlarmHigh-1JYHQZHWCC8CG\n2020-08-20 04:58:07 INFO Created load balancer named: arn:aws:elasticloadbalancing:ap-northeast-1:111111111111:loadbalancer\/app\/awseb-AWSEB-K7ARO4RZPPFS\/132af7e0b271b51e\n2020-08-20 04:58:07 INFO Created Load Balancer listener named: arn:aws:elasticloadbalancing:ap-northeast-1:111111111111:listener\/app\/awseb-AWSEB-K7ARO4RZPPFS\/132af7e0b271b51e\/179271fd42db6b0b\n2020-08-20 04:59:04 INFO Instance deployment completed successfully.\n2020-08-20 04:59:20 INFO Application available at envblue.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com.\n2020-08-20 04:59:21 INFO Successfully launched environment: envblue<\/code><\/pre>\n
\u30b3\u30de\u30f3\u30c9\u4e00\u767a\u3067\u3001\u3044\u3044\u611f\u3058\u306b\u4f5c\u6210\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3001AWS\u30a4\u30f3\u30d5\u30e9\u306e\u77e5\u8b58\u304c\u306a\u3044\u4eba\u3067\u3082\u697d\u3061\u3093\u3067\u3059\u3002 <\/p>\n$ eb status envblue\nEnvironment details for: envblue\n Application name: app\n Region: ap-northeast-1\n Deployed Version: app-f56a-200820_045534\n Environment ID: e-jywrptwt6c\n Platform: arn:aws:elasticbeanstalk:ap-northeast-1::platform\/Docker running on 64bit Amazon Linux 2\/3.1.0\n Tier: WebServer-Standard-1.0\n CNAME: envblue.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com\n Updated: 2020-08-20 04:59:21.579000+00:00\n Status: Ready\n Health: Green<\/code><\/pre>\n
http:\/\/envblue.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com<\/code> \u306b\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3068\u3001<\/p>\n
Green\u74b0\u5883\u4f5c\u6210<\/h3>\n
\u540d\u524d\u306f envgreen<\/code> \u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n
application.py<\/code> \u306e74\u884c\u76ee\u306e
background-color<\/code> \u3092
green<\/code> \u4fee\u6b63\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n
.textColumn {\n position: absolute;\n top: 0px;\n right: 50%;\n bottom: 0px;\n left: 0px;\n\n text-align: right;\n padding-top: 11em;\n background-color: green; \/\/\u3053\u3053\u3092 green \u306b\u5909\u66f4\n}<\/code><\/pre>\n
$ eb create envgreen\nCreating application version archive "app-f56a-200820_050403".\nUploading app\/app-f56a-200820_050403.zip to S3. This may take a while.\nUpload Complete.\nEnvironment details for: envgreen\n Application name: app\n Region: ap-northeast-1\n Deployed Version: app-f56a-200820_050403\n Environment ID: e-u6j7ubnf56\n Platform: arn:aws:elasticbeanstalk:ap-northeast-1::platform\/Docker running on 64bit Amazon Linux 2\/3.1.0\n Tier: WebServer-Standard-1.0\n CNAME: UNKNOWN\n Updated: 2020-08-20 05:04:07.009000+00:00\nPrinting Status:\n2020-08-20 05:04:05 INFO createEnvironment is starting.\n2020-08-20 05:04:07 INFO Using elasticbeanstalk-ap-northeast-1-111111111111 as Amazon S3 storage bucket for environment data.\n2020-08-20 05:04:28 INFO Created target group named: arn:aws:elasticloadbalancing:ap-northeast-1:111111111111:targetgroup\/awseb-AWSEB-19G3AMQDOPOMM\/63866529b59c2db4\n2020-08-20 05:04:29 INFO Created security group named: sg-0a29b375fef10adce\n2020-08-20 05:04:44 INFO Created security group named: awseb-e-u6j7ubnf56-stack-AWSEBSecurityGroup-1MR72ZIN6S1G6\n2020-08-20 05:04:44 INFO Created Auto Scaling launch configuration named: awseb-e-u6j7ubnf56-stack-AWSEBAutoScalingLaunchConfiguration-C6CT6HF14TH5\n2020-08-20 05:05:46 INFO Created Auto Scaling group named: awseb-e-u6j7ubnf56-stack-AWSEBAutoScalingGroup-94SRCJPFN5F9\n2020-08-20 05:05:46 INFO Waiting for EC2 instances to launch. This may take a few minutes.\n2020-08-20 05:05:46 INFO Created Auto Scaling group policy named: arn:aws:autoscaling:ap-northeast-1:111111111111:scalingPolicy:f2d0c1fc-e96d-41d6-a20c-9e791c2b7166:autoScalingGroupName\/awseb-e-u6j7ubnf56-stack-AWSEBAutoScalingGroup-94SRCJPFN5F9:policyName\/awseb-e-u6j7ubnf56-stack-AWSEBAutoScalingScaleUpPolicy-1WWHVFHUA9ATS\n2020-08-20 05:05:46 INFO Created Auto Scaling group policy named: arn:aws:autoscaling:ap-northeast-1:111111111111:scalingPolicy:49c8098c-495d-455f-bf0a-63472593f645:autoScalingGroupName\/awseb-e-u6j7ubnf56-stack-AWSEBAutoScalingGroup-94SRCJPFN5F9:policyName\/awseb-e-u6j7ubnf56-stack-AWSEBAutoScalingScaleDownPolicy-4AUHRB0KFKGU\n2020-08-20 05:06:02 INFO Created CloudWatch alarm named: awseb-e-u6j7ubnf56-stack-AWSEBCloudwatchAlarmHigh-149KK1O2VXJXG\n2020-08-20 05:06:02 INFO Created CloudWatch alarm named: awseb-e-u6j7ubnf56-stack-AWSEBCloudwatchAlarmLow-GKTVA8SZ66O6\n2020-08-20 05:06:37 INFO Created load balancer named: arn:aws:elasticloadbalancing:ap-northeast-1:111111111111:loadbalancer\/app\/awseb-AWSEB-9QSDBBY8XY1A\/10604c0117039c7e\n2020-08-20 05:06:52 INFO Created Load Balancer listener named: arn:aws:elasticloadbalancing:ap-northeast-1:111111111111:listener\/app\/awseb-AWSEB-9QSDBBY8XY1A\/10604c0117039c7e\/02dde44d0da6f440\n2020-08-20 05:07:35 INFO Instance deployment completed successfully.\n2020-08-20 05:07:41 INFO Application available at envgreen.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com.\n2020-08-20 05:07:41 INFO Successfully launched environment: envgreen<\/code><\/pre>\n
$ eb status envgreen\nEnvironment details for: envgreen\n Application name: app\n Region: ap-northeast-1\n Deployed Version: app-f56a-200820_050403\n Environment ID: e-u6j7ubnf56\n Platform: arn:aws:elasticbeanstalk:ap-northeast-1::platform\/Docker running on 64bit Amazon Linux 2\/3.1.0\n Tier: WebServer-Standard-1.0\n CNAME: envgreen.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com\n Updated: 2020-08-20 05:07:41.383000+00:00\n Status: Ready\n Health: Green<\/code><\/pre>\n
http:\/\/envgreen.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com<\/code> \u306b\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3068\u3001<\/p>\n
Route53\u306b\u30ec\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3059\u308b<\/h3>\n
Route53<\/code> \u306b\u30ec\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u307f\u307e\u3059\u3002
\u4eca\u56de\u306f\u3001 ebapp.test.mmmcorp.co.jp<\/code> \u306b\u3057\u307e\u3057\u305f\u3002
ALIAS \u3068\u3057\u3066\u3001\u5148\u7a0b\u4f5c\u6210\u3057\u305fBlue\u74b0\u5883\u306eCNAME envblue.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com<\/code> \u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002 <\/p>\n
http:\/\/ebapp.test.mmmcorp.co.jp<\/code> \u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3068<\/p>\n
CNAME \u3092\u5207\u308a\u66ff\u3048\u308b<\/h3>\n
eb swap<\/code> \u30b3\u30de\u30f3\u30c9\u30672\u3064\u306e\u74b0\u5883\u306eCNAME\u3092\u5165\u308c\u66ff\u3048\u307e\u3059\u3002
\u307e\u305a\u306f\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u78ba\u8a8d\u304b\u3089\u3002
Blue\u74b0\u5883\u306eCNAME\u306f\u3001\u4e0b\u8a18\u306e\u3068\u304a\u308a\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n$ eb status envblue\nEnvironment details for: envblue\n (\u7565)\n CNAME: envblue.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com\n (\u7565)<\/code><\/pre>\n
eb swap<\/code> \u3067\u5207\u308a\u66ff\u3048\u307e\u3059\u3002 <\/p>\n
$ eb swap --destination_name envgreen\n2020-08-20 05:48:33 INFO swapEnvironmentCNAMEs is starting.\n2020-08-20 05:48:34 INFO Swapping CNAMEs for environments 'envblue' and 'envgreen'.\n2020-08-20 05:48:39 INFO 'envgreen.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com' now points to 'awseb-AWSEB-K7ARO4RZPPFS-554919051.ap-northeast-1.elb.amazonaws.com'.\n2020-08-20 05:48:39 INFO Completed swapping CNAMEs for environments 'envblue' and 'envgreen'.<\/code><\/pre>\n
$ eb status envblue\nEnvironment details for: envblue\n (\u7565)\n CNAME: envgreen.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com\n (\u7565)<\/code><\/pre>\n
\u3055\u3089\u306b\u305d\u306e\u72b6\u614b\u3067\u3001Green\u74b0\u5883\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001<\/p>\n$ eb status envgreen\nEnvironment details for: envgreen\n (\u7565)\n CNAME: envblue.eba-at7th2ac.ap-northeast-1.elasticbeanstalk.com\n (\u7565)<\/code><\/pre>\n
http:\/\/ebapp.test.mmmcorp.co.jp\/<\/code> \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001<\/p>\n
\u30ea\u30ea\u30fc\u30b9\u5f8c\u306b\u4f55\u304b\u4e0d\u5177\u5408\u304c\u767a\u899a\u3057\u3066\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5207\u308a\u623b\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u5834\u5408\u306f\u540c\u3058\u3088\u3046\u306b eb swap<\/code> \u30b3\u30de\u30f3\u30c9\u3067CNAME\u3092\u5165\u308c\u66ff\u3048\u308b\u3060\u3051\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n
\u307e\u3068\u3081<\/h2>\n
\u5f0a\u793e\u3067\u306f\u3001\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u3084\u8907\u96d1\u306a\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u304c\u8981\u4ef6\u4e0a\u767a\u751f\u3059\u308b(\u898b\u8fbc\u307e\u308c\u308b)\u30b7\u30b9\u30c6\u30e0\u306e\u958b\u767a\u3092\u8acb\u3051\u8ca0\u3046\u3053\u3068\u304c\u591a\u304f\u3001\u30b3\u30fc\u30c9\u30d9\u30fc\u30b9\u306e\u7ba1\u7406\u30b3\u30b9\u30c8\u30fb\u8907\u96d1\u6027\u306e\u89b3\u70b9\u304b\u3089Elastic Beanstalk\u3092\u3042\u307e\u308a\u5229\u7528\u3057\u307e\u305b\u3093\u3002
\u3068\u306f\u3044\u3048\u3001\u6bd4\u8f03\u7684\u30b7\u30f3\u30d7\u30eb\u306aAWS\u30a4\u30f3\u30d5\u30e9\u3067\u554f\u984c\u306a\u3044\u5834\u5408\u3084\u3001AWS\u30a4\u30f3\u30d5\u30e9\u3092\u3042\u307e\u308a\u8003\u3048\u305f\u304f\u306a\u3044\u5834\u5408\u3001AWS\u30a4\u30f3\u30d5\u30e9\u306e\u8907\u96d1\u306a\u7ba1\u7406\u3092\u3057\u305f\u304f\u306a\u3044\u5834\u5408\u306b\u306f\u3001Elastic Beanstalk\u3092\u63a1\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u7c21\u5358\u306bBlue-Green Deployment\u304c\u884c\u3048\u308b\u306e\u3067\u4e00\u8003\u306e\u4f59\u5730\u3042\u308a\u3060\u3068\u306f\u601d\u3044\u307e\u3059\u3002<\/p>\n\u53c2\u8003<\/h2>\n
\n