gogoWebsite

What is S3 and how to access S3 through commands

Updated to 19 days ago

Table of contents

What is S3

Access S3 via cmd

Installing AWS CLI (AWS CLI depends on Python running, and Python needs to be installed in advance):

Configure the AWS CLI:

Set up endpoints (if any):

Operation example:

Summarize


What is S3

S3 (Simple Storage Service) is an object storage service provided by Amazon Web Services (AWS). It allows users to store and retrieve any amount of data over the Internet. Here are some important features and uses of S3:

Object storage: S3 is an object storage service suitable for storing various types of data, such as files, images, videos and text. Each object stored in S3 has a unique key (Key) used to identify and access the object in a bucket (Bucket).

Scalability: S3 is designed as a highly scalable storage solution. It supports storing large amounts of data and is able to automatically handle traffic growth and load balancing.

Security: S3 provides a variety of security features, including data encryption options (data at rest and data in transit), access control lists (ACLs), bucket policies and cross-region replication, etc. These features help users protect their data stored in S3 from unauthorized access and data breaches.

Multifunctionality: S3 is not only a storage service, but also used as a solution for static website hosting. Users can configure their S3 buckets to host static web pages and provide content distribution via AWS CloudFront for improved access speed and performance.

Cost-effectiveness: S3 provides a variety of storage categories, such as standard, low-frequency access (IA) and archived storage. Users can choose the storage category that best suits their needs based on the data access frequency, thereby achieving cost optimization.

Access S3 via cmd

Installing AWS CLI (AWS CLI depends on Python running, and Python needs to be installed in advance):

Install via Homebrew (macOS). Open the terminal and run the following command: brew install awscli

Configure the AWS CLI:

After the installation is complete, in the terminal, run the following command to start the configuration: aws configure

Then follow the prompts to enter the AWS Access Key ID, AWS Secret Access Key, the default AWS Region, and the output format (usually select json).

Set up endpoints (if any):

According to the endpoint provided, it is a custom S3 endpoint, and you need to specify the endpoint in the command:

aws s3 lsĀ --endpoint-url https://your-custom-s3-endpoint-url

Operation example:

Upload files to custom S3 endpoint:

aws s3 cp  s3://bucket-name/path-in-bucket/ --endpoint-url https://your-custom-s3-endpoint-url

Download the file from a custom S3 endpoint:

aws s3 cp s3://bucket-name/path-in-bucket/  --endpoint-url https://your-custom-s3-endpoint-url

Delete files on custom S3 endpoints:

aws s3 rm s3://bucket-name/path-in-bucket/ --endpoint-url https://your-custom-s3-endpoint-url

By adding after each AWS S3 command--endpoint-urlParameters and specify the URL of the custom S3 endpoint, you can access and manage objects and buckets on the custom S3 endpoint directly from the command line. If not, do not add--endpoint-urlparameter.

Summarize

The AWS CLI provides a wealth of options and commands for managing S3 buckets and objects, such as copy, move, synchronization, etc. Can be run byaws s3 helpTo view the help documentation for all available commands and options.

Through the above operations, use the command line to easily manage AWS S3 buckets and objects, and implement upload, download, delete files and other operations.