AWS for DevOps — Deployment Strategies
6.4 — Deployment Strategies
Choosing the right deployment strategy is the difference between a seamless release and a 3 a.m. incident. AWS CodeDeploy and ECS support several strategies out of the box.
Strategy Comparison
| Strategy | Downtime | Rollback Speed | Risk | Best For |
|---|---|---|---|---|
| In-place | Brief | Slow (re-deploy old version) | Medium | Dev/staging, cost-sensitive |
| Rolling | Zero | Medium | Low–Medium | Fleet of EC2 instances |
| Blue/Green | Zero | Instant (switch back) | Low | Production, ECS, Lambda |
| Canary | Zero | Fast (shift traffic back) | Very Low | High-traffic production |
| All-at-once | Brief | Slow | High | Non-critical environments |
In-Place Deployment
Each instance is updated one at a time (or in batches). The old version is stopped, new version installed.
Instance A Instance B Instance C
┌──v1──┐ ┌──v1──┐ ┌──v1──┐
│ │ │ │ │ │
└──────┘ └──────┘ └──────┘
│
▼ (take offline, update)
┌──v2──┐ ┌──v1──┐ ┌──v1──┐
│ ✓ │ │ │ │ │
└──────┘ └──────┘ └──────┘
│
▼ (take offline, update)
┌──v2──┐ ┌──v2──┐ ┌──v1──┐
│ ✓ │ │ ✓ │ │ │
└──────┘ └──────┘ └──────┘
$ aws deploy create-deployment-group \
--application-name my-app \
--deployment-group-name staging \
--deployment-config-name CodeDeployDefault.OneAtATime \
--deployment-style deploymentType=IN_PLACE,deploymentOption=WITHOUT_TRAFFIC_CONTROL
Blue/Green Deployment
A complete parallel environment is created. Traffic shifts from old (blue) to new (green) after validation.
Load Balancer
│
┌────┴────┐
│ │
▼ ▼
Blue Green
(v1) (v2)
┌───┐ ┌───┐
│ A │ │ D │ ◀── new instances provisioned
│ B │ │ E │
│ C │ │ F │
└───┘ └───┘
Step 1: Green instances created, v2 deployed
Step 2: Health checks pass on Green
Step 3: ALB shifts traffic Blue → Green
Step 4: Blue instances terminated (or kept for rollback)
CodeDeploy (EC2 Blue/Green):
$ aws deploy create-deployment-group \
--application-name my-app \
--deployment-group-name production \
--deployment-style deploymentType=BLUE_GREEN,deploymentOption=WITH_TRAFFIC_CONTROL \
--blue-green-deployment-configuration \
terminateBlueInstancesOnDeploymentSuccess={action=TERMINATE,terminationWaitTimeInMinutes=60},\
deploymentReadyOption={actionOnTimeout=CONTINUE_DEPLOYMENT,waitTimeInMinutes=0},\
greenFleetProvisioningOption={action=COPY_AUTO_SCALING_GROUP} \
--load-balancer-info targetGroupInfoList=[{name=my-app-tg}]
ECS Blue/Green (built-in):
$ aws ecs create-service \
--cluster production \
--service-name my-app \
--task-definition my-app:3 \
--deployment-controller type=CODE_DEPLOY \
--load-balancers targetGroupArn=arn:aws:elasticloadbalancing:...:targetgroup/blue-tg/abc,containerName=my-app,containerPort=8080
Canary Deployment
Traffic is shifted in two increments: a small percentage first (canary), then the rest after validation.
100% traffic
│
┌────┴────┐
│ 90% │ 10%
▼ ▼
v1 v2 (canary)
┌───┐ ┌───┐
│ A │ │ D │ ◀── small slice first
│ B │ │ │
│ C │ │ │
└───┘ └───┘
After X minutes (if healthy):
0% │ 100%
▼
v2
┌───┐
│ D │ ◀── full traffic shift
│ E │
│ F │
└───┘
CodeDeploy Canary Configs:
| Configuration | Behaviour |
|---|---|
CodeDeployDefault.ECSCanary10Percent5Minutes |
10% for 5 min, then 100% |
CodeDeployDefault.ECSCanary10Percent15Minutes |
10% for 15 min, then 100% |
CodeDeployDefault.LambdaCanary10Percent5Minutes |
Same pattern for Lambda |
Custom canary config:
$ aws deploy create-deployment-config \
--deployment-config-name Canary25Percent10Minutes \
--compute-platform ECS \
--traffic-routing-config \
type=TimeBasedCanary,\
timeBasedCanary={canaryPercentage=25,canaryInterval=10}
Linear Deployment
Traffic shifts in equal increments at regular intervals.
| Configuration | Behaviour |
|---|---|
CodeDeployDefault.ECSLinear10PercentEvery1Minute |
+10% every minute |
CodeDeployDefault.ECSLinear10PercentEvery3Minutes |
+10% every 3 minutes |
CodeDeployDefault.LambdaLinear10PercentEvery1Minute |
Same for Lambda |
Choosing a Strategy — Decision Flow
Can you afford downtime?
│
Yes │ No
│ │
▼ ▼
All-at-once Do you need instant rollback?
or In-place │
Yes │ No
│ │
▼ ▼
Blue/Green Rolling
│
▼
Is this high-traffic production?
│
Yes │ No
│ │
▼ ▼
Canary Blue/Green
Rollback Comparison
| Strategy | Rollback Method | Time to Rollback |
|---|---|---|
| In-place | Re-deploy previous revision | Minutes (full deploy cycle) |
| Rolling | Re-deploy previous revision | Minutes |
| Blue/Green | Switch traffic back to Blue | Seconds |
| Canary | Stop traffic shift, route all to v1 | Seconds |
Common Mistakes
| Mistake | Why It Hurts | Fix |
|---|---|---|
| Using All-at-once in production | Full outage if deploy fails | Use Blue/Green or Canary |
| Blue/Green without health checks | Bad version receives 100% traffic | Configure ALB health checks |
| Terminating Blue too fast | Can’t rollback if issues found later | Keep Blue for 30-60 minutes |
| No CloudWatch alarms on canary | Canary proceeds even if errors spike | Set deployment alarms |
Quick Reference
| Task | Command |
|---|---|
| In-place deploy | --deployment-style deploymentType=IN_PLACE |
| Blue/Green deploy | --deployment-style deploymentType=BLUE_GREEN |
| Create canary config | aws deploy create-deployment-config --traffic-routing-config type=TimeBasedCanary,... |
| Create linear config | aws deploy create-deployment-config --traffic-routing-config type=TimeBasedLinear,... |
| Stop deployment | aws deploy stop-deployment --deployment-id ID |
Next → GitHub as Source