Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save eugenestarchenko/5fe348f8ed0f7abb2c8a0eda1ff72866 to your computer and use it in GitHub Desktop.

Select an option

Save eugenestarchenko/5fe348f8ed0f7abb2c8a0eda1ff72866 to your computer and use it in GitHub Desktop.
ECRのリージョン移行
#!/bin/bash
#
# 前準備として、移行先に各イメージのレポジトリを作成しておく必要あり。
# $from、$to、$aws_account_id、$images は適宜変更する。
#
set -e
from="us-east-1"
to="ap-northeast-1"
aws_account_id=""
images=("image1:tag" "image2:tag")
repo_format="%s.dkr.ecr.%s.amazonaws.com"
repo_from=$(printf $repo_format $aws_account_id $from)
repo_to=$(printf $repo_format $aws_account_id $to)
pull_and_tag_images() {
for image in ${images[@]}
do
docker pull $repo_from/$image
docker tag $repo_from/$image $repo_to/$image
done
unset image
}
push_images() {
for image in ${images[@]}
do
docker push $repo_to/$image
done
unset image
}
aws ecr get-login --region $from | bash
pull_and_tag_images
aws ecr get-login --region $to | bash
push_images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment