Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
6
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

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

時間の無い人向け

下記コマンドの<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     |
+-----------------+
:
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
6
Help us understand the problem. What are the problem?