Hands-On: The AWS CLI

Create a bucket, upload files, and list them in five commands.

1 min read

Make sure the AWS CLI is installed and configured (aws sts get-caller-identity should print your account). Replace notesnap-uploads-dev-4821 with your own unique name.

Create a bucket (mb = make bucket):

Terminal
aws s3 mb s3://notesnap-uploads-dev-4821 --region us-east-1

Upload a single file:

Terminal
echo "Buy milk, eggs, and coffee" > note.txt
aws s3 cp note.txt s3://notesnap-uploads-dev-4821/notes/note.txt

Sync a whole folder (only uploads new or changed files):

Terminal
aws s3 sync ./my-notes s3://notesnap-uploads-dev-4821/notes/

List what's there:

Terminal
aws s3 ls s3://notesnap-uploads-dev-4821/notes/ --recursive --human-readable

Clean up (deletes the bucket and everything in it, so be careful):

Terminal
aws s3 rb s3://notesnap-uploads-dev-4821 --force
Note

aws s3 gives you friendly, high-level commands. aws s3api exposes every raw API operation when you need fine-grained control.

Key takeaways

  • `mb`, `cp`, `sync`, `ls`, and `rb` cover most day-to-day S3 work.
  • `sync` only transfers what changed, which makes it great for folders.
  • `aws s3api` is there when you need every option.

Check your understanding

Pick an answer to see the explanation.

  1. 1. Which command uploads only new or changed files from a folder?