2.1.4.4. Tools for Code Distribution (CodeDeploy, EC2 Image Builder)
2.1.4.4. Tools for Code Distribution (CodeDeploy, EC2 Image Builder)
Code distribution is the mechanism that gets your artifact from the repository to the running compute instance. The tool depends on the deployment strategy and compute platform.
AWS CodeDeploy distributes application bundles to EC2 instances, ECS services, and Lambda functions. For EC2, the CodeDeploy agent on each instance pulls the deployment bundle from S3 and executes the appspec.yml lifecycle hooks. CodeDeploy tracks deployment progress per instance and can automatically roll back if too many instances fail health checks.
EC2 Image Builder distributes pre-baked AMIs. Rather than deploying code to running instances, you bake the entire application into an AMI and launch fresh instances. Distribution settings control which regions and accounts receive the AMI.
AWS Systems Manager Distributor distributes software packages (agents, drivers, custom packages) to managed instances. Use it for one-time installs or keeping software up-to-date across a fleet.
Comparison for the exam:
| Scenario | Tool | Why |
|---|---|---|
| Deploy app code to running EC2s | CodeDeploy | Handles rolling/blue-green with hooks |
| Distribute a new base AMI | Image Builder | Bakes and distributes immutable images |
| Install an agent on 500 instances | SSM Distributor | Fleet-wide package management |
| Deploy container to ECS | CodeDeploy (ECS) | Manages blue/green target group switching |
| Deploy new Lambda version | CodeDeploy (Lambda) | Traffic shifting between alias versions |
Exam Trap: CodeDeploy for EC2 requires the CodeDeploy agent installed and running on every target instance. If instances in an ASG are launched from an AMI that doesn't include the agent, deployments fail silently. Bake the agent into your AMI or install it via user data.
