Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Object Storage
    • All tools
      • All SDKs
      • AWS SDK for Java
      • AWS SDK for JavaScript
      • AWS SDK for Python (boto)
      • AWS SDK for .NET
      • AWS SDK for C++
      • AWS SDK for PHP
      • AWS SDK for Go
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Bucket logs
  • Release notes
  • FAQ

In this article:

  • Getting started
  • Installation
  • Configuration
  • Updating an endpoint
  1. Tools
  2. SDK
  3. AWS SDK for Java

AWS SDK for Java

Written by
Yandex Cloud
Updated at April 1, 2025
  • Getting started
  • Installation
  • Configuration
  • Updating an endpoint

The AWS SDK for Java is an Yandex Object Storage-compatible software development kit for integration with AWS services.

You will use the AWS SDK for Java to create a bucket, upload objects to it, clean up its contents, and delete it.

Getting startedGetting started

  1. Create a service account.

  2. Assign to the service account the roles required for your project, e.g., storage.editor for a bucket (to work with a particular bucket) or a folder (to work with all buckets in this folder). For more information about roles, see Access management with Yandex Identity and Access Management.

    To work with objects in an encrypted bucket, a user or service account must have the following roles for the encryption key in addition to the storage.configurer role:

    • kms.keys.encrypter: To read the key, encrypt and upload objects.
    • kms.keys.decrypter: To read the key, decrypt and download objects.
    • kms.keys.encrypterDecrypter: This role includes the kms.keys.encrypter and kms.keys.decrypter permissions.

    For more information, see Key Management Service service roles.

  3. Create a static access key.

    As a result, you will get the static access key data. To authenticate in Object Storage, you will need the following:

    • key_id: Static access key ID
    • secret: Secret key

    Save key_id and secret: you will not be able to get the key value again.

Note

A service account is only allowed to view a list of buckets in the folder it was created in.

A service account can perform actions with objects in buckets that are created in folders different from the service account folder. To enable this, assign the service account roles for the appropriate folder or its bucket.

InstallationInstallation

Warning

On December 31, 2025, the AWS SDK for Java version 1.x will reach end-of-support. We recommend that you migrate to the AWS SDK for Java version 2.x to keep receiving new features and security updates.

AWS SDK v2.x
AWS SDK v1.x
  1. Install Java.

  2. Install Apache Maven to build your project.

  3. Create a project as described in the AWS guide.

    Below is the structure of the created project:

    getstarted
    ├── README.md
    ├── pom.xml
    └── src
        ├── main
        │   ├── java
        │   │   └── org
        │   │       └── example
        │   │           ├── App.java
        │   │           ├── DependencyFactory.java
        │   │           └── Handler.java
        │   └── resources
        │       └── simplelogger.properties
        └── test
            └── java
                └── org
                    └── example
                        └── HandlerTest.java
    
    10 directories, 7 files
    
  4. Edit the project code as described in the AWS guide.

To install the AWS SDK for Java v.1.x, use the instructions on the vendor's website.

ConfigurationConfiguration

  1. Create a directory to store the authentication data in and navigate to it:

    For macOS and Linux:

    mkdir ~/.aws/
    

    For Windows:

    mkdir C:\Users\<username>\.aws\
    
  2. In the .aws directory, create a file named credentials, copy the credentials you got earlier, and paste them into it:

    [default]
    aws_access_key_id = <static_key_ID>
    aws_secret_access_key = <secret_key>
    
  3. Create a file named config with the default region settings and copy the following information to it:

    [default]
    region = ru-central1
    endpoint_url = https://storage.yandexcloud.net
    

    Note

    Some apps designed to work with Amazon S3 do not allow you to specify the region; this is why Object Storage may also accept the us-east-1 value.

To access Object Storage, use the https://storage.yandexcloud.net endpoint.

Updating an endpointUpdating an endpoint

AWS SDK v2.x
AWS SDK v1.x
  1. In the /src/main/java/org/example directory, open the DependencyFactory.java file and modify the DependencyFactory class:

    public class DependencyFactory {
        private DependencyFactory() {}
        public static S3Client s3Client() {
            return S3Client.builder()
            .endpointOverride(URI.create("https://storage.yandexcloud.net"))
            .httpClientBuilder(ApacheHttpClient.builder())
            .build();
        }
    }
    
  2. Run the code as described in the AWS guide.

See this repository for other examples of using the AWS SDK for Java.

In the aws-java-sdk/samples/AmazonS3 directory, the SDK distribution archive contains the code you need to modify.

To connect to Object Storage, replace the code in the example:

AmazonS3 s3 = AmazonS3ClientBuilder.standard()
    .withCredentials(new AWSStaticCredentialsProvider(credentials))
    .withRegion("us-west-2")
    .build();

with

AmazonS3 s3 = AmazonS3ClientBuilder.standard()
    .withCredentials(new AWSStaticCredentialsProvider(credentials))
    .withEndpointConfiguration(
        new AmazonS3ClientBuilder.EndpointConfiguration(
            "storage.yandexcloud.net","ru-central1"
        )
    )
    .build();

See this repository for other examples of using the AWS SDK for Java.

Was the article helpful?

Previous
All SDKs
Next
AWS SDK for JavaScript
Yandex project
© 2025 Yandex.Cloud LLC