
Như hình của bên trên bạn có 2 account aws A và account aws B
==> Bạn muốn Account AWS B có thể pull image từ account aws A
Chúng ta sẽ set permission trên từng image để cho phép Account AWS B có thể pull image từ account aws A


{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPushPull",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::account-id:root"
},
"Action": [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload"
]
}
]
}
Ok giờ bạn đừng Ở User B và login vào ECR của account
aws sts get-caller-identity --profile fedramp-dev-mdcl-nim-engines
{
"UserId": "AIDA3RZ3BTJETEXT5QBK6",
"Account": "794155915849",
"Arn": "arn:aws:iam::794155915849:user/nimtechnology"
}
aws ecr get-login-password --region <regionID> --profile <profileName> | docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<regionID>.amazonaws.com
example:
aws ecr get-login-password --region us-east-1 --profile fedramp-dev-mdcl-nim-engines | docker login --username AWS --password-stdin 250887682577.dkr.ecr.us-east-1.amazonaws.com

Reference Links:
https://aws.amazon.com/blogs/containers/cross-region-replication-in-amazon-ecr-has-landed/