Amazon CodeDeploy with AllAtOnce fails to execute on new CloudFormation stack with on 1 EC2 instance

2k views Asked by At

My CloudFormation stack produces a ScalingGroup which has MinSize and MaxSize set to 1. It also creates a DeploymentGroup that targets this ScalingGroup.

  • When the deploymentgroup is configured with Configuration name CodeDeployDefault.OneAtATime then the deployment starts successfully.
  • When the deploymentgroup is configured with Configuration name CodeDeployDefault.AllAtOnce then upon the creation of the stack, the codedeploy doesn't do anything and you can't see any events or log traces on the EC2. There is only one mention to error code HEALTH_CONSTRAINTS. If I terminate the instance, then the scaling group launches a new instance but CodeDeploy doesn't do anything again. If I manually start a deployment with CodeDeployDefault.OneAtATime then it works.

From what i've read in the documentation, this should not happen

  • There should be no health checks because no instances exists in the deployment group
  • CodeDeployDefault.AllAtOnce has a minimum health percentage of 0. So it could be that the reason to raise the error is that it equaled 0 and it decided to not continue with the health error code
  • CodeDeployDefault.AllAtOnce mentions and that should be my understanding, that it is not going to do a heath check because conceptually there is no point, as all instances will be configured at the same time.

Is my expectation or correct or am I do something wrong?

1

There are 1 answers

2
binbinlu On

The error code HEALTH_CONSTRAINTS means CodeDeploy deployment failed and the configured healthy hosts ratio is not satisfied. You might want to got to the AWS CodeDeploy console and click on the deployment that created during the during the CloudFormation running process, and the check why the deployment failed. The different between CodeDeployDefault.OneAtATime and CodeDeployDefault.AllAtOnce can be found here: http://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-configurations.html

CodeDeployDefault.AllAtOnce Attempts to deploy an application revision to as many instances as possible at once. The status of the overall deployment will be displayed as Succeeded if the application revision is deployed to one or more of the instances. The status of the overall deployment will be displayed as Failed if the application revision is not deployed to any of the instances. Using an example of nine instances, CodeDeployDefault.AllAtOnce will attempt to deploy to all nine instances at once. The overall deployment will succeed if deployment to even a single instance is successful; it will fail only if deployments to all nine instances fail.

CodeDeployDefault.OneAtATime Deploys the application revision to only one instance at a time. For deployment groups that contain more than one instance: The overall deployment succeeds if the application revision is deployed to all of the instances. The exception to this rule is if deployment to the last instance fails, the overall deployment still succeeds. This is because AWS CodeDeploy allows only one instance at a time to be taken offline with the CodeDeployDefault.OneAtATime configuration. The overall deployment fails as soon as the application revision fails to be deployed to any but the last instance. In an example using nine instances, it will deploy to one instance at a time. The overall deployment succeeds if deployment to the first eight instances is successful; the overall deployment fails if deployment to any of the first eight instances fails. For deployment groups that contain only one instance, the overall deployment is successful only if deployment to the single instance is successful.

Since your deployment group only contains one single instance, if you set CodeDeployDefault.OneAtATime and the single instance deployment failed, the deployment will still be marked as succeeded. Please check the deployment details on AWS CodeDeploy console.