S3 is object storage: you give it a blob of bytes and a name, and it keeps the bytes safe and gives them back on request. It is the service most of AWS is built on top of, and it is where the Monster Market's site will live.
Buckets
A bucket is a container with a name and a region. Names are lowercase letters, digits and hyphens, 3 to 63 characters, and unique across every account in the world. monster-market is probably taken; monster-market-5djtvs is yours.
aws s3 mb s3://monster-market-5djtvs
aws s3 lsmb is make bucket; ls with no argument lists your buckets.
Objects and keys
Inside a bucket are objects: the bytes plus a key, which is the object's full name. css/style.css is one object whose key contains a slash. There are no folders; tools draw slashes as folders because it is convenient, and aws s3 ls shows a PRE css/ line for the same reason.
aws s3 cp index.html s3://monster-market-5djtvs/index.html
aws s3 cp s3://monster-market-5djtvs/index.html ./copy.html
aws s3 ls s3://monster-market-5djtvs/
aws s3 ls s3://monster-market-5djtvs/ --recursive
aws s3 rm s3://monster-market-5djtvs/old.txtcp works in both directions and between buckets. --recursive walks keys under a prefix.
Sync
aws s3 sync ./site s3://monster-market-5djtvs
aws s3 sync ./site s3://monster-market-5djtvs --deletesync compares the directory with the prefix and copies only what is new or changed. Run it again and nothing moves. --delete also removes objects that no longer exist locally. It is the deploy command for a static site.
The API underneath
Every aws s3 command is made of API calls, and aws s3api exposes those calls one to one:
aws s3api list-buckets --query "Buckets[].Name"
aws s3api head-object --bucket monster-market-5djtvs --key index.html
aws s3api list-objects-v2 --bucket monster-market-5djtvs --query "Contents[].Key"Use s3 to move files, s3api when you need an exact operation or a setting s3 does not expose. Most bucket settings in this chapter are s3api calls.