查找所有没有特定标签的 Amazon AWS 实例 [英] Finding all Amazon AWS Instances That Do Not Have a Certain Tag

查看:12
本文介绍了查找所有没有特定标签的 Amazon AWS 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Amazon AWS 命令​​行工具查找没有指定标签的所有实例.

I'm trying to use the Amazon AWS Command Line Tools to find all instances that do not have a specified tag.

查找带有标签的所有实例非常简单,例如

Finding all instances WITH a tag is simple enough, e.g.

ec2-describe-instances --filter "tag-key=Name"

但是我如何反转过滤器以仅返回没有标签名称"的实例?

But how would I invert that filter to return only the instances that have no tag "Name"?

推荐答案

你可以用 jmespath(驱动 --query 参数的引擎)做到这一点,不管别人怎么说:

You can do that with jmespath (the engine that drives the --query parameter) despite what others say:

aws ec2 describe-instances 
  --query 'Reservations[].Instances[?!not_null(Tags[?Key == `Name`].Value)] | []'

来源:使用亚马逊网络服务用于查找没有名称"标签的实例的命令行界面 (AWS CLI).

这篇关于查找所有没有特定标签的 Amazon AWS 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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