Will two S3 objects with identical contents have the same ETag?

Index, feed.

[ Date | 2020-02-09 22:33 -0500 ]
[ Mod. | 2021-03-09 16:31 -0500 ]

When using Amazon Web Services S3 object storage service, a pattern appears semi-frequently to try to find out from metadata alone whether two objects are identical.

The idea behind the shortcut is to assume that two objects with identical value will have identical ETag values.

Testing the assumption

To test this assumption, I upload the same file a bunch of times with different number of parts for multipart uploads, and also as a non-multipart upload, and then compare the ETag values.

In this example, the input is 64 megabytes of zero bytes.

part count ETag
none 7f614da9329cd3aebf59b91aadc30bf0
1 a78211a9709e5a28de9e2fd6eda275f2-1
2 e37c18c50eb968283fd30eee4930d0b2-2
4 e4336b5de4e2180a53fe2e17d03abe4f-4
8 e025c614e2d55d4ae4a8dbc6eeda3220-8

Conclusion: Objects with identical values can have differing ETag values. The assumption is invalid.

Going further

How was the ETag value actually computed on this example?

What about the reverse?

In the non-multipart case, it is trivially true that two objects with different values may have identical MD5 hashes, and therefore identical ETags.

The same can be said for in the multipart case, since the ETags appears to also be a 128-bit value, with some metadata appended.

References

Code used to create the test objects.

Use a command such as the following to list objects and their ETag values (replace BUCKET and PREFIX with your own values):

aws s3api list-objects --bucket BUCKET --prefix PREFIX |    
  jq -r '.Contents[] | [.Key, (.ETag | fromjson)] | @tsv'

www.kurokatta.org


www.kurokatta.org

Quick links:

Photos
Montréal
Oregon
Paris
Camp info 2007
Camp Faécum 2007
--more--
Doc
Jussieu
Japanese adjectives
Muttrc
Bcc
Montréal
Couleurs LTP
French English words
Petites arnaques
--more--
Hacks
Statmail
DSC-W17 patch
Scarab: dictionnaire de Scrabble
Sigpue
Recipes
Omelette soufflée au sirop d'érable
Camembert fondu au sirop d'érable
La Mona de Tata Zineb
Cake aux bananes, au beurre de cacahuètes et aux pépites de chocolat
*