Volume 9 · Chapter 10 — CI/CD, DevOps and Infrastructure as Code
Deployment Strategies with CodeDeploy
10.1 Introduction
The safe-deployment concepts (rolling, blue-green, canary) have concrete AWS implementations in CodeDeploy’s deployment configurations, which differ by compute target (EC2, ECS, Lambda). The exam tests these specifics - in-place vs blue-green, and the canary/linear/all-at-once traffic-shifting options - so this chapter maps the concepts to CodeDeploy’s mechanics.
10.2 In-Place vs Blue-Green Deployments
CodeDeploy supports two fundamental approaches. Anin-placedeployment updates the application on theexistinginstances (taking some out of service, updating, returning them - like a rolling update); it’s cheaper (no new fleet) but the same instances are modified and rollback means redeploying the old version. Ablue-greendeployment provisions anewenvironment (green) with the new version, tests it, then shifts traffic from blue to green - giving instant rollback (shift back) and no in-service modification, at the cost of running two environments briefly. For ECS and Lambda, CodeDeploy deployments are inherently blue-green/traffic-shifting. The exam pattern: in-place for cost-sensitive EC2 rolling updates; blue-green for fast, safe rollback and zero in-place modification.
flowchart TB
Q{Deployment approach?} -->|Update existing instances| IP[In-place - rolling, cheaper, redeploy to roll back]
Q -->|New environment, shift traffic| BG[Blue-green - instant rollback, two environments]
BG --> Shift{Traffic shift config}
Shift --> Canary[Canary - X% then rest]
Shift --> Linear[Linear - equal increments over time]
Shift --> AllAtOnce[All-at-once] 10.3 Traffic-Shifting Configurations
For blue-green and Lambda/ECS deployments, CodeDeploy offers deployment configurations that control how traffic shifts to the new version.Canary: shift a small percentage first, wait, then shift the rest (e.g. Canary10Percent5Minutes) - catches problems while few users are affected.Linear: shift in equal increments at set intervals (e.g. Linear10PercentEvery1Minute) - gradual.All-at-once: shift everything immediately (fastest, riskiest). During the shift,CloudWatch alarmsand validation hooks can triggerautomatic rollbackif the new version misbehaves. The exam expects you to match the config to risk tolerance: canary or linear for careful, health-monitored rollouts with fast rollback; all-at-once only for low-risk changes.
10.4 Lambda and ECS Deployments
ForLambda, CodeDeploy shifts traffic between functionversionsusing an alias (the weighted-alias mechanism), applying canary/linear/all-at-once with pre/post-traffic validation hooks and automatic rollback on alarm - the standard safe serverless deployment. ForECS, CodeDeploy blue-green creates a new task set and shifts the load balancer’s traffic to it, with validation and rollback. Both integrate with the pipeline so production deployments are automated, health-gated, and reversible. This ties the safe-deployment strategy directly to the compute target’s CodeDeploy mechanics - which the professional exam expects you to know per target (EC2 in-place/blue-green, Lambda alias traffic-shifting, ECS task-set blue-green).
10.5 Banking Production Scenario
A bank deploys its ECS microservices with CodeDeploy blue-green: a new task set is created, the ALB shifts traffic canary-style (10% for 5 minutes) while CloudWatch alarms watch error rate and latency, and any breach triggers automatic rollback to the original task set. Lambda functions deploy via weighted-alias canary shifting with pre/post-traffic validation hooks. A low-risk internal EC2 app uses in-place rolling deployment for cost. All deployments run through CodePipeline with a production approval gate and cross-account deployment. Because every production rollout is health-gated and instantly reversible, the bank deploys frequently to critical systems with minimal risk - exactly the professional-level safe-deployment design the certification targets.
10.6 Chapter Revision Notes
- In-place deployment updates existing instances (cheaper, rolling, redeploy to roll back); blue-green provisions a new environment and shifts traffic (instant rollback, two environments).
- Traffic-shifting configs: canary (small % then rest), linear (equal increments over time), all-at-once (immediate) - with CloudWatch-alarm-triggered automatic rollback.
- Lambda deployments shift traffic between versions via a weighted alias with validation hooks; ECS blue-green creates a new task set and shifts the load balancer.
- Match the config to risk: canary/linear for careful health-monitored rollouts, all-at-once for low-risk changes.
- CodeDeploy integrates with CodePipeline for automated, health-gated, reversible production deployments.