Use this file to discover all available pages before exploring further.
This Nebius AI Cloud reference shows you how to set up and configure AWS CLI and how to use it to work with buckets and objects complemented with useful parameters you can apply.
This section explains how to create a service account, grant it access to manage your resources and set up the AWS CLI to perform actions on the service account’s behalf. This section also covers other settings that connect the AWS CLI with Nebius AI Cloud and Object Storage.
AWS CLI setup instructions
Create a service account and save its ID to an environment variable:
Use the s3 rb (“remove bucket”) command to delete an empty bucket:
aws s3 rb s3://<bucket_name>
A bucket you want to delete must be completely empty. If you still have objects in your bucket, use the --force parameter to remove a non-empty bucket:
aws s3 rb s3://<bucket_name> --force
Usage examples
Empty bucket
Non-empty bucket (force delete)
Run:
aws s3 rb s3://example-bucket
Output:
remove_bucket: example-bucket
In this example, the bucket example-bucket contains three text files: lorem.txt, euismod.txt and litora.txt.Run:
You can use the AWS CLI to configure lifecycle rules for object expiration and storage-class transitions in a bucket.When you update a bucket lifecycle configuration, provide the full configuration in JSON, including all existing rules that you want to keep. If you omit a rule or some of its parameters, the new configuration replaces the old one and the omitted data is removed.To review the current lifecycle configuration of a bucket, run:
The AWS CLI does not support uploading objects to a storage class that differs from the bucket’s default. To do that, use s5cmd. For details, see How to upload.
You can choose to upload a single file or a whole folder containing any number of files:
Single file
Folder
Use the s3 cp (“CoPy”) command to upload a specified local file to your Object Storage bucket with a specified prefix:
upload: lorem-ipsum/lorem.txt to s3://example-bucket/lorem-ipsum/lorem.txtupload: lorem-ipsum/litora.txt to s3://example-bucket/lorem-ipsum/litora.txtupload: lorem-ipsum/euismod.txt to s3://example-bucket/lorem-ipsum/euismod.txt
s3 sync command only copies new and updated files compared to the target:
upload: lorem-ipsum/lorem.txt to s3://example-bucket/lorem-ipsum/lorem.txtupload: lorem-ipsum/litora.txt to s3://example-bucket/lorem-ipsum/litora.txtupload: lorem-ipsum/euismod.txt to s3://example-bucket/lorem-ipsum/euismod.txt
If the name of your local folder contains spaces, put it in single quotation marks. For example: Documents/'My ML configurations'/.
Use the s3 ls (“LiSt”) command with a <bucket_name> and a [<prefix_for_object_keys>] to see all the available buckets on your Object Storage cluster:
aws s3 ls s3://<bucket_name>/[<prefix_for_object_keys>] --recursive --human-readable --summarize
The command contains the following parameters:
--recursive keeps listing objects in the bucket under all available object keys until all have been listed.
--human-readable clearly defines data capacity units and rounds them up if necessary.
--summarize below the list of objects, shows the total number and the total size of all the objects in the bucket.
Usage example
In this example, your Object Storage example-bucket contains three text files: lorem.txt, euismod.txt and litora.txt under the object key lorem-ipsum/.Run:
aws s3 ls s3://example-bucket/ --recursive --human-readable --summarize
Use the s3 mv (“MoVe”) command to copy objects with a specified prefix from the source bucket to another destination bucket with a new prefix within your Object Storage cluster, then remove the objects at the origin:
The --recursive parameter used in the command above keeps listing objects in the bucket under all available object keys until all have been listed.
Usage example
In this example, your Object Storage example-bucket contains three text files: lorem.txt, euismod.txt and litora.txt under the object key lorem-ipsum/. You need to move these objects to another-example-bucket under the prefix lorem-ipsum-mv/.Run:
move: s3://example-bucket/lorem-ipsum/litora.txt to s3://another-example-bucket/lorem-ipsum-mv/litora.txtmove: s3://example-bucket/lorem-ipsum/lorem.txt to s3://another-example-bucket/lorem-ipsum-mv/lorem.txtmove: s3://example-bucket/lorem-ipsum/euismod.txt to s3://another-example-bucket/lorem-ipsum-mv/euismod.txt
You can set a different name for a file you want to download in <local/destination/path/>.
Usage example
In this example, you’ll download the lorem.txt file from the Object Storage example-bucket to the local example-download/ folder as lorem-download.txt.Run:
In this example, your Object Storage example-bucket contains three text files: lorem.txt, euismod.txt and litora.txt under the object key lorem-ipsum/. They need to be downloaded into the local example-download/ folder.Run:
download: s3://example-bucket/lorem-ipsum/lorem.txt to example-download/lorem.txtdownload: s3://example-bucket/lorem-ipsum/litora.txt to example-download/litora.txtdownload: s3://example-bucket/lorem-ipsum/euismod.txt to example-download/euismod.txt
s3 sync command copies new and updated files from your Object Storage bucket compared to a destination on your local machine:
In this example, your Object Storage example-bucket contains three text files: lorem.txt, euismod.txt and litora.txt under the object key lorem-ipsum/. They need to be downloaded into the local example-download/ folder.Run:
download: s3://example-bucket/lorem-ipsum/lorem.txt to example-download/lorem.txtdownload: s3://example-bucket/lorem-ipsum/litora.txt to example-download/litora.txtdownload: s3://example-bucket/lorem-ipsum/euismod.txt to example-download/euismod.txt
If the name of your local folder contains spaces, put it in single quotation marks. For example: Documents/'My ML configurations'/.
When you use the s3 cp, s3 sync, s3 mv or s3 rm command, you can apply the --include parameter to set the rule to only include parameters specified.For example, your Object Storage bucket contains images and text files, but you want to download text files only. Set the rule as follows:
When you use the s3 cp, s3 sync, s3 mv or s3 rm command, you can apply the --exclude parameter to set the rule to include all the files except the parameters specified.For example, your Object Storage bucket contains images in .png and .jpg formats together with text files, but you want to download text files only. Set the rule as follows:
--recursive copies all the objects available at the source.
--exclude "*.png" --exclude "*.jpg" applies the command to all file formats except .png and .jpg.Note that you need to use multiple --exclude parameters to define more than one condition.