Amazon Web Services (AWS) - List Amazon Machine Images (AMI) using the AWS CLI
                
            
            
            
            
            
            
                           
                
            
            
            
                
    
    
    
            
                
                    by
                    Jeremy Canfield  |  
                    Updated: May 25 2023
                    
                          |  Amazon Web Services (AWS) articles
                    
                    
                    
                
            
            This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
The aws ec2 describe-images command can be used to list all of the available EC2 images.
aws ec2 describe-images
If you are looking for a specific image, the --filters option can be used.
aws ec2 describe-images --filters "Name=name,Values=amzn2-ami-kernel-*-x86_64-*"
And here is an example of how to limit the output using the --query option.
aws ec2 describe-images --query 'Images[?Name==`amzn2-ami-kernel-5.10-hvm-2.0.20221103.3-x86_64-gp2`]'
Something like this should be returned.
{
    "Images": [
        {
            "Architecture": "x86_64",
            "CreationDate": "2022-11-14T15:27:30.000Z",
            "ImageId": "ami-0c306652768ec4cc5",
            "ImageLocation": "929637706107/isc-ga-2022-2-0-368-0-irishealth-community-image",
            "ImageType": "machine",
            "Public": true,
            "OwnerId": "929637706107",
            "PlatformDetails": "Linux/UNIX",
            "UsageOperation": "RunInstances",
            "State": "available",
            "BlockDeviceMappings": [
                {
                    "DeviceName": "/dev/sda1",
                    "Ebs": {
                        "DeleteOnTermination": true,
                        "SnapshotId": "snap-090c2dd83f08b2d03",
                        "VolumeSize": 15,
                        "VolumeType": "gp2",
                        "Encrypted": false
                    }
                },
                {
                    "DeviceName": "/dev/sdb",
                    "VirtualName": "ephemeral0"
                },
                {
                    "DeviceName": "/dev/sdc",
                    "VirtualName": "ephemeral1"
                }
            ],
            "Description": "isc-ga-2022-2-0-368-0-irishealth-community-image",
            "EnaSupport": true,
            "Hypervisor": "xen",
            "Name": "isc-ga-2022-2-0-368-0-irishealth-community-image",
            "RootDeviceName": "/dev/sda1",
            "RootDeviceType": "ebs",
            "SriovNetSupport": "simple",
            "VirtualizationType": "hvm",
            "DeprecationTime": "2024-11-14T15:27:30.000Z"
        }
    ]
}
Did you find this article helpful?
If so, consider buying me a coffee over at 