Search code examples
amazon-web-servicesaws-code-deployaws-codepipeline

How to get around CodeDeploy succeeding with N-1 successful deployments


Current CodeDeploy implementation has it so that if N-1 deployments succeed, the whole deployment is successful. However, we have a use case where ALL N deployments must succeed, not just N-1 (N being the total # of target servers we are deploying to). So to get around this limitation, we saw that we can create alarms and add that to the deployment group. And if the alarm is triggered, any deployments ongoing by the deployment group will fail. My question is how could we trigger this alarm during deployment to force fail the deployment?

Thanks a lot in advance.


Solution

  • You can use the set-alarm-state aws cli call to set any alarm state. Its more for testing purpose but can work for your use case:

    https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/set-alarm-state.html

    Instead of the above approach which could be error-prone and hard to debug, I would suggest to use CodeDeploy notification on INSTANCE_FAILURE to respond to deployment failing on an instance during deployment:

    https://aws.amazon.com/blogs/aws/new-notifications-for-aws-codedeploy-events/