Reputation: 31560
Im using terraform to get the official centos ami:
data "aws_ami" "centos" {
most_recent = true
owners = ["679593333241"] # Centos.org
filter {
name = "name"
values = ["CentOS Linux 7 x86_64 HVM EBS 1708_01-*"]
}
}
I need the owner ID and the way I found it in this case was to aimlessly google until some article had it (they didn't say how they got it).
I can't find the owner ID on the ami's market place page.
If I launch the ami through it's market place page the ec2 instance it creates actually has my personal id set for the instance's "owner" field- so I can't launch an ec2 instance, check the owner and get it that way either.
Why is this so impossible to get? I must be missing something obvious.
Upvotes: 19
Views: 19037
Reputation: 123
TJ is correct however, to use jq I had to add single quotes for it work:
aws ec2 describe-images --image-ids ami-00dfe2c7ce89a450b --region us-east-2 | jq -r '.Images[0].OwnerId'
Upvotes: 3
Reputation: 6484
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
Upvotes: 13
Reputation: 11431
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:
Upvotes: 17