# AWS SDK for Java

[The AWS SDK for Java](https://aws.amazon.com/ru/sdk-for-java/) is a development kit for working with AWS services.

### Preparation for work <a href="#before-you-begin" id="before-you-begin"></a>

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

### Installation <a href="#installation" id="installation"></a>

To install the AWS SDK for JAVA, follow the [instructions](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-install.html) on the manufacturer's website.

### Customization <a href="#setup" id="setup"></a>

To configure, create configuration files in your home directory and specify in them:

* Static key in file `.aws/credentials`:

  ```
  [default]
              aws_access_key_id = <id>
              aws_secret_access_key = <secretKey>
  ```
* Default region in file `.aws/config`:

  ```
  [default]
              region=us-east-1
  ```

Use the address to access ColdStack `s3.coldstack.io`.

### Code examples <a href="#java-sdk-examples" id="java-sdk-examples"></a>

The sample code is located in the directory `aws-java-sdk/samples/AmazonS3`in the archive with the SDK distribution kit.

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

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

on the

```java
AmazonS3 s3 = AmazonS3ClientBuilder.standard()
    .withCredentials(new AWSStaticCredentialsProvider(credentials))
    .withEndpointConfiguration(
        new AmazonS3ClientBuilder.EndpointConfiguration(
            "s3.coldstack.io", "us-east-1"
        )
    )
    .build();
```
