Configuring AWS CLI
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
AWS CLI setup instructions
-
Create a service account and save its ID to an environment variable:
-
Grant edit access to the service account:
-
Get the tenant ID:
-
Get the ID of the default
editorsgroup: -
Add the service account to
editorsgroup:
-
Get the tenant ID:
-
Create an access key for the service account and get its AWS-like ID and contents:
-
Add the key to the AWS CLI configuration:
-
Depending on your project region, add the Nebius AI Cloud region ID and the Object Storage endpoint URL to the AWS CLI configuration:
For example, run the following commands for a project in
eu-north1:
Working with buckets
In Object Storage, you store your files in containers called buckets.Create a bucket
Use the s3 mb (“make bucket”) command to create a bucket:Usage example
Usage example
Run:Output:
List buckets on your cluster
Use the s3 ls (“LiSt”) command to see all the available buckets on your Object Storage cluster:Delete a bucket
Use the s3 rb (“remove bucket”) command to delete an empty bucket:--force option to remove a non-empty bucket:
Usage examples
Usage examples
- Empty bucket
- Non-empty bucket (force delete)
Run:Output:
Working with objects
In Object Storage, you work with files and folders called objects.Upload objects
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:
Usage example
Usage example
Run:Output:
List objects in your bucket
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:
--recursivekeeps listing objects in the bucket under all available object keys until all have been listed.--human-readableclearly defines data capacity units and rounds them up if necessary.--summarizebelow the list of objects, shows the total number and the total size of all the objects in the bucket.
Usage example
Usage example
In this example, your Object Storage Output:
example-bucket contains three text files: lorem.txt, euismod.txt and litora.txt under the object key lorem-ipsum/.Run:Move objects between buckets
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:--recursive option used in the command above keeps listing objects in the bucket under all available object keys until all have been listed.
Usage example
Usage example
In this example, your Object Storage Output:
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:Download objects
- Single object
- All objects with a prefix
Use the s3 cp (“CoPy”) command to download a specified object with a prefix from your Object Storage bucket to a destination on your local machine:You can set a different name for a file you want to download in
<local/destination/path/>.Usage example
Usage example
In this example, you’ll download the Output:
lorem.txt file from the Object Storage example-bucket to the local example-download/ folder as lorem-download.txt.Run:Documents/'My ML configurations'/.
Delete objects
Use the s3 rm (“ReMove”) command to delete objects from your Object Storage bucket.- Single object
- All objects with a prefix
Useful options for AWS CLI commands
This section describes useful options you can use with most of the commands listed above.Include
When you use the s3 cp, s3 sync, s3 mv or s3 rm command, you can apply the--include option to set the rule to only include options 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:
-
--recursivecopies all the objects available at the source. -
--include "*.txt"applies the command only to.txtfiles. Note that you need to use multiple--includeflags to define more than one condition.
Exclude
When you use the s3 cp, s3 sync, s3 mv or s3 rm command, you can apply the--exclude option to set the rule to include all the files except the options 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:
-
--recursivecopies all the objects available at the source. -
--exclude "*.png" --exclude "*.jpg"applies the command to all file formats except.pngand.jpg. Note that you need to use multiple--excludeflags to define more than one condition.