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

2.1.4.6. Configuring Deployment Agents (CodeDeploy Agent)

First Principle: The deployment agent acts as a secure, authorized executor on the target instance, enabling the centralized deployment service to manage application updates remotely.

For deployments to Amazon EC2 instances or on-premises servers using AWS CodeDeploy, a deployment agent must be installed and configured on the target instances. This agent is the crucial link that allows CodeDeploy to interact with the instance and manage the application deployment.

AWS CodeDeploy Agent Configuration:
  • Purpose: The CodeDeploy agent is a software package that runs on your instances and communicates with the CodeDeploy service. It pulls deployment instructions and application revisions from CodeDeploy and executes them on the instance.
  • Installation: The agent must be installed on each target EC2 instance or on-premises server. AWS provides scripts and instructions for various operating systems.
  • Configuration:
    • IAM Role: The EC2 instance (or on-premises server) must have an IAM instance profile (or credentials for on-premises) with permissions to communicate with CodeDeploy and access deployment artifacts (e.g., from S3).
    • appspec.yml: This file, included in your application revision, defines the deployment lifecycle hooks (e.g., BeforeInstall, AfterInstall, ApplicationStart) and specifies which files to copy and where. The agent executes these hooks.
  • Health Checks: The agent reports the status of deployment lifecycle events back to the CodeDeploy service.

Scenario: A DevOps team is setting up AWS CodeDeploy to deploy applications to a fleet of EC2 instances. They need to ensure that CodeDeploy can remotely control these instances to install application updates and manage the deployment lifecycle.

Reflection Question: How does installing and properly configuring the CodeDeploy agent on EC2 instances, along with the necessary IAM instance profile and an appspec.yml file, enable centralized and automated application updates?

Properly configuring the CodeDeploy agent is essential for successful and automated deployments to instances.

šŸ’” Tip: Automate the installation and configuration of the CodeDeploy agent as part of your AMI build process (e.g., using EC2 Image Builder) or instance bootstrapping (e.g., User Data) to ensure consistency.