How can I connect my autoscaling group to my ecs cluster?

cari picture cari · Feb 4, 2016 · Viewed 9.7k times · Source

In all tutorials for ECS you need to create a cluster and after that an autoscaling group, that will spawn instances. Somehow in all these tutorials the instances magically show up in the cluster, but noone gives a hint what's connecting the autoscaling group and the cluster.

my autoscaling group spawns instances as expected, but they just dont show up on my ecs cluster, who holds my docker definitions.

Where is the connection I'm missing?

Answer

volker238 picture volker238 · Feb 10, 2016

I was struggling with this for a while. The key to getting the instances in the autoscaling group associated with your ECS cluster is in the user data. When you are creating your launch config when you get to step 3 "Configure Details" hit the advanced tab and enter a simple bash script like the following for your user data.

#!/usr/bin/env bash
echo ECS_CLUSTER=your_cluster_name >> /etc/ecs/ecs.config

All the available parameters for agent configuration can be found here http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html