Skip to content

How to list down Amazon EC2 AMI using your terminal?

Published:ย atย 11:11 AM

When managing cloud resources, it is important to consider the costs associated with AWS EC2 instances, which can add up quickly, especially when using high-configuration instances unnecessarily. For testing purposes, it is wise to choose low-configuration machines such as the t4g.nano instance. These instances are designed to offer a cost-effective solution for workloads that do not need significant computational power, enabling developers and testers to carry out their activities efficiently without incurring excessive expenses.

While it is cost-effective, finding the right instances can be tricky sometimes. I came across a scenario where I needed an older version of an OS that should also be Arm 64 architecture. Using the AWS console, it is easy to get the latest OS AMIs, but finding older ones can be tricky.

Youโ€™ve come to the right place if you are stuck in a similar problem.

Letโ€™s get Started ๐Ÿš€

The first step is configuring your terminal with your cloud environmentโ€™s credentials. Follow this article to configure your terminal.

To ensure your terminal is properly connected, try running a simple AWS CLI command like aws s3 ls. This CLI command would list the buckets in your cloud environment.

In this article, I am searching for AMIs in the ap-south-1 (Mumbai) region.

aws ec2 describe-images --region ap-south-1 --owners amazon --query 'Images[*].[ImageId,Name,Architecture]' --output table

This command will generate a list of AMIs in the Mumbai region.

List of AMIs

Now, you can simply select your EC2 AMI and spin up an EC2 instance using the AWS EC2 run-instances.

And thatโ€™s it!

==============================================================

If you find this story helpful and want to see similar stories, feel free to support me with a virtual coffee ๐Ÿ˜‰๐Ÿ‘‡๐Ÿป

โ˜• Buy me a coffee โ˜•