Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

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 PlatformDeployment TypesRollback Method
EC2/On-PremisesIn-Place, Blue/GreenRedeploy previous revision
ECSBlue/Green onlyReroute traffic to original task set
LambdaCanary, Linear, All-at-onceShift 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.

Alvin Varughese
Written byAlvin Varughese•Founder•15 professional certifications