10

I'm trying to setup an Auto Scaling Group in combination with CodeDeploy. Everything works fine except for the fact that when a new instance is created CodeDeploy starts before the user data script (defined in the Launch Configuration) finishes.

The default value of this user data script downloads and install the code deploy agent and i've extended it with installation of a couple of windows features, IIS rewrite module and msdeploy.

In my appspec.yml i'm using the hook AfterInstall to deploy my IIS website and this obviously fails when msdeploy is not installed (yet).

Am i going about this the wrong way or is there a way to make CodeDeploy wait for the user data script to finish?

4

2 回答 2

15

不幸的是,对于 CodeDeploy 来说,除了实例加载它的操作系统之外,什么都不知道。好消息是 CodeDeploy 给主机代理 1 小时开始轮询具有自动部署的命令。最简单的做法是在安装所有必需的依赖项后安装主机代理。将创建自动部署,但在主机代理启动之前无法继续。

于 2015-10-27T17:42:55.863 回答
3

这在这里详细解释 - https://aws.amazon.com/blogs/devops/under-the-hood-aws-codedeploy-and-auto-scaling-integration/

启动脚本的执行顺序 – CodeDeploy 代理在启动后立即查找并执行部署。部署执行和启动脚本(如用户数据、cfn-init 等)之间没有顺序。我们建议您将主机代理安装为启动脚本的一部分(也可能是作为启动脚本的最后一步),这样您就可以确定在实例安装不属于您的 CodeDeploy 部署的依赖项之前,不会执行部署。如果您更喜欢将代理烘焙到基础 AMI 中,我们建议您将代理服务保持在停止状态并使用启动脚本启动代理服务。

于 2021-02-11T07:13:53.133 回答