Skip to content

Install the ECS Agent

# Terraform snippet
resource "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.

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.