Videos
You don't necessarily need the owner ID but it is obviously a good idea to include to ensure you are getting the AMI you expect.
Given that you know the trusted owner up-front, the simple way to find the owner ID is to look in the AMIs table in the AWS console.
From the AWS console, navigate to EC2 > Images > AMIs. Select the "Public Images" filter from the dropdown on the left of the search box. You can then search for any AMI you want, and the Owner value is shown in the table:
If you'd like the use the AWS SDK; the easiest way to go about this is something like the following:
aws ec2 describe-images --image-ids ami-0def3275 --region us-west-2
Of course, replace the region and AMI ID as appropriate.
If you'd like to use jq to then parse this; you could something like:
aws ec2 describe-images --image-ids ami-0def3275 --region us-west-2 | jq -r .Images[0].OwnerId
CentOS publishes their AMI product codes to their wiki. The wiki provides the following information for the latest CentOS 7 AMI:
- Owner:
aws-marketplace - Product Code:
aw0evgkw8e5c1q413zgy5pjce
Using this information, we can query describe-images with the AWS CLI:
Example:
aws ec2 describe-images \
--owners 'aws-marketplace' \
--filters 'Name=product-code,Values=aw0evgkw8e5c1q413zgy5pjce' \
--query 'sort_by(Images, &CreationDate)[-1].[ImageId]' \
--output 'text'
Output:
ami-6d1c2007
This query returns a single AMI ID, selected by sorting the collection by creation date and then selecting the last (most recent) element in the collection.
Per the CentOS wiki, multiple AMI ids may be associated with a product key, so while this query would currently only return a single AMI because only one matching this product currently exists... in the future if a new AMI is created for this product code for any reason this query will return it instead.
Check in this page
or
AWS has been changing the “aws marketplace” UI. Now (2022) We get the ami id in the “configure this software” Page in the AWS Marketplace itself.
Steps:
- Search and locate the image. Click on the image.
- On the top right, click “continue to subscribe”
- On the next window, click on “Continue to configuration”
- On the next window, Find the Ami ID located. We can change software versions to get different ami Ids.