How can I get list of only running instances when using ec2-describe-tags

user1788294 picture user1788294 · May 29, 2014 · Viewed 28.3k times · Source

How can I get list of only running instances when using ec2-describe-tags. I am using my command like this:

ec2-describe-tags --filter "resource-type=instance" --filter "value=somevalue" --filter "key=key"

Answer

John Rotenstein picture John Rotenstein · Nov 22, 2014

It is easy using the aws-cli:

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId]' --filters Name=instance-state-name,Values=running --output text