Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Object Storage
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Buckets
      • Creating a bucket
      • Deleting a bucket
      • Limiting the maximum size of a bucket
      • Allowing public access to a bucket
      • Bucket encryption
      • Managing object lifecycles
      • Managing CORS configurations
      • Editing a bucket ACL
      • Logging actions with the bucket
    • Objects
      • Uploading an object
      • Getting information about an object
      • Downloading an object
      • Getting a public link to an object
      • Deleting an object
      • Deleting a partially uploaded object
      • Editing an object ACL
    • Static website hosting
      • Hosting setup
      • Support for your own domain
      • Support for multiple domain names
      • Configuring HTTPS
  • Concepts
    • Overview
    • Bucket
    • Objects
    • Bucket versioning
    • Object lifecycles
    • CORS
    • Static website hosting
    • Pre-signed URLs
    • Multipart upload
    • Access control lists (ACLs)
    • Bucket Policy
    • Upload file via HTML form
    • Storage class
    • Logging actions with a bucket
    • Backups
    • TLS protocol
    • Quotas and limits
  • Tools
    • All tools
    • Console clients
      • AWS CLI
      • S3cmd
    • File browsers
      • CyberDuck
      • WinSCP
    • SDK
      • AWS SDK for Java
      • Python SDK (boto)
    • FUSE
      • s3fs
      • goofys
  • Amazon S3-compatible HTTP API
    • How to use the API
    • Signing requests
    • API reference
      • All services and methods
      • Bucket
        • All methods
        • create
        • getBucketEncryption
        • getMeta
        • listObjects
        • listBuckets
        • deleteBucket
        • deleteBucketEncryption
        • putBucketEncryption
        • putBucketVersioning
        • getBucketVersioning
        • putBucketLogging
        • getBucketLogging
        • listObjectVersions
      • Object
        • All methods
        • upload
        • get
        • copy
        • getObjectMeta
        • delete
        • deleteMultipleObjects
        • options
      • Multipart upload
        • General multipart upload procedure
        • startUpload
        • uploadPart
        • copyPart
        • listParts
        • abortUpload
        • completeUpload
        • listUploads
      • Static Website Hosting
        • All methods
        • upload
        • get
        • delete
        • Static website response codes
      • CORS
        • All methods
        • XML structure of CORS configuration
        • upload
        • get
        • delete
      • Lifecycles
        • All methods
        • XML structure of lifecycle configuration
        • upload
        • get
        • delete
      • ACL
        • All methods
        • XML structure of ACL configuration
        • objectGetAcl
        • objectPutAcl
        • bucketGetAcl
        • bucketPutAcl
      • Bucket Policy
        • All methods
        • GetBucketPolicy
        • PutBucketPolicy
        • DeleteBucketPolicy
        • Data schema
        • Actions
        • Conditions
      • Common request headers
      • Common response headers
      • Responses
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January 1 to March 1, 2019
  • Questions and answers
  1. Tools
  2. Console clients
  3. AWS CLI

AWS Command Line Interface (AWS CLI)

  • Before you start
  • Installation
  • Configuration
    • Configuration files
  • Specifics
  • Examples of operations
    • Creating a bucket
    • Uploading objects
    • Getting a list of objects
    • Deleting objects
    • Retrieving an object

AWS CLI is a command line interface designed for AWS services. To learn how to run commands, see the official Amazon documentation.

To work with Yandex Object Storage via the AWS CLI, you can use the following sets of commands:

  • s3api: Commands corresponding to operations in the REST API. Before you start, review the list of supported operations.
  • s3: Additional commands that make it easier to work with a large number of objects.

Before you start

  1. Create a service account.
  2. Assign a role to a service account.
  3. Create a static access key.

Installation

To install the AWS CLI, follow the instructions on the manufacturer's website.

Configuration

To configure the AWS CLI, use the aws configure command. The command requests values for the following parameters:

  1. AWS Access Key ID: Enter the ID of the key that you received when generating the static key.

  2. AWS Secret Access Key: Enter the secret key that you received when generating the static key.

  3. Default region name: Enter ru-central1.

    Note

    To work with Yandex Object Storage, always specify the ru-central1 region. A different region value may lead to an authorization error.

  4. Leave the other parameter values unchanged.

Configuration files

The aws configure command saves your settings to the following files:

  • Your static key to the .aws/credentials file in the format:

    [default]
                aws_access_key_id = id
                aws_secret_access_key = secretKey
    
  • The default region to the .aws/config file in the format:

    [default]
                region=ru-central1
    

Specifics

When using the AWS CLI to work with Object Storage, keep the following in mind:

  • The AWS CLI treats Object Storage like a hierarchical file system and object keys look like file paths.

  • When running the aws command to work with Object Storage, the --endpoint-url parameter is required because the client is configured to work with the Amazon servers by default.

  • When using macOS, in some cases you need to run the command:

    export PYTHONPATH=/Library/Python/2.7/site-packages; aws --endpoint-url=https://storage.yandexcloud.net s3 ls
    

Examples of operations

Note

To enable debug output in the console, use the --debug key.

Creating a bucket

aws --endpoint-url=https://storage.yandexcloud.net s3 mb s3://bucket-name

Note

When creating a bucket, follow the naming conventions.

Uploading objects

You can upload objects using one of the following methods:

  • Upload all objects from a local directory:

    aws --endpoint-url=https://storage.yandexcloud.net \
        s3 cp --recursive local_files/ s3://bucket-name/path_style_prefix/
    
  • Upload objects specified in the --include filter and skip objects specified in the --exclude filter:

    aws --endpoint-url=https://storage.yandexcloud.net \
        s3 cp --recursive --exclude "*" --include "*.log" \
        local_files/ s3://bucket-name/path_style_prefix/
    
  • Upload objects one by one, running the following command for each object:

    aws --endpoint-url=https://storage.yandexcloud.net \
        s3 cp testfile.txt s3://bucket-name/path_style_prefix/textfile.txt
    

Getting a list of objects

aws --endpoint-url=https://storage.yandexcloud.net \
    s3 ls --recursive s3://bucket-name

Deleting objects

You can delete objects using one of the following methods:

  • Delete all objects with the specified prefix:

    aws --endpoint-url=https://storage.yandexcloud.net \
        s3 rm s3://bucket-name/path_style_prefix/ --recursive
    
  • Delete objects specified in the --include filter and skip objects specified in the --exclude filter:

    aws --endpoint-url=https://storage.yandexcloud.net \
        s3 rm s3://bucket-name/path_style_prefix/ --recursive \
        --exclude "*" --include "*.log"
    
  • Delete objects one by one, running the following command for each object:

    aws --endpoint-url=https://storage.yandexcloud.net \
        s3 rm s3://bucket-name/path_style_prefix/textfile.txt
    

Retrieving an object

aws --endpoint-url=https://storage.yandexcloud.net \
    s3 cp s3://bucket-name/textfile.txt textfile.txt
In this article:
  • Before you start
  • Installation
  • Configuration
  • Configuration files
  • Specifics
  • Examples of operations
  • Creating a bucket
  • Uploading objects
  • Getting a list of objects
  • Deleting objects
  • Retrieving an object
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC