如何在 elastic-beanstalk 创建的 ec2 实例上设置标签
How can I set tags on ec2 instances created by elastic-beanstalk
有没有办法从 Beanstalk 做到这一点?
还是我必须在新实例通过 .ebextensions 或类似的东西启动后自己做?
如果您想在 Elastic Beanstalk 实例中设置标签,您当然可以通过 SSH 登录、安装 AWS CLI 并通过命令行设置标签。或者,您在 Beanstalk 上部署的任何应用程序都可以通过 SDK 执行此操作(例如 Java)。
通过 CLI:
http://docs.aws.amazon.com/cli/latest/reference/ec2/create-tags.html
create-tags [--dry-run | --no-dry-run] --resources <value> --tags <value> [--cli-input-json <value>] [--generate-cli-skeleton]
(伪代码)
Authorize via credentials
Instantiate CreateTagsRequest with specific resource ID
call setTags(Collection<<**String**>> tags) on the CreateTagsRequest object
从环境外部,您可以通过控制台或 EB CLI 设置标签。
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.tagging.html
eb create --tags mytag1=value1,mytag2=value2
注意,您还可以通过 eb create 设置常规环境变量。
eb create --envvars key=value
回答
1. 为了在 elastic beanstalk 中拥有可以应用于为该环境创建的任何 ec2 实例的标签 - 它们必须在环境创建期间设置。
2. 对于现有环境,保存配置、创建替代环境、正确设置标签和交换 URL 非常简单,直到您正确配置原始环境。
这家伙解释得很好:http://www.boringgeek.com/add-or-update-tags-on-existing-elastic-beanstalk-environments/
在提出此问题时此功能不可用。有 many requests for this ever since the tagging feature was first introduced in 2014。
更新 EB 标签的支持最终是 added in Oct 2017。
您现在可以在 Beanstalk Management Console, with the EB CLI or with the AWS CLI 中管理标签。
有没有办法从 Beanstalk 做到这一点? 还是我必须在新实例通过 .ebextensions 或类似的东西启动后自己做?
如果您想在 Elastic Beanstalk 实例中设置标签,您当然可以通过 SSH 登录、安装 AWS CLI 并通过命令行设置标签。或者,您在 Beanstalk 上部署的任何应用程序都可以通过 SDK 执行此操作(例如 Java)。
通过 CLI:
http://docs.aws.amazon.com/cli/latest/reference/ec2/create-tags.html
create-tags [--dry-run | --no-dry-run] --resources <value> --tags <value> [--cli-input-json <value>] [--generate-cli-skeleton]
(伪代码)
Authorize via credentials
Instantiate CreateTagsRequest with specific resource ID
call setTags(Collection<<**String**>> tags) on the CreateTagsRequest object
从环境外部,您可以通过控制台或 EB CLI 设置标签。 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.tagging.html
eb create --tags mytag1=value1,mytag2=value2
注意,您还可以通过 eb create 设置常规环境变量。
eb create --envvars key=value
回答 1. 为了在 elastic beanstalk 中拥有可以应用于为该环境创建的任何 ec2 实例的标签 - 它们必须在环境创建期间设置。 2. 对于现有环境,保存配置、创建替代环境、正确设置标签和交换 URL 非常简单,直到您正确配置原始环境。
这家伙解释得很好:http://www.boringgeek.com/add-or-update-tags-on-existing-elastic-beanstalk-environments/
在提出此问题时此功能不可用。有 many requests for this ever since the tagging feature was first introduced in 2014。
更新 EB 标签的支持最终是 added in Oct 2017。
您现在可以在 Beanstalk Management Console, with the EB CLI or with the AWS CLI 中管理标签。