We're using Amazon ECS for our services. We have a cluster called application
and within that cluster, we have several services:
- dev_app
- dev_kafka
- dev_zookeeper
- qa_app
- qa_kafka
- qa_zookeeper
- etc.
And the services pull from task definitions that have correlating constraints, i.e., memberOf(attribute:env == qa), memberOf(attribute:role == zookeeper)
We launch our instances via EC2 launch configurations + Autoscaling Groups. This means that our services can't actually auto-scale right now, because instances launch without the appropriate attributes. The only way I know how to add the attributes currently is to wait for the instance to be added to the application
cluster, and go in to manually add custom attributes to each instance.
The question: Can I somehow add instance attributes via the launch configuration, or some other means, at launch?
I've found modify-instance-attribute
, but this only seems to be valid for existing attributes, not custom attributes. I've also tried put-attributes
, but this seems to only be valid for ECS resources (my instance ARN is apparently invalid).
Use "user data" in launch configuration.
echo ECS_INSTANCE_ATTRIBUTES={\"mycostomattr\":\"myvalue\"} >> /etc/ecs/ecs.config
See http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html