Amazon Web Services (AWS) Elastic Compute Cloud (EC2) instances come in various types and sizes to meet different compute needs. Finding the instance type of your AWS EC2 server can be useful for various reasons, such as understanding the level of performance, optimizing cost, or troubleshooting issues. In this article, we will explore six methods to easily identify the instance type of your AWS EC2 instance over SSH.
Method 1: Using the ec2-metadata Command
One of the simplest ways to find the instance type of your EC2 instance is by using the ec2-metadata command. This command is available on Amazon Linux, Amazon Linux 2, and EC2 instances created from AWS Marketplace AMIs. Simply connect to your EC2 instance over SSH and run the following command:
ec2-metadata --instance-type
Method 2: Using the Instance Metadata Service
AWS provides an instance metadata service that allows you to retrieve metadata about your EC2 instance. You can access this metadata by making an HTTP request to a specific URL. To find the instance type of your EC2 instance using the instance metadata service, run the following command:
curl http://169.254.169.254/latest/meta-data/instance-type
Method 3: Using the AWS Command Line Interface (CLI)
If you have the AWS CLI installed on your local machine, you can use it to find the instance type of your EC2 instance. Run the following command to get the instance type:
aws ec2 describe-instances --instance-ids <instance-id> --query 'Reservations[*].Instances[*].InstanceType' --output text
Replace <instance-id>
with the ID of your EC2 instance.
Method 4: Checking the Instance Type in the AWS Management Console
Another way to find the instance type of your EC2 instance is by logging into the AWS Management Console. Navigate to the EC2 service, select your instance, and the instance type will be displayed in the details section.
Method 5: Checking the /proc/cpuinfo File
You can also find information about the instance type of your EC2 instance by checking the /proc/cpuinfo file. Simply run the following command to view the contents of the file:
cat /proc/cpuinfo
Look for the value of the "model name" field, which will indicate the model of the CPU, and subsequently the instance type.
Method 6: Using the lscpu Command
The lscpu command can provide detailed information about your CPU, including the model name and the number of cores. Run the following command to find the instance type based on the CPU model:
lscpu
In conclusion, there are multiple methods to find the instance type of your AWS EC2 instance over SSH. Whether you prefer using the ec2-metadata command, the instance metadata service, the AWS CLI, the AWS Management Console, checking system files, or using the lscpu command, you can easily retrieve information about your EC2 instance type for various purposes.