We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

File System Illusion

Remember how I mentioned that S3's "object storage" doesn't support directories? Well, that's true, but there's some trickery involved that makes it feel like it does.

Directories are really great for organizing stuff. Storing everything in one giant bucket makes a big hard-to-manage mess. So, S3 makes your objects feel like they're in directories, even though they're not.

It's Just Prefixes

Keys inside of a bucket are just strings. And strings can have slashes, right? Right.

If you upload an object to S3 with the key users/john/profile.jpg, we can kind of pretend that the object is in a directory called users and a subdirectory called john. Not only that, but the S3 API actually provides tools that allow this illusion to thrive.

Let's say I create some objects with keys:

  • users/dan/profile.jpg
  • users/dan/friends.jpg
  • users/lane/profile.jpg
  • users/lane/friends.jpg
  • people/matt/profile.jpg

Then I can use the S3 API to list all the objects with the key prefix users/lane. It returns:

  • users/lane/profile.jpg
  • users/lane/friends.jpg

or just everything with the prefix "users":

  • users/dan/profile.jpg
  • users/dan/friends.jpg
  • users/lane/profile.jpg
  • users/lane/friends.jpg

It feels like a hierarchy, without all the technical overhead of actually creating directories.

Assignment

aws s3 ls s3://YOURBUCKET/backups/

Replace YOURBUCKET with the name of your bucket.

aws s3 ls s3://YOURBUCKET/backups/ > /tmp/s3_listing.txt

Run and submit the CLI tests.

You can delete the backups folder and its contents when you're done.