LoginSignup
9
4

More than 5 years have passed since last update.

ECRでタグの付け替え

Last updated at Posted at 2017-11-27

一度タグ付けたけど、別のタグにしたくなった時のやり方。
AWSのCLIコマンド長くてすぐ忘れるのでメモ。

環境

aws-cliのバージョンは以下。

$ aws --version
aws-cli/1.11.124 Python/2.7.14 Darwin/17.2.0 botocore/1.7.43

参考

やりかた

公式ドキュメントに書いてあるように、新しいタグを付けてから古いタグを消すだけ。
現時点ではマネジメントコンソール上からはできなそうだった。

新しいタグを付ける

$ MANIFEST=$(aws ecr batch-get-image --repository-name amazonlinux --image-ids imageTag=2017.02 --query images[].imageManifest --output text)
$ aws ecr put-image --repository-name amazonlinux --image-tag 2017.03 --image-manifest "$MANIFEST"
$ aws ecr describe-images --repository-name amazonlinux

古いタグを消す

以下のbatch-delete-imageを使った。
http://docs.aws.amazon.com/cli/latest/reference/ecr/batch-delete-image.html

$ aws ecr batch-delete-image --repository-name amazonlinux --image-ids imageTag=2017.02

感想

batch-delete-image とかAWSの命名結構ブレがある気がする。
他にもっと良い方法もあるかもしれない。

9
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
4