基于标签从 EC2 实例创建镜像

发布于 2025-01-15 23:24:22 字数 621 浏览 1 评论 0原文

我们已经在AWS中创建了一个环境并配置了所有实例。我们有带有 NAMEENVIRONMENT 标签的实例。

我们希望制作带有特定环境标签的所有实例的图像。我可以使用 aws ec2 describe-instances --query 查询环境并提取标签(例如 Environment=TEST),但不知道如何从这里开始,以便可以通过编程方式对带有环境标记 TEST 的所有实例进行映像。

这是我用来提取 NAMEENVIRONMENT 标签信息的命令:

aws ec2 describe-instances --query "Reservations\[*\].Instances\[*\].{Name:Tags\[?Key=='Name'\],Environment:Tags\[?Key=='Environment'\]|\[0\].Value,Status:State.Name}"  --filters "Name=instance-state-name,Values=running"

We have created an environment in AWS and configured all the instances. We have the instances tagged with NAME and ENVIRONMENT tags.

We would like to make images of all the instances tagged with a specific Environment tag. I'm able query the environment with aws ec2 describe-instances --query and pull the tags (ex, Environment=TEST), but can't figure out how to proceed from here so that all instances with the environment tag TEST can be imaged programmatically.

This was the command I used to pull the NAME and ENVIRONMENT tag info:

aws ec2 describe-instances --query "Reservations\[*\].Instances\[*\].{Name:Tags\[?Key=='Name'\],Environment:Tags\[?Key=='Environment'\]|\[0\].Value,Status:State.Name}"  --filters "Name=instance-state-name,Values=running"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文