📝
ECR では多段階のレプリケーションはできない
Private image replication in Amazon ECR - Amazon ECR
A replication action only occurs once per image push. For example, if you configured cross-Region replication from us-west-2 to us-east-1 and from us-east-1 to us-east-2, an image pushed to us-west-2 replicates to only us-east-1, it doesn't replicate again to us-east-2. This behavior applies to both cross-Region and cross-account replication.
上記仕様を実際に確認してみました。
準備
今回は以下のリージョンに ECR リポジトリを作成しました。
- 東京
- 大阪
- バージニア北部
リポジトリ名はいずれも「replication-test」です。
東京リージョンと大阪リージョンでレプリケーションルールを作成しました。
- 東京リージョン
{
"rules": [
{
"destinations": [
{
"region": "ap-northeast-3",
"registryId": "012345678901"
}
],
"repositoryFilters": [
{
"filter": "replication-test",
"filterType": "PREFIX_MATCH"
}
]
}
]
}
- 大阪リージョン
{
"rules": [
{
"destinations": [
{
"region": "us-east-1",
"registryId": "012345678901"
}
],
"repositoryFilters": [
{
"filter": "replication-test",
"filterType": "PREFIX_MATCH"
}
]
}
]
}
プッシュしてみる
上記の準備完了後、東京リージョンの CloudShell から東京リージョンの ECR リポジトリにイメージをプッシュします。
$ docker pull hello-world
$ docker tag hello-world 012345678901.dkr.ecr.ap-northeast-1.amazonaws.com/replication-test:v1.0
$ aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 012345678901.dkr.ecr.ap-northeast-1.amazonaws.com
$ docker push 012345678901.dkr.ecr.ap-northeast-1.amazonaws.com/replication-test:v1.0
プッシュ後に各リージョンのリポジトリを確認したところ、以下の状況でした。
- 東京: プッシュされている
- 大阪: 東京からレプリケーションされている
- バージニア北部: 大阪からレプリケーションされていない
まとめ
今回は ECR では多段階のレプリケーションはできないという内容を紹介しました。
どなたかの参考になれば幸いです。
Discussion