Search⌘ K
AI Features

AWS CodeDeploy in Depth: Deployments, Strategies, and Rollbacks

Explore AWS CodeDeploy to understand how to deploy application revisions safely and reversibly. This lesson covers deployment objects, configurations for EC2, Lambda, and ECS platforms, and rollback mechanisms. Learn to analyze failed deployments using logs and error codes, and manage traffic shifting with deployment strategies and AWS SAM integration.

A new revision has to reach production without taking the application down, and it has to be reversible when it misbehaves. AWS CodeDeploy covers both needs: it copies the revision to the target, runs validation at defined points, decides how fast traffic or instances move to the new version, and redeploys the last good revision when something goes wrong.

This lesson covers what a developer operates day to day: the CodeDeploy objects, the deployment configurations, the appspec for each compute platform, rollback settings, and the logs that explain a failed deployment.

CodeDeploy building blocks

A CodeDeploy setup is a small set of objects that every deployment refers to:

  • Application: A name that groups everything CodeDeploy deploys for one app. It also records the compute platform: EC2/on-premises, AWS Lambda, or Amazon ECS.

  • Revision: The deployable bundle, consisting of the application files plus the appspec.yml file. For EC2/on-premises, a revision is a zip, tar, or tgz archive in Amazon S3, or a commit in GitHub or Bitbucket. For Lambda and ECS, the revision is just an appspec file that names the function version or task definition.

  • Deployment group: The target and the rules. For EC2, it selects instances by tags, Amazon EC2 Auto Scaling groups, or both. It also holds the deployment configuration, the service role, the load balancer, the rollback settings, and the CloudWatch alarms to watch.

  • Deployment configuration: The rule for how fast the revision spreads and how many failures are tolerated.

  • Service role: The IAM role CodeDeploy assumes to read instance tags, work with Auto Scaling and load balancers, and invoke Lambda functions on our behalf.

  • CodeDeploy agent: A process installed on every EC2 or on-premises instance. It polls CodeDeploy, downloads the revision, and runs the appspec hooks. Lambda and ECS deployments need no agent.

The instance needs its own permissions as well. The instance profile must allow reading the revision from S3, ...