AWS volumes and AMI without a specific tag

Viewed 313

To find list of instances without tag "Environment", I used the following command.

aws ec2 describe-instances --query 'Reservations[?Instances[?length(Tags[?Key=='Environment']) == `0`]].Instances[].InstanceId' --output text

Now, how to find the list of volume-Id doesn't have a specific tag? Suppose some of my volumes have tag "Environment". When executing a command the result should contain volume-Ids without the tag Environment.

Similarly, I need to list the AMI and snapshot also.

2 Answers

I listed all the instances id's into a file(file A). And then listed instance id's with tag 'Environment' into another file(file B). And then I find the differences between these two files(instance id's listed in file A but not in file B).

Related