Install the ECS Agent
Option 1: Daemon service (EC2 capacity)
Section titled “Option 1: Daemon service (EC2 capacity)”# Terraform snippetresource "aws_ecs_task_definition" "clustercost" { family = "clustercost-agent" network_mode = "bridge" cpu = 256 memory = 512 requires_compatibilities = ["EC2"] container_definitions = jsonencode([ { name = "agent" image = "ghcr.io/clustercost/ecs-agent:latest" environment = [{ name = "CLUSTERCOST_CLUSTER", value = "payments-prod" }] } ])}Run one copy per instance using an ECS service with the DAEMON scheduling strategy.
Option 2: Sidecar (Fargate)
Section titled “Option 2: Sidecar (Fargate)”Add a second container to an existing task definition:
{ "name": "clustercost-agent", "image": "ghcr.io/clustercost/ecs-agent:latest", "essential": false, "environment": [ { "name": "CLUSTERCOST_SERVICE", "value": "sync-worker" } ]}In both cases, grant the task IAM permissions for ecs:Describe* and cloudwatch:GetMetricData so it can resolve usage details and match them to AWS pricing.