5

I am trying a quick way to list/output all instances type running in my environment. Nothing else just a list of those InstanceType.

I can easily get them on the console but it's a bit time consuming.

Thanks in advance!

2
  • Have you tried aws ec2 describe-instances ? Commented Feb 4, 2021 at 21:54
  • ...together either --query --filter and jq commandline tool you can do many things. Commented Feb 4, 2021 at 21:58

3 Answers 3

3

AWS CLI -

aws ec2 describe-instances --region eu-west-1 --query 'Reservations[*].Instances[*].InstanceType' --output text | sort | uniq

In AWS web console - You can also use AWS Config -> Advanced queries -> Query editor as shown below. Output can be exported as json or csv. Also have aws cli for this.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

3

Personally I use Steampipe to query AWS (and other cloud) resources using SQL from my terminal. Per your question, I've also limited resources to those "running":

select
  instance_type,
  count(*)
from
  aws_ec2_instance
where
  instance_state = 'running'
group by
  instance_type
order by
  count

Comments

1

I think this maybe help you:

aws ec2 describe-instances \
--query "Reservations[*].Instances[*].[InstanceType]" \
--output json

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.