Deployment Strategies and Remediating Deployment Failures
Overview
A deployment strategy is the plan for replacing the running version of an application with a new one. The right choice trades speed, cost, risk and rollback time. The SOA-C03 guide lists "implement deployment strategies and services" and "identify and remediate deployment issues (for example, subnet sizing issues, CloudFormation errors, permissions issues)", so you need to know the strategies and the usual reasons they fail.
Think of replacing the engines of a fleet of buses. You could swap every bus overnight (all at once, cheap but risky), swap a few at a time (rolling), build a full second fleet and switch the routes (blue/green, safest but costly), or send one bus on the new route first and watch the passengers (canary). When a swap fails, you want to know whether it was the parts (subnet size, quotas), the permissions (IAM) or the instructions (template errors).
This lesson maps strategies to AWS services and then gives a troubleshooting table for failed deployments.
Key Concepts
- All at once: fastest, causes downtime; rollback means redeploying. Rolling: updates in batches, reduced capacity during the update. Rolling with additional batch: keeps full capacity. Immutable: new instances in a new ASG, swap on success.
- Blue/green: two environments; shift traffic with Route 53 weights, ALB target group switch, or CodeDeploy blue/green; instant rollback by switching back, double cost during cutover.
- Canary / linear (Lambda aliases, API Gateway stages, CodeDeploy, ECS): send a small percentage, then the rest if alarms stay green; automatic rollback on alarm.
- Elastic Beanstalk policies: All at once, Rolling, Rolling with additional batch, Immutable, Traffic splitting; swap environment URLs for blue/green.
- CodeDeploy supports EC2/on-premises (in-place, blue/green), Lambda and ECS; appspec file and lifecycle hooks; CloudWatch alarms can stop and roll back.
- CloudFormation uses change sets to preview, rollback on failure by default (
UPDATE_ROLLBACK_FAILEDneedscontinue-update-rollback), and UpdatePolicy / CreationPolicy / cfn-signal for ASG rollouts. - Deployment failures usually come from subnet IP exhaustion, quotas, missing IAM permissions, AMI/Region mismatches or failing health checks.
- ECS rolling updates use
minimumHealthyPercentandmaximumPercent; the deployment circuit breaker auto-rolls back failed deployments.
Detailed Notes
Strategy comparison
| Strategy | Downtime | Capacity during deploy | Rollback speed | Cost | Typical service |
|---|---|---|---|---|---|
| All at once | Yes | Zero briefly | Slow (redeploy) | Lowest | Beanstalk, CodeDeploy AllAtOnce |
| Rolling | No | Reduced | Slow | Low | ASG instance refresh, Beanstalk, ECS |
| Rolling + extra batch | No | Full | Slow | Slightly higher | Beanstalk |
| Immutable | No | Full | Fast (terminate new ASG) | Higher | Beanstalk, ASG |
| Blue/green | No | Full | Instant (switch back) | Highest (two stacks) | CodeDeploy, Route 53, ALB, Beanstalk swap |
| Canary / linear | No | Full | Fast (shift back) | Moderate | Lambda, API Gateway, CodeDeploy |
Implementing common strategies
# ASG rolling replacement
aws autoscaling start-instance-refresh --auto-scaling-group-name web \
--preferences '{"MinHealthyPercentage":90,"InstanceWarmup":120,"AutoRollback":true}'
# Lambda canary with a weighted alias
aws lambda update-alias --function-name orders --name live --function-version 7 \
--routing-config AdditionalVersionWeights={"8"=0.1}
# Route 53 weighted shift for blue/green
aws route53 change-resource-record-sets --hosted-zone-id Z123 --change-batch file://shift-10pct.json
# CodeDeploy appspec for EC2/on-premises
version: 0.0
os: linux
files:
- source: /app
destination: /var/www/app
hooks:
BeforeInstall: [ { location: scripts/stop.sh, timeout: 60 } ]
AfterInstall: [ { location: scripts/config.sh, timeout: 60 } ]
ValidateService: [ { location: scripts/health.sh, timeout: 120 } ]
Deployment failure troubleshooting
| Symptom | Likely cause | Remediation |
|---|---|---|
InsufficientFreeAddressesInSubnet | Subnet too small / IPs exhausted (AWS reserves 5 per subnet; ENIs for Lambda, ECS, EKS pods consume addresses) | Add larger or additional subnets (secondary CIDR), spread across AZs, plan with IPAM |
InstanceLimitExceeded / VcpuLimitExceeded | Service Quotas | Request increase |
UnauthorizedOperation, AccessDenied | Missing IAM permissions or SCP/permission boundary; wrong CloudFormation service role | Decode message with aws sts decode-authorization-message; grant specific actions |
CREATE_FAILED with "resource already exists" | Hard-coded names, retained resources | Remove names or use generated names |
ROLLBACK_COMPLETE stack | Create failed and rolled back; cannot update | Delete and recreate after fixing the cause |
UPDATE_ROLLBACK_FAILED | Rollback could not restore a resource | Fix cause (or skip resources) and continue-update-rollback |
Timeout waiting for cfn-signal | Instance bootstrap failed | Check /var/log/cfn-init.log, cloud-init-output.log, security group egress to CloudFormation endpoint |
| ECS or ALB targets unhealthy after deploy | Wrong health check path/port, security group, slow startup | Fix health check, add grace period |
| CodeDeploy hook failure | Script error or timeout | Check /opt/codedeploy-agent/deployment-root logs |
| Image/AMI not found | AMI is Region-specific or not shared | Copy/share AMI, use SSM parameter public AMI lookups |
aws cloudformation describe-stack-events --stack-name web --query "StackEvents[?contains(ResourceStatus,'FAILED')].[LogicalResourceId,ResourceStatusReason]" --output table
aws cloudformation continue-update-rollback --stack-name web --resources-to-skip LogicalId1
aws cloudformation create-change-set --stack-name web --change-set-name preview --template-body file://t.yaml
aws ec2 describe-subnets --subnet-ids subnet-0abc --query "Subnets[0].AvailableIpAddressCount"
Subnet sizing guidance
- A /24 has 256 addresses but only 251 usable (first four and last address reserved).
- Lambda in a VPC, ECS awsvpc tasks and EKS pods (VPC CNI) each use an IP; plan for scale-out and rolling updates that temporarily double the count.
- Add secondary CIDR blocks to a VPC or use custom networking and prefix delegation for EKS when addresses run short.
- Keep one subnet per AZ per tier and monitor
AvailableIpAddressCountwith a custom metric or Config rule.
Rolling back safely
Always define the rollback trigger before the deployment: CloudWatch alarms on 5xx rate, latency and health host count tied to CodeDeploy, Lambda alias traffic shifting or ECS circuit breaker. For CloudFormation use change sets, stack policies and termination protection for critical stacks.
Real World Example
Scenario – failed scale-out during a release. A retailer runs a rolling update on an ECS service with awsvpc networking in /26 private subnets. The new deployment starts extra tasks, then fails with ResourceInitializationError: ... failed to create network interface as the subnets run out of IP addresses.
The operator confirms AvailableIpAddressCount is 0, adds a secondary CIDR with larger subnets in each AZ and updates the service. They enable the deployment circuit breaker so a failing rollout rolls back automatically and create a Config rule and alarm on subnet free IPs. For the next release they use CodeDeploy blue/green with a 10% canary and alarm-based rollback.
Architecture Diagram
- 1Deploy the new version to the green environment while blue serves all traffic.
- 2Shift a small percentage of traffic to green and watch health and error alarms.
- 3If alarms stay green, increase traffic in steps until green takes 100%.
- 4If an alarm fires, traffic shifts back to blue automatically for instant rollback.
- 5Terminate the old environment after a bake period.
Best Practices
- ✓Choose blue/green or canary with alarm-based automatic rollback for customer-facing production services.
- ✓Preview CloudFormation updates with change sets and protect critical stacks with stack policies and termination protection.
- ✓Size subnets for peak and rolling-update IP use; monitor free addresses and use secondary CIDRs when needed.
- ✓Use service roles with least privilege for CloudFormation and CodeDeploy and test with
decode-authorization-message. - ✓Enable the ECS deployment circuit breaker and ASG instance refresh with auto rollback.
Common Interview Questions
Exam Tips
SOA-C03 focus
- Instant rollback, no downtime -> blue/green; gradual exposure with auto rollback -> canary/linear with alarms.
- Subnet IP exhaustion -> larger subnets or secondary CIDR; AWS reserves 5 addresses per subnet.
- Stack stuck after failed rollback -> continue-update-rollback; failed create leaves ROLLBACK_COMPLETE (delete and recreate).
- Permissions failures -> read the exact denied action, check IAM, SCPs, boundaries and the CloudFormation service role.
Finished this lesson?
0 of 46 lessons done · 0% of the course

