DrDroid
Resource Cheatsheet

S3

Quick reference guide and commands for S3.

Download PDF

Authentication

aws configure
Set up AWS credentials for S3 access

aws s3 presign s3://bucket-name/object-key
Generate a pre-signed URL for temporary access to an object

Bucket Operations

aws s3 ls
List all buckets

aws s3 mb s3://bucket-name
Create a new bucket

aws s3 rb s3://bucket-name
Delete an empty bucket

aws s3 rb s3://bucket-name --force
Delete a bucket and all its contents

Object Operations

aws s3 ls s3://bucket-name
List objects in a bucket

aws s3 ls s3://bucket-name --recursive
List all objects in a bucket including subdirectories

aws s3 cp file.txt s3://bucket-name/
Upload a file to a bucket

aws s3 cp s3://bucket-name/file.txt ./
Download a file from a bucket

aws s3 mv file.txt s3://bucket-name/
Move/rename a file to S3

aws s3 rm s3://bucket-name/file.txt
Delete an object

aws s3 rm s3://bucket-name --recursive
Delete all objects in a bucket

Sync Operations

aws s3 sync . s3://bucket-name/
Sync local directory to S3 bucket

aws s3 sync s3://bucket-name/ .
Sync S3 bucket to local directory

aws s3 sync . s3://bucket-name/ --delete
Sync and delete files that don't exist in source

Access Control

aws s3api get-bucket-policy --bucket bucket-name
View bucket policy

aws s3api put-bucket-policy --bucket bucket-name --policy file://policy.json
Set bucket policy

aws s3api get-bucket-acl --bucket bucket-name
View bucket ACL

aws s3api put-bucket-acl --bucket bucket-name --acl public-read
Set bucket ACL

Monitoring

aws s3api get-metric-statistics
Get bucket metrics

aws cloudwatch get-metric-statistics --namespace AWS/S3
Get S3 metrics from CloudWatch

aws s3api get-bucket-notification-configuration --bucket bucket-name
View notification configuration