[英]AWS CD/CI pipeline with ASG and ELB (bitbucket)
I must first preface by saying I am relatively new to AWS but finding it immensely useful.我必须首先声明我对 AWS 比较陌生,但发现它非常有用。 Let me describe my scenario...让我描述一下我的场景......
When the ASG decides to scale in a new EC2 instance using my launch template and AMI, it will use the application code from the AMI.当 ASG 决定使用我的启动模板和 AMI 扩展新的 EC2 实例时,它将使用 AMI 中的应用程序代码。 But if I deploy to master at some point, my AMI will not be updated, but instances within the ASG will be updated.但如果我在某个时候部署到 master,我的 AMI 将不会更新,但 ASG 中的实例会更新。 What is the best method for ensuring the new instances spawned by the ASG are running the latest code version (master)?确保 ASG 生成的新实例运行最新代码版本(master)的最佳方法是什么?
I am thinking to include a bash script in the launch config that will pull the latest code from Bitbucket and run any following steps to get my application running (such as "npm install", "npm run start" etc etc).我想在启动配置中包含一个 bash 脚本,它将从 Bitbucket 中提取最新代码并运行以下任何步骤以使我的应用程序运行(例如“npm install”、“npm run start”等)。 I'm sure someone has a more elegant solution, and I'd love to hear some suggestions.我相信有人有更优雅的解决方案,我很想听听一些建议。
To anyone coming to this, I did solve my problem.对于任何来到这里的人,我确实解决了我的问题。 I was correct initially.我一开始是对的。 The "user data" field within the Launch Template was a good place to bootstrap my app once the instance is up and running.一旦实例启动并运行,启动模板中的“用户数据”字段是引导我的应用程序的好地方。 It basically clones from the remote repo and performs any necessary steps to launch the app after that.它基本上从远程存储库克隆,然后执行任何必要的步骤来启动应用程序。
For example, in the launch configuration for EC2例如,在 EC2 的启动配置中
#cloud-boothook
#!/bin/bash
git clone myremoterepo.git
cd myremoterepo
npm install
npm run start
Also, if you're running a classic load balancer, CodeDeploy will attempt to start a deployment, based on your latest code repo in S3, when your ASG scales up the EC2 instances.此外,如果您运行的是经典负载均衡器,当您的 ASG 扩展 EC2 实例时,CodeDeploy 将尝试根据您在 S3 中的最新代码存储库开始部署。 So the above solution will be redundant.所以上述解决方案将是多余的。
thanks for this post.感谢这篇文章。 But it would help me a lot if you shared an example of your bitbucket pipeline yml, since I have a project that migrates it to the asg infrastructure with network load balancer, and I don't know how to configure a code deploy to integrate it with s3 and bitbucket.但是,如果您分享了您的 bitbucket 管道 yml 的示例,这将对我有很大帮助,因为我有一个项目可以将其迁移到带有网络负载均衡器的 asg 基础架构,而且我不知道如何配置代码部署以集成它使用 s3 和 bitbucket。 A guide would help me a lot to be able to configure the entire process of deploying my load balancer from bitbucket.一个指南可以帮助我配置从 bitbucket 部署负载均衡器的整个过程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.