Finding all Amazon AWS Instances That Do Not Have a Certain Tag

前端 未结 9 2032
借酒劲吻你
借酒劲吻你 2020-12-23 12:09

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.<

9条回答
  •  半阙折子戏
    2020-12-23 12:17

    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)] | []'
    

    Source: Using Amazon Web Services Command Line Interface (AWS CLI) to Find Instances without a 'Name' Tag.

提交回复
热议问题