1) Install AWS CLI
- On Windows, download the AWSCLI-64 or AWSCLI-32 bit installer for Windows and set it as the default.
- On Mac and Linux
Requires Python 2.6.5 or later, and the Python Package Installer.
Then set it up with one command.
pip install awscli
After installation, use the aws --version command in the console to check the installed version.
2) Profile setting
You can access the administration panel of the service at https://cmc.objstor.cloud4u.com:8443 using the login details received from Cloud4U technical support after purchasing the service or from your S3 administrator.
In the Administration panel, in the Security Credentials find and remember ACCESS KEY ID, SECRET KEY
To work, we need to configure our profile, we can use it as a global profile, then use the aws configure command or a dedicated command.
In the example below, we will create an additional one named demo-s3. Type the command
aws configure --profile demo-s3
and enter the data requested by the system:
- AWS Access Key ID: (7683ed31dcXXXXXXXXX)
- AWS Secret Access Key: (oUiK3XXXXXXXXXXXXXXXXXXX)
- Default region name: K41
- Default output format: json
The output parameters can be of the following types:
- json
- text
- table
In the example we chose json.
We can set the created profile as the default, which we will do:
setx AWS_DEFAULT_PROFILE demo-s3
You will need to restart the console for the changes to take effect.
The profile configuration files themselves are located on the Windows system in the folder: C:\Users\ИМЯ_ПОЛЬЗОВАТЕЛЯ\.aws.
3) Start working with S3
To connect, we need to specify the connection point, endpoint-url, it can take the following values:
- S3 ENDPOINT (HTTP): http://s3.objstor.cloud4u.com:80/.
- S3 ENDPOINT (HTTPS): https://s3.objstor.cloud4u.com:443/.
3.1 Get the list of buckets with the list-buckets.
a) Specifying a specific profile:
aws s3api list-buckets -endpoint-url https://s3.objstor.cloud4u.com:443/ --profile demo-s3
b) With default profile:
aws s3api list-buckets -endpoint-url https://s3.objstor.cloud4u.com:443/.
We created a profile with JSON, but we can change this by specifying additionally --output, for example:
aws s3api list-buckets --endpoint-url https://s3.objstor.cloud4u.com:443/ --output text
If you get an error when running the command: Unable to locate credentials. You can configure credentials by running "aws configure" then you should check your profile settings and the correctness of the data entered.
3.2 Let's create a bucket using the create-bucket.
aws s3api create-bucket -endpoint-url https://s3.objstor.cloud4u.com:443/ --bucket demo-s3-bucket --acl public-read
The access rights list (acl) can have values such as:
- private
- public-read
- public-read-write
- authenticated-read
Please note that to access the bucket, you must use the URI http://s3.objstor.cloud4u.com/demo-s3-bucket, NOT the FQDN http://demo-s3-bucket.s3.objstor.cloud4u.com.
3.3 Let's upload the file to the created bucket using the put-object command.
aws s3api put-object -endpoint-url https://s3.objstor.cloud4y.ru:443/ --bucket demo-s3-bucket --key my-video-file.mp4 --body C:\Upload\my-video-file.mp4
After downloading, we will get this result:
All these actions can also be performed/checked in the control panel
We work similarly with other commands, see the detailed information.