基于标签从 EC2 实例创建镜像
我们已经在AWS中创建了一个环境并配置了所有实例。我们有带有 NAME
和 ENVIRONMENT
标签的实例。
我们希望制作带有特定环境
标签的所有实例的图像。我可以使用 aws ec2 describe-instances --query
查询环境并提取标签(例如 Environment=TEST
),但不知道如何从这里开始,以便可以通过编程方式对带有环境标记 TEST
的所有实例进行映像。
这是我用来提取 NAME
和 ENVIRONMENT
标签信息的命令:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论