Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CLI: Retrieve list of running EC2 instance types

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!

like image 336
kddiji Avatar asked Feb 04 '21 21:02

kddiji


People also ask

How do I get a list of EC2 instances?

Go to the instances section and click on "instances". It will show you all the running instances in the select region.

How do I know my EC2 instance type from command line?

To find an instance type using the consoleOpen the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . From the navigation bar, select the Region in which to launch your instances. You can select any Region that's available to you, regardless of your location. In the navigation pane, choose Instance Types.

Which of the following is needed to retrieve a list of your EC2 instances using the AWS CLI?

Which of the following is needed to retrieve a list of your EC2 instances using the AWS CLI? Solution: Access keys are long-term credentials for an IAM user or the AWS account root user.

How to list EC2 instances using AWS CLI command line?

Setup your Programmatic Access – Create Access Key and Key Secret. Execute the AWS CLI Command line examples to List EC2 instances command line. Let us perform these aforementioned steps one by one. Example3: Getting More Fields using the Query Parameter. Get the Machine type

What is an active EC2 instance?

EC2 instances in any of the following states are considered active: AWAITING_FULFILLMENT, PROVISIONING, BOOTSTRAPPING, RUNNING. See 'aws help' for descriptions of global parameters. list-instances is a paginated operation. Multiple API calls may be issued in order to retrieve the entire data set of results.

What is instance-storage-info in AWS?

instance-storage-info.total-size-in-gb - The total amount of storage available from all local instance storage, in GB. instance-storage-supported - Indicates whether the instance type has local instance storage ( true | false ). instance-type - The instance type (for example c5.2xlarge or c5*).

What is AWS CLI and how to use it?

AWS CLI is a very great help when it comes to efficiently manage your AWS Cloud Infrastructure and your EC2 instances. While we are managing our AWS Infrastructure, we cannot always afford to login to the AWS console all the time and it is not recommended from the security perspective as well.


Video Answer


1 Answers

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

like image 112
amitd Avatar answered Sep 21 '22 01:09

amitd