
I Tried Out deleteReplication, Which Propagates Deletions to the Destination in Amazon ECR Replication
This page has been translated by machine translation. View original
Introduction
On 2026-11-16, Amazon ECR replication gained the ability to propagate image deletions and tag deletions to the destination.
When you enable deleteReplication in a replication rule, image deletions and tag deletions made at the source after enabling are also reflected at the destination. With replication from us-east-1 to us-east-2, I deleted tags and images at the source, then checked that the deletions were reflected at the destination and recorded in CloudTrail.
Preparation for Verification
Verification Environment
The source is us-east-1 and the destination is us-east-2, both within the same account. I attached a filter with the prefix devio-repl-del to the rule. The test image is 560 bytes, and the AWS CLI version is 2.41.0.
Replication Configuration
Save the following JSON as replication-delete-enabled.json and apply it in the source region (us-east-1). Put the destination account ID in registryId.
{
"rules": [
{
"destinations": [
{ "region": "us-east-2", "registryId": "111122223333" }
],
"repositoryFilters": [
{ "filter": "devio-repl-del", "filterType": "PREFIX_MATCH" }
],
"deleteReplication": { "enabled": true }
}
]
}
aws ecr put-replication-configuration --region us-east-1 --replication-configuration file://replication-delete-enabled.json
When using this cross-account, the destination registry's permissions policy needs ecr:ReplicateImageDelete. Grant it in addition to ecr:ReplicateImage and ecr:CreateRepository. Since this verification was done within a single account, I did not configure this permission.
How to Check the Destination
Call describe-images in the destination region and look at the pairs of tags and digests.
aws ecr describe-images --region us-east-2 --repository-name devio-repl-del/main --query 'sort_by(imageDetails,&imagePushedAt)[].{tags:imageTags,digest:imageDigest}'
I measured the time until reflection with a script (poll-dest.sh) that repeats this command at 2-second intervals.
poll-dest.sh
#!/usr/bin/env bash
# Usage: poll-dest.sh <repository name> <exit condition> [interval seconds] [max seconds]
# Calls describe-images in the destination region at regular intervals and prints the result with a timestamp whenever it changes.
# Exit condition: gone = the repository has 0 images
# tags=a,b = the set of tags matches a,b (comma-separated; order does not matter)
# present = there is at least 1 image
set -uo pipefail
REPO="$1"; COND="$2"; INT="${3:-5}"; MAX="${4:-1800}"
DST="${DST_REGION:-us-east-2}"
START=$(date +%s); LAST=""
while :; do
NOW=$(date +%s); EL=$((NOW-START))
OUT=$(aws ecr describe-images --region "$DST" --repository-name "$REPO" \
--query 'sort_by(imageDetails,&imagePushedAt)[].{tags:imageTags,digest:imageDigest}' --output json 2>&1)
if echo "$OUT" | grep -q RepositoryNotFoundException; then OUT='"RepositoryNotFound"'; fi
COMPACT=$(echo "$OUT" | tr -d ' \n')
if [ "$COMPACT" != "$LAST" ]; then
echo "$(date +%Y-%m-%dT%H:%M:%S%z) +${EL}s $COMPACT"
LAST="$COMPACT"
fi
case "$COND" in
gone) [ "$COMPACT" = "[]" ] && { echo "$(date +%Y-%m-%dT%H:%M:%S%z) +${EL}s CONDITION_MET gone"; exit 0; } ;;
present) [ "$COMPACT" != "[]" ] && [ "$COMPACT" != '"RepositoryNotFound"' ] && { echo "$(date +%Y-%m-%dT%H:%M:%S%z) +${EL}s CONDITION_MET present"; exit 0; } ;;
tags=*) WANT=$(echo "${COND#tags=}" | tr ',' '\n' | sort | paste -sd,)
HAVE=$(echo "$OUT" | python3 -c 'import sys,json
try:
d=json.load(sys.stdin)
print(",".join(sorted(t for i in d for t in (i.get("tags") or []))))
except Exception: print("")')
[ "$HAVE" = "$WANT" ] && [ -n "$WANT" ] && { echo "$(date +%Y-%m-%dT%H:%M:%S%z) +${EL}s CONDITION_MET $COND"; exit 0; } ;;
esac
[ "$EL" -ge "$MAX" ] && { echo "$(date +%Y-%m-%dT%H:%M:%S%z) +${EL}s TIMEOUT"; exit 1; }
sleep "$INT"
done
Deletions Propagated to the Destination
Replication is asynchronous and eventually consistent (User Guide). Therefore, the numbers of seconds below are single measurements.
With a rule that has deleteReplication enabled, I pushed image A (tags a1, a2) and image B (tags b1, b2) to devio-repl-del/main at the source, and confirmed they were replicated to the destination. The deletions were done in this order: tag a2 of image A, tag a1 of image A, and the digest of image B.
One of Multiple Tags
Delete only a2 from image A (executed at 20:31:32).
aws ecr batch-delete-image --region us-east-1 --repository-name devio-repl-del/main --image-ids imageTag=a2
$ ./poll-dest.sh devio-repl-del/main tags=a1,b1,b2 2 300
2026-11-18T20:31:34+0900 +0s [{"tags":["a2","a1"],"digest":"sha256:a1850d6ee549dd96b9485ba1c5e02410e92a5ab3d38fa36f0af69ad3daf57820"},{"tags":["b2","b1"],"digest":"sha256:0a011b9b48d31abc26915f7964053ee83ab9d1d27875a60337963a55aa49e998"}]
2026-11-18T20:31:37+0900 +3s [{"tags":["a1"],"digest":"sha256:a1850d6ee549dd96b9485ba1c5e02410e92a5ab3d38fa36f0af69ad3daf57820"},{"tags":["b2","b1"],"digest":"sha256:0a011b9b48d31abc26915f7964053ee83ab9d1d27875a60337963a55aa49e998"}]
Only a2 was removed from image A at the destination, and the tags of image B did not change. The reflection at the destination came 5 seconds after running the delete command (20:31:32 → 20:31:37).
The Last Tag
Delete a1, which remains on image A (executed at 20:31:46).
aws ecr batch-delete-image --region us-east-1 --repository-name devio-repl-del/main --image-ids imageTag=a1
$ ./poll-dest.sh devio-repl-del/main tags=b1,b2 2 300
2026-11-18T20:31:48+0900 +0s [{"tags":["a1"],"digest":"sha256:a1850d6ee549dd96b9485ba1c5e02410e92a5ab3d38fa36f0af69ad3daf57820"},{"tags":["b2","b1"],"digest":"sha256:0a011b9b48d31abc26915f7964053ee83ab9d1d27875a60337963a55aa49e998"}]
2026-11-18T20:31:51+0900 +3s [{"tags":["b2","b1"],"digest":"sha256:0a011b9b48d31abc26915f7964053ee83ab9d1d27875a60337963a55aa49e998"}]
At the destination, not only tag a1 but image A itself disappeared. The reflection came 5 seconds later (20:31:46 → 20:31:51).
Specifying by Digest
Delete image B by digest (executed at 20:31:51).
aws ecr batch-delete-image --region us-east-1 --repository-name devio-repl-del/main --image-ids imageDigest=sha256:0a011b9b48d31abc26915f7964053ee83ab9d1d27875a60337963a55aa49e998
$ ./poll-dest.sh devio-repl-del/main gone 2 300
2026-11-18T20:31:53+0900 +0s [{"tags":["b2","b1"],"digest":"sha256:0a011b9b48d31abc26915f7964053ee83ab9d1d27875a60337963a55aa49e998"}]
2026-11-18T20:31:56+0900 +3s []
At the destination, image B and its two tags (b1, b2) disappeared at once, and the number of images in the repository became 0. The reflection came 5 seconds later (20:31:51 → 20:31:56).
Deletion Records
I searched CloudTrail in the destination region for the event name ReplicateImageDelete.
aws cloudtrail lookup-events --region us-east-2 --lookup-attributes AttributeKey=EventName,AttributeValue=ReplicateImageDelete --start-time 2026-11-18T20:25:00+09:00 --query 'Events[].{time:EventTime,name:EventName,user:Username}'
[
{
"time": "2026-11-18T20:31:36+09:00",
"name": "ReplicateImageDelete",
"user": "ECRReplication"
}
]
The search returned 4 results, one more than the 3 deletions at the source, with 2 records at 20:31:48 for the deletion of the last tag (20:31:46). The output above is the one of the 4 that corresponds to the deletion of tag a2 (20:31:32). Here is an excerpt of its details. The account ID has been replaced.
"arn": "arn:aws:sts::111122223333:assumed-role/AWSServiceRoleForECRReplication/ECRReplication",
"invokedBy": "replication.ecr.amazonaws.com",
"requestParameters": null,
"responseElements": null,
"resources": [
{
"accountId": "111122223333",
"ARN": "arn:aws:ecr:us-east-2:111122223333:repository/devio-repl-del/main"
}
],
In all 4 records, the only target recorded is the repository ARN, so the deleted tags and digests cannot be determined.
Summary
I confirmed that with ECR replication, deletions of images and tags at the source are reflected at the destination.
If you delete images manually rather than through lifecycle policies, this removes the effort of deleting in both the source and the destination.
In particular, when images are large and storage charges add up, or when you are concerned about the charges for Amazon Inspector continuous scanning, it can reduce the unneeded images remaining at the destination.
