How to get the list of all AWS AMIs using boto3?
12,951
import boto3
ec2_client = boto3.client('ec2', region_name='ap-southeast-2') # Change as appropriate
images = ec2_client.describe_images(Owners=['self'])
This lists all AMIs that were created by your account. If you leave out the 'self' bit, it will list all publicly-accessible AMIs (and the list is BIG!).
Author by
New_to_work
Updated on June 05, 2022Comments
-
New_to_work almost 2 years
I want to list all the AWS AMI's (Amazon Machine Image) that I can see using the console and Boto 3.
I have tried using
describe_instances()
to get ImageIDs but not all the images are getting listed. -
Cale Sweeney almost 4 yearsI would add that describe_images() returns a dict. Its well documented here: boto3.amazonaws.com/v1/documentation/api/latest/reference/…
-
wisp over 3 yearsNot exactly. It will print list of AMI of all instances you're running. It can be own private AMIs and publicly available AMI. But this method will omit everything that is not an active instance right now.