Search code examples
amazon-web-servicesamazon-ec2aws-cliamazon-ami

In AWS where how can I get the list of image ids


If I need to get list of AMI image ids (Ex: "ami-0ff8a91507f77f867") for Amazon Linux 2 AMI (HVM), SSD Volume Type

Is there a CLI command I can run (prefered) or is it documented some where?


Solution

  • The AWS managed list of current AMIs for Amazon Linux can be obtained using aws cli and querying public AWS SSM Parameters:

    The cool thing is that these values can be referenced in CloudFormation templates, so there is no need to hard-code the AMI ids.

    Having the latest AMI ids, one can also use describe-images AWS CLI command to get more details about them, or filter out those which exhibit properties of interest to you (e.g. Volume Type).