AWS CLI 2 cheatsheet
AWS CLI 2: S3
8 common AWS CLI 2 tasks.
List buckets or objects
List buckets, or add a bucket and prefix to list objects.
aws s3 ls s3://my-bucket/path/
Mirror a folder, deleting extras
Also delete objects in the bucket that are not in the folder.
aws s3 sync ./dist s3://my-bucket --delete
Caution: Deletes objects that are missing locally. Preview with --dryrun first.
Delete everything under a prefix
Delete all objects under a prefix.
aws s3 rm s3://my-bucket/old/ --recursive
Caution: Deleted objects cannot be recovered unless versioning is enabled. Preview with --dryrun.
Create a temporary download link
Make a signed URL that expires after an hour.
aws s3 presign s3://my-bucket/file.txt --expires-in 3600