Hosting » AWS » How do I get a list of instances in AWS CLI?

How do I get a list of instances in AWS CLI?

Last updated on September 25, 2022 @ 6:32 pm

AWS CLI provides a list of all the instances in your account in the form of an output table. To get the list of instances, you can use the following command:

AWS ec2 get-instances

The command returns an output table that looks like this:

Instance Type Name Status Region

ami-b2c2e2d8f Region US East (N. Virginia)

ami-f2dde2a0 Region US East (N. Virginia)

ami-7e3fde40 Region US East (N. Virginia)

ami-630bf2c0 Region US East (N. Virginia)

ami-2f4c2d10 Region US West (Oregon)

ami-a5dde2a4 Region US West (Oregon)

ami-c2d10e40 Region US West (Oregon)

ami-5f2de2a8 Region US West (Oregon)

ami-cde2d10c Region EU (Ireland)

ami-cde2d10 Region Asia Pacific (Singapore)

ami-cde2d10 Region South America (Brazil)

ami-cde2d10 Region North America (US West (Oregon))

ami-cde2d10 Region EU (Ireland)

Conclusion

The AWS ec2 get-instances command provides a list of all the instances in your account in the form of an output table.

PRO TIP: When using the AWS CLI to list instances, you must specify the region in which the instances reside. Failure to do so will result in a list of all instances in all regions. Additionally, the AWS CLI does not support pagination, so the entire list of instances will be returned.
Morgan Bash

Morgan Bash

Technology enthusiast and Co-Founder of Women Coders SF.