Amazon S3
CLI
Install AWS CLI version 2 on Linux
aws configure
- create .aws which contains config and credentials
- config, use default
- credentials, default user, access key, secret access key
cp
- aws s3 cp localFile s3://bucket, copy a local file to S3
- aws s3 cp s3://bucket/fileName ., copy a file in a bucket to local
- aws s3 cp localFolder s3://bucket/folderName --recursive, copy a local folder to a bucket
- aws s3 cp s3://bucket/folderName localFolder --recursive, copy a folder in a bucket to local
ls
- aws s3 ls, list user owned buckets
- aws s3 ls s3://bucketName, list all prefixes and objects in a bucket
- aws s3 ls s3://bucketName/Data/, all prefixes and objects in a bucke
- aws s3 ls s3://bucketName --recursive --human-readable, recursively listing all prefixes and objects in a bucket
mb, create a bucket, an Amazon S3 bucket name is globally unique, and the namespace is shared by all AWS accounts
- aws s3 mb s3://bucketName
mv
- aws s3 mv fileName s3://bucketName, move a file from the local to a bucket
- aws s3 mv folderName s3://bucket/folderName, move a folder to a bucket
presign, generate a pre-signed URL for an Amazon S3 object
- default is one hour lifetime
- aws s3 presign s3://bucket/fileName --expires-in seconds, create a pre-signed URL
rm
- aws s3 rm s3://bucketName/fileName, delete a file in a bucket
- aws s3 rm s3://bucketName/folderName, delete a folder in a bucket
rb
- aws s3 rb s3://bucketName, remove a bucket, the bucket must be empty in order to remove
sync
- aws s3 sync folderName s3://bucketName/folderName, only copies over files that are new and updated
website, configures a bucket as a static website
Access Point
- Create an access point
- aws s3control create-access-point --name access_point_name --account-id 123456789012 --bucket bucket_name, create a bucket as an access point
- Access an access point
- aws s3 cp s3://arn:aws:s3:region:account_id:accesspoint/access_point_name/Hello.py ./, copy a file from an access point to local
Reference