2.1.1.5. Deployment Strategies Overview (CodeDeploy)
2.1.1.5. Deployment Strategies Overview (CodeDeploy)
CodeDeploy automates application deployments to EC2 instances, ECS services, Lambda functions, and on-premises servers. The critical concept is that CodeDeploy uses different deployment types depending on the compute platform — and the exam tests whether you can match the right type to the right scenario.
EC2/On-Premises deployments use an appspec.yml that defines lifecycle hooks:
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html
hooks:
BeforeInstall:
- location: scripts/stop_server.sh
timeout: 300
AfterInstall:
- location: scripts/start_server.sh
timeout: 300
ValidateService:
- location: scripts/health_check.sh
timeout: 300
ECS deployments use a different appspec.yml format that specifies the new task definition and container port. CodeDeploy handles the traffic shifting between the original (blue) and replacement (green) target groups behind an ALB.
Lambda deployments shift traffic between function alias versions. appspec.yml specifies BeforeAllowTraffic and AfterAllowTraffic hooks — Lambda functions that run validation before and after the traffic shift.
| Compute Platform | Deployment Types | Rollback Method |
|---|---|---|
| EC2/On-Premises | In-Place, Blue/Green | Redeploy previous revision |
| ECS | Blue/Green only | Reroute traffic to original task set |
| Lambda | Canary, Linear, All-at-once | Shift traffic back to original version |
Exam Trap: EC2 Blue/Green deployments require an Auto Scaling Group — CodeDeploy creates a new ASG with the updated instances, then terminates the original. If your instances aren't in an ASG, Blue/Green is not available and you're limited to In-Place.
