Help us understand the problem. What is going on with this article?

aws cliでECSのリポジトリ内にどんなimageタグがbuildされているかワンライナーで答える

More than 1 year has passed since last update.

時間の無い人向け

下記コマンドの<repositoryName>のところをご自身のECS(Amazon EC2 Container Service)に登録されたrepositoryNameに置き換えて実行します。

$ aws ecr list-images --repository-name <repositoryName> --query "imageIds[*].imageTag" --output table

--output tableと指定すると表形式で出力されます。

-------------------
|   ListImages    |
+-----------------+
|  hoge           |
|  fuga           |
|  moga           |
+-----------------+
$ aws ecr list-images --repository-name <repositoryName> --query "imageIds[*].imageTag" --output json

--output jsonとするとjson形式になります。

[
    "hoge",
    "fuga",
    "moga"
]

時間が無い人向けはここまで

リポジトリがたくさんある人向け

一旦、repository.listを作成します。

$ aws ecr describe-repositories --output json | jq ".repositories[].repositoryName" | sed 's/"//g' > repository.list
$ cat repository.list
repository1
repository2
repository3
:

ECR内のリポジトリ名だけのテキストファイルが作成されるので、そのファイルをawkで拾っていきます。

for X in `awk '{print $1}' repository.list` ; do  echo $X ; aws ecr list-images --repository-name $X --query "imageIds[*].imageTag" --output table ; done
repository1
-------------------
|   ListImages    |
+-----------------+
|  hoge           |
|  fuga           |
|  moga           |
+-----------------+
repository2
-------------------
|   ListImages    |
+-----------------+
|  hoge-latest    |
|  fuga-latest    |
|  moga-latest    |
+-----------------+
repository3
-------------------
|   ListImages    |
+-----------------+
|  development    |
|  staging        |
|  production     |
+-----------------+
:
fk_2000
最近の関心事:YouTube、aws、IoT、マイコンボード エンジニア採用、IT導入担当、ブログメディア編集長( https://avatarworld.info/ )、 ↓こちらのYouTubeチャンネルで動画をアップしています。 https://www.youtube.com/channel/UCFM7KsJZC8uGJ1BRMT-4dFg
https://twitter.com/fk_2000
orylab
オリィ研究所は距離や身体的問題を克服し、あいたい人に会え、行きたいところに行ける未来を実現します。
http://orylab.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした