Amazon-AWS S3 Bucket Introduction / Installation and Configuration AWS CLI

table of Contents

1. AWS official documentation

2. Install and configure AWS CLI

3. Introduction to AWS S3 CLI commands

(1) All command keywords of aws s3 cli

(2) Detailed explanation of aws s3 cli command


1. AWS official documentation

AWS SDK for python (using boto3 library)

https://boto3.amazonaws.com/v1/documentation/api/latest/index.html

AWS S3 SDK for python 

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html

AWS S3 CLI documentation

https://docs.aws.amazon.com/cli/latest/reference/s3/index.html

 

2. Install and configure AWS CLI

Install AWS CLI using pip

pip install awscli --upgrade --user

Configure AWS CLI

#key is the company key

$ aws configure

AWS Access Key ID [None]: AKIAUxxxxxxxxxxxxxxxxxxxxx

AWS Secret Access Key [None]: Jdwtexxxxxxxxxxxxxxxxx

Default region name [None]: cn-north-1

Default output format [None]:json

 

3. Introduction to AWS S3 CLI commands

(1) All command keywords of aws s3 cli

cp: Copy the local file or S3 object to another location in the local or S3.

ls: List S3 objects and common prefixes under the prefix or all S3 buckets. This command will ignore --output and --no-paginate.

mb: Create an S3 bucket.

mv: Move the local file or S3 object to another location in the local or S3.

presign: Generate a pre-signed URL for the Amazon S3 object.

rb: Delete an empty S3 bucket. This command can only delete empty buckets.

rm: Delete an S3 object.

sync: Synchronize the directory and the S3 prefix. Recursively copy new and updated files from the source directory to the target. If the folder contains one or more files, the folder is only created in the target folder.

website: Set the website configuration of the bucket.

 

(2) Detailed explanation of aws s3 cli command

Upload file bucket

aws s3 cp L2_P3.zip s3://temp-files

aws s3 cp L2_02.zip s3://gz-shared --profile george

aws s3 cp ./mws_manage_fba_inventory.zip s3://temp-files/ --profile cn

Download file to local

aws s3 cp s3://temp-files/Listing_20190712.tar.gz /home/ubuntu

All buckets are listed

aws s3 ls

List all objects and folders in the bucket

aws s3 ls s3://bucket-name

List the object path in bucket-name/

aws s3 ls s3://bucket-name/path/

Delete a bucket

aws s3 rb s3://bucket-name

By default, the bucket must be empty for the operation to succeed. To delete a non-empty bucket, you need to include the --force option.

aws s3 rb s3://bucket-name --force

aws s3 cp s3://temp-files/res_amzseo_1001.zip /home/ubuntu

Sync files or folders to s3

aws s3 sync html_0912 s3://seo-html-bucket/html/html_0912/ #If there is no html directory, one will be created

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/helunqu2017/article/details/115221349