If you deploy in place to an Auto Scaling group with CodeDeploy, you have probably met this failure: the deployment is halfway through an instance, scale-in picks that same instance, and the whole thing falls over. The usual fix was a pair of scripts to suspend and resume processes around the deployment. CodeDeploy now does that for you.
Here is what the feature does, how to turn it on, and the two things I would set up before relying on it. This is based on the launch post and the CodeDeploy user guide. I have not run it myself.
What changed
CodeDeploy can now suspend chosen EC2 Auto Scaling processes before an in-place deployment and resume them when the deployment succeeds, fails or is stopped. You pick any combination of four:
-
Terminate: stops scale-in from removing instances while they are being updated -
AZRebalance: stops rebalancing, which launches and terminates instances to even out Availability Zones -
InstanceRefresh: stops instance refreshes that replace instances -
ScheduledActions: stops scheduled scaling actions from running
You can set it on the deployment group, which then applies to every deployment in that group, including ones started by pipelines you already have. You can also override it for a single deployment, including with an empty list to suspend nothing. It is available in all AWS Regions, including GovCloud and China.
Turning it on
The setting lives in ec2DeploymentOptions. On a deployment group:
aws deploy update-deployment-group \ --application-name my-application \ --current-deployment-group-name my-deployment-group \ --ec2-deployment-options '{"autoScalingGroupProcessesToSuspend":["Terminate","AZRebalance"]}' To switch it off again, pass an empty list. Process names are case sensitive, which is the sort of thing that costs you ten minutes.
The service role needs autoscaling:DescribeAutoScalingGroups, autoscaling:SuspendProcesses and autoscaling:ResumeProcesses on the groups involved. The AWSCodeDeployRole managed policy already includes them. If you use a custom role, add them, because without them CodeDeploy will not create the deployment at all.
Where it does not apply
This is worth checking before you assume it covers you:
- It only works for in-place deployments. Blue/green deployments do not suspend processes.
- The deployment group must include at least one Auto Scaling group. Instances you add by tag, or on-premises instances, are not affected by the suspension.
- If you ask for processes on a group that does not meet those conditions, CodeDeploy rejects the request.
What I would set up first
A notification on failed deployments. The docs are clear that if CodeDeploy cannot resume the processes, the deployment fails and they stay suspended. While Terminate is suspended, Auto Scaling does not replace unhealthy instances. So a failed deployment can leave a group that quietly stops healing itself. A CodeDeploy trigger or an EventBridge rule on failure is the minimum. The error message lists which groups and processes are still suspended, and the fix is a manual ResumeProcesses.
One deployment group per Auto Scaling group. If two deployment groups share an Auto Scaling group, a deployment in one can resume processes while the other is still running. The docs say to associate each Auto Scaling group with only one deployment group. Worth auditing if you have grown organically.
Two smaller points from the docs. If a process was already suspended when the deployment started, CodeDeploy will not resume it afterwards. And if you suspend Terminate but not AZRebalance, the group can temporarily exceed its maximum size, by up to 10 percent, while rebalancing.
One behaviour I would not forget: suspended ScheduledActions that start during the deployment are skipped and do not run later. If you have a scheduled scale-up at 09:00 and a deployment overlaps it, that scale-up is gone for the day unless you rerun it.
What I'd do this week
If you have custom suspend/resume scripts in your appspec hooks or pipeline, list them and see which ones this replaces. Start with Terminate on one non-critical deployment group, wire up the failure alert, and run a couple of deployments. Then decide whether AZRebalance and ScheduledActions earn a place too.
Do you suspend anything today, or just accept the occasional failed deployment?
Sources
- https://aws.amazon.com/about-aws/whats-new/2026/11/aws-codedeploy-suspend-asg-processes/
- https://docs.aws.amazon.com/codedeploy/latest/userguide/integrations-aws-auto-scaling-suspend-processes.html
- https://docs.amazonaws.cn/en_us/codedeploy/latest/APIReference/API_EC2DeploymentOptions.md
Drafted with AI assistance. I review and edit every post.
