Search code examples
amazon-web-servicesamazon-ec2windows-serveraws-code-deploy

AWS CodeDeploy executes before Auto Scaling userdata scripts finishes


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?


Solution

  • Unfortunately, there's no way for CodeDeploy to know anything more than the instance has loaded it's OS. The good thing is that CodeDeploy gives the host agent 1 hour to start polling for commands with automatic deployments. The easiest thing to do is to install the host agent after all the required dependencies are installed. The automatic deployment will be created, but can't proceed until after the host agent is started.