公開されているAMIの所有者がAmazonであることを確認する方法

2023.06.13

困っていた内容

Amazonが提供しているパブリックAMIを使用したいので、Amazon所有のアカウントIDを調べる方法が知りたいです。

対処方法

以下のAWS CLIコマンドで、東京リージョンのAmazon所有のアカウントIDが確認できます。(実行結果は、2023/06/22の情報です)

aws ec2 describe-images --owners amazon --query 'Images[].OwnerId' --region ap-northeast-1 | jq unique
[
  "013907871322",
  "099720109477",
  "102837901569",
  "136693071363",
  "137112412989",
  "164071883780",
  "247102896272",
  "302615239497",
  "309956199498",
  "366320600621",
  "465558535106",
  "490389498239",
  "517802777641",
  "591542846629",
  "593245189075",
  "602401143452",
  "663280808239",
  "680152181751",
  "746694360614",
  "801119661308",
  "877601337756",
  "877902723034",
  "898082745236"
]

こちらは、バージニア北部リージョンでの実行結果です。(2023/06/22の情報です)

aws ec2 describe-images --owners amazon --query 'Images[].OwnerId' --region us-east-1 | jq unique
[
  "013907871322",
  "052272138977",
  "092701018921",
  "099720109477",
  "102837901569",
  "111986023115",
  "136693071363",
  "137112412989",
  "233035487920",
  "247102896272",
  "309956199498",
  "327094444948",
  "591542846629",
  "596061404617",
  "602401143452",
  "628277914472",
  "633936118553",
  "801119661308",
  "877902723034",
  "898082745236",
  "899538854915",
  "957547624766",
  "990736445056"
]


--owners で amazon と指定することで、Amazon 提供のAMIのみ出すようにしています。

--owners (list)

Scopes the results to images with the specified owners. You can specify a combination of Amazon Web Services account IDs, self , amazon , and aws-marketplace . If you omit this parameter, the results include all images for which you have launch permissions, regardless of ownership. (string)


--query で、'Images[].OwnerId' と指定し、OwnerIdの一覧を出すようにしています。

--query (string)

A JMESPath query to use in filtering the response data.


--regionで、リージョン指定しました。指定しなければ、.aws/config で指定しているリージョンで実行されます。リージョン毎に結果が変わるので、--regionオプションを使用することをおすすめします。

--region (string)

The region to use. Overrides config/env settings.

引用元:describe-images

最後に jq コマンドでユニークな値に絞って出すようにしています。

参考資料