Developer Tools
    🛠️Developer Tools

    AWS CodeDeploy

    Automated application deployment to EC2, Lambda, or on-premises

    CodeDeploy is like a smart deployment robot that updates your applications without downtime. When you have new code to deploy to 100 servers, doing it manually is risky because something breaks halfway through? CodeDeploy automates deployments with strategies like blue/green (deploy to new servers, switch traffic) or rolling (update servers gradually). It monitors deployments and automatically rolls back if errors occur. It's like having a deployment expert who ensures updates happen smoothly, safely, and can be undone if something goes wrong.

    CodeDeploy automates application deployments to EC2, Lambda, ECS, or on-premises servers. You create an application, deployment group (target servers), and deployment configuration (strategy). Deployment strategies: in-place (update existing servers), blue/green (deploy to new servers, switch traffic), canary (deploy to subset first), and linear (gradual rollout). CodeDeploy uses appspec.yml to define deployment steps (stop application, install files, start application).

    Key Capabilities

    • Automates deployments to EC2 fleets, on-premises servers, Lambda functions, and ECS services using a consistent AppSpec file format
    • Supports all-at-once, half-at-a-time, one-at-a-time, and custom deployment configurations to control rollout speed and blast radius
    • Blue/green deployments for EC2 and ECS launch a replacement environment, shift traffic, and then terminate the original after validation
    • Canary and linear traffic shifting for Lambda and ECS gradually move traffic to updated versions over a defined interval
    • Lifecycle event hooks (before install, after install, application start, validate service, and others) run scripts at each deployment phase
    • Automatic rollback triggers redeploy the last known-good revision when a deployment fails or CloudWatch alarms breach defined thresholds

    Gotchas & Constraints

    Gotcha #1: CodeDeploy requires an agent on EC2 instances; ensure the agent is installed and running. Gotcha #2: Blue/green deployments require double capacity temporarily; plan for additional costs. Constraints: Maximum 1,000 instances per deployment group, maximum 25 concurrent deployments per account, and deployment timeout maximum 48 hours.

    A web application runs on 50 EC2 instances behind an ALB. Manual deployments take 2 hours and cause downtime. They implement CodeDeploy with blue/green deployment: CodeDeploy launches 50 new instances (green), deploys new code, runs health checks, and switches ALB traffic from old instances (blue) to new instances. If health checks fail, CodeDeploy automatically rolls back. They configure CloudWatch alarms: if error rate exceeds 5%, trigger automatic rollback. For gradual rollouts, they use canary deployment, deploying to 10% of instances first, monitor for 10 minutes, then deploy to remaining 90%. They integrate CodeDeploy with CodePipeline, so code pushed to GitHub triggers automatic deployment. Deployment time drops from 2 hours to 15 minutes, and downtime is eliminated.

    The Result

    zero-downtime deployments, automatic rollback on errors, and 90% faster releases.

    Official AWS Documentation