Mastering ECS Managed Daemons: A Platform Engineer's Guide to Decoupled Agent Management
Create a daemon task definition for a CloudWatch Agent, deploy to ECS Managed Instances, and decouple agent lifecycle from apps. Covered prerequisites, steps, common pitfalls.
Overview
Platform engineers managing containerized workloads at scale often face a tight coupling between operational agents (monitoring, logging, tracing) and application deployments. Updating a monitoring agent previously meant coordinating with application teams, modifying task definitions, and redeploying entire services — a significant operational burden across hundreds or thousands of services. Amazon ECS now introduces managed daemon support for ECS Managed Instances, enabling you to decouple the lifecycle of these agents from your application containers. This guide walks you through the complete setup, from understanding the architecture to deploying your first daemon using the Amazon CloudWatch Agent.

Managed daemons provide independent control for platform engineers over software agents, ensuring every instance runs required daemons consistently. Daemons start before application tasks and drain last, guaranteeing logging, tracing, and monitoring are always available when your application needs them. Resource management is centralized — you define CPU and memory separately from application configurations, with no need to rebuild AMIs or update task definitions. Each instance runs exactly one daemon copy shared across multiple application tasks, optimizing resource utilization.
Prerequisites
Before you begin, ensure you have the following:
- An AWS account with permissions to create and manage ECS resources.
- An existing Amazon ECS cluster with a Managed Instance capacity provider (created using the official documentation).
- A task execution IAM role (e.g.,
ecsTaskExecutionRole) that grants the ECS agent permissions to pull images, write logs, and interact with AWS services. The role must include policies for the daemon container (e.g.,CloudWatchAgentServerPolicyfor the CloudWatch agent). - Basic familiarity with the Amazon ECS console and container concepts.
Step-by-Step Instructions
1. Access the Daemon Task Definitions Section
Open the Amazon ECS console. In the left navigation pane, you will notice a new option: Daemon task definitions. This is where you define your managed daemons – a dedicated construct that separates operational tooling from application tasks.
2. Create a New Daemon Task Definition
Click Create new daemon task definition. You'll see a form similar to standard task definitions, but tailored for daemon management. For this example, we'll configure the CloudWatch Agent as our first daemon.
- Daemon task definition family: Provide a recognizable name, e.g.,
cloudwatch-agent-daemon. - Task execution role: Select the IAM role you prepared (e.g.,
ecsTaskExecutionRole) from the dropdown. - Container definitions: Add a container. Use the official CloudWatch Agent image:
public.ecr.aws/cloudwatch-agent/cloudwatch-agent:latest. - Resource allocation: Set the CPU and memory for the daemon. For the CloudWatch Agent, 1 vCPU and 0.5 GB memory are sufficient. These resources are allocated per instance, independent of your application tasks.
- Optionally, configure environment variables, log configuration, or mount points as needed for your agent.
Review and create the daemon task definition.
3. Deploy the Daemon to Your Cluster
After creation, you’ll be taken to the daemon task definition details page. To deploy:
- Click Deploy.
- Select your target ECS cluster and the Managed Instance capacity provider(s) where you want the daemon to run. You can deploy across multiple capacity providers for broad coverage, or target specific ones for controlled rollouts.
- Specify any advanced settings (e.g., daemon startup ordering — but note that daemons automatically start before application tasks and drain last).
- Click Deploy daemon.
ECS will now ensure every instance in the targeted capacity providers runs exactly one copy of the CloudWatch Agent daemon. The daemon starts before any application tasks and will be the last to stop during instance termination or scale-in events.

4. Verify the Daemon is Running
Navigate to your cluster and then to the Tasks tab. You should see the daemon task(s) running with a status of RUNNING on each instance. You can also check the CloudWatch console to confirm metrics are being collected from your instances.
5. Update a Managed Daemon
To update the agent (e.g., a new version), simply create a new revision of the daemon task definition (with the same family name) and redeploy. ECS performs a rolling update across instances, starting the new daemon before stopping the old one, ensuring zero downtime for monitoring. Application teams need no involvement — their tasks continue running unaffected.
Common Mistakes and How to Avoid Them
- Missing execution role permissions: The task execution role must include policies for the daemon’s actions (e.g.,
CloudWatchAgentServerPolicyfor CloudWatch, orAmazonSSMManagedInstanceCorefor Systems Manager agents). Without correct permissions, daemon containers will fail to start. Double-check the role before deployment. - Targeting the wrong capacity provider: Daemons only deploy to Managed Instance capacity providers. Ensure your cluster has at least one such provider created and attached. If you target a non-managed provider, the deployment will be ignored.
- Resource contention with application tasks: While managed daemons share the instance with application tasks, setting too-large CPU/memory for the daemon may leave insufficient resources for your services. Monitor utilization and adjust daemon resources accordingly. Use the centralized resource management to tune independently.
- Forgetting to update daemon task definitions: Daemon task definitions are separate from application task definitions. When updating an agent, create a new revision of the daemon definition and redeploy—do not modify the application task definitions. This ensures decoupled lifecycle management.
- Assuming daemons automatically update: Managed daemons do not auto-update. You must actively create new revisions and redeploy to roll out changes. This gives you controlled rollout flexibility.
Summary
ECS managed daemons empower platform engineers to independently manage operational agents across their infrastructure, eliminating the need to coordinate with application teams for every agent update. By creating a dedicated daemon task definition and deploying it to your Managed Instance capacity providers, you ensure consistent, reliable monitoring, logging, and tracing across all instances. The daemons start before and drain after application tasks, guaranteeing uptime. With centralized resource management and decoupled lifecycle, you can optimize instance utilization and simplify operations at scale. Start with a simple agent like the CloudWatch Agent, and expand to logging or tracing agents as needed. Adopt this pattern to bring platform engineering best practices to your ECS environment.