Search code examples
amazon-web-servicesamazon-ec2devopsaws-code-deploy

What does AWS CodeDeploy mean by taking an instance offline?


We are using AWS, with CodeDeploy and EC2 instances to run multiple web applications.

We have 4 EC2 instances, each running multiple applications, accessible on different ports. We have CodeDeploy deployment groups configured for each application. So, for 5 applications, there are 5 app/deployment groups. Since each application is deployed to all 4 instances, each deployment group includes all 4 instances (using tags). These deployment groups are configured to perform "in-place" deployments. Even though we're using an application load balancer, these deployment groups are not enabled for load balancing. (Mostly because I'm unclear on the answer to the question below.)

In the AWS documentation, it indicates that during deployment "Instances in a deployment group are taken offline". What exactly does that mean? Is it taking the entire EC2 instance offline during deployment? Meaning that all apps running on a single instance will be unavailable while deploying a single app to that instance?

Or is it really only "offline" in terms of the specific CodeDeploy app status and managing deployments? And the actual app status is really defined by how the lifecycle events are implemented/handled in the specific appsec file? Meaning that the EC2 instance is still technically available for traffic, regardless of whether the literal app is available or LB traffic is being routed to the instance?

And if it's not clear, the use case is: since we're running multiple apps on the same instance(s), can we safely deploy updates to an individual app, without at all affecting the availability of other applications?


Solution

  • From the documentation - emphasis mine:

    In-place deployment: The application on each instance in the deployment group is stopped, the latest application revision is installed, and the new version of the application is started and validated. You can use a load balancer so that each instance is deregistered during its deployment and then restored to service after the deployment is complete. Only deployments that use the EC2/On-Premises compute platform can use in-place deployments. For more information about in-place deployments, see Overview of an In-Place Deployment.

    The documentation doesn't say anything about the instance being stopped...

    What happens during the deployment is defined by your Appspec-File, for which the reference documentation is here.

    The important part in you case concers the hooks in which you specify what happens during the deployment.

    This graphic from the AWS documentation shows the Order in which the hooks are executed (in your case the left flow should be relevant:

    enter image description here