Wisco crew
Wisco crew

Reputation: 1367

S3 folder keeps reappearing and disappearing

I have an S3 bucket. In it are folders Foo and foo (among others). I deleted Foo.

When I refresh the page in the S3 browser console, about 50% of the time I still see Foo listed. I refresh again, and it's gone. Refresh a third time, and it's back. This is also the case with the AWS CLI.

The only idea I can come up with is something related to upper/lowercase clashes, but I was under the impression that S3 is case-sensitive. Any idea what might be going on?

Upvotes: 2

Views: 4286

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269302

The important thing to appreciate is that folders do not actually exist in Amazon S3. Amazon S3 is an object store, not a filesystem, and all objects are stored in a flat namespace with no directories.

That said, S3 emulates directories via:

  • Filenames (the key of the object) include the full path, so bar.txt stored in the foo directory actually has a Key of foo/bar.txt
  • The S3 management console simulates folders by showing objects with a common prefix
  • You can actually copy files to a 'folder' even if the folder doesn't exist, eg: aws s3 cp bar.txt s3://bucket/docs/bar.txt
  • Empty folders created in the management console actually create a hidden zero-length file to force the 'folder' to appear

So, firstly don't worry too much about empty folders appearing/disappearing. It doesn't really mean anything. It might be caused by S3 eventual consistency or due to versioning. If it is really upsetting for you, you could contact AWS Support (if you are subscribed). Otherwise, just keep trying to delete it and hopefully it will give you a consistent result.

Upvotes: 3

Related Questions