如何在启动时添加EC2实例属性? [英] How can you add EC2 instance attributes at launch?

查看:89
本文介绍了如何在启动时添加EC2实例属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将Amazon ECS用于我们的服务.我们有一个名为application的集群,并且在该集群中,我们有一些服务:

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.

并且服务从具有相关约束(即memberOf(attribute:env == qa), memberOf(attribute:role == zookeeper)

And the services pull from task definitions that have correlating constraints, i.e., memberOf(attribute:env == qa), memberOf(attribute:role == zookeeper)

我们通过EC2启动配置+ Autoscaling组启动实例.这意味着我们的服务目前无法立即自动扩展,因为实例启动时没有适当的属性.我知道当前如何添加属性的唯一方法是等待将实例添加到application群集,然后手动向每个实例添加自定义属性.

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?

我找到了 modify-instance-attribute ,但这似乎仅对现有属性有效,而对自定义属性无效.我也尝试过 put-attributes ,但这似乎仅对ECS资源有效(我的实例ARN显然无效).

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

请参见 http://docs.aws.amazon .com/AmazonECS/latest/developerguide/ecs-agent-config.html

这篇关于如何在启动时添加EC2实例属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆