

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在 Snowball Edge 上使用与亚马逊 S3 兼容存储空间的 S3 存储桶
<a name="working-s3-snow-buckets"></a>

借助 Snowball Edge 上的 Amazon S3 兼容存储，您可以在 Snowball Edge 设备上创建 Amazon S3 存储桶，以便在需要本地数据访问、本地数据处理和数据驻留的应用程序存储和检索对象。Snowball Edge 上与 Amazon S3 兼容的存储提供了一种新的存储类别`SNOW`，它使用 Amazon S3 APIs，旨在在多台 Snowball Edge 设备上以持久和冗余的方式存储数据。您可以在 Snowball Edge 存储桶上使用与在 Amazon S3 上相同的功能，包括存储桶生命周期策略、加密 APIs 和标记。

你可以使用 AWS Command Line Interface (AWS CLI) 在 Snowball Edge 上使用与 Amazon S3 兼容的存储，也可以通过 Java SDK 以编程方式使用。 AWS 使用 AWS CLI，您可以设置 s3api 或 s3control 端点，并通过命令与之交互。我们建议使用 s3api 端点，因为相同的端点可同时用于存储桶和对象操作。

**注意**  
s3api 端点可用于 Snowball Edge 软件的 8004 版及更高版本。要查找设备上安装的 Snowball Edge 软件的版本，请使用 `snowballEdge check-for-updates` 命令。要更新 Snowball Edge 设备，请参阅[更新 Snowball Edge 设备上的软件](https://docs.aws.amazon.com/snowball/latest/developer-guide/updating-device.html)。

## 使用 AWS CLI
<a name="working-s3-snow-buckets-cli-setup"></a>

请按照以下说明使用 AWS CLI在设备上使用 Amazon S3 存储桶。

**要设置 AWS CLI**

1. 在 `~/.aws/config` 中为对象端点创建配置文件。

   ```
   [profile your-profile]
   aws_access_key_id = your-access-id
   aws_secret_access_key = your-access-key
   region = snow
   ca_bundle = dev/apps/ca-certs/your-ca_bundle
   ```

1. 从您的设备获取证书。有关更多信息，请参阅《[Snowball Edge 开发人员指南](https://docs.aws.amazon.com/snowball/latest/developer-guide/using-client-commands.html#snowball-edge-certificates-cli)》**。

1. 如果您在虚拟环境中安装了开发工具包，请使用以下命令将其激活：

   ```
   source your-virtual-environment-name/bin/activate
   ```

设置操作后，你可以使用 s3api SDK 或 s3control SDK 通过访问 Snowball Edge 上的 S3 存储桶。 AWS CLI

**Example 使用 s3api SDK 访问 S3 存储桶**  

```
aws s3api list-buckets --endpoint-url https://s3api-endpoint-ip --profile your-profile                    
```

**Example 使用 s3control 软件开发工具包访问 S3 存储桶**  

```
aws s3control list-regional-buckets --account-id bucket-owner --endpoint-url https://s3ctrlapi-endpoint-ip --profile your-profile                
```

**Example 使用 s3api SDK 访问 S3 对象**  

```
aws s3api list-objects-v2 --endpoint-url https://s3api-endpoint-ip --profile your-profile
```

## 使用 Java SDK
<a name="working-s3-snow-buckets-python-setup"></a>

使用以下示例，利用 Java SDK 处理 Amazon S3 存储桶和对象。

```
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.http.SdkHttpClient;bg
import software.amazon.awssdk.http.apache.ApacheHttpClient;
import software.amazon.awssdk.regions.Region;

import java.net.URI;

AwsBasicCredentials creds = AwsBasicCredentials.create(accessKey, secretKey); // set creds by getting Access Key and Secret Key from snowball edge
SdkHttpClient httpClient = ApacheHttpClient.builder().tlsTrustManagersProvider(trustManagersProvider).build(); // set trust managers provider with client certificate from snowball edge
String s3SnowEndpoint = "10.0.0.0"; // set s3-snow object api endpoint from describe service

S3Client s3Client = S3Client.builder().httpClient(httpClient).region(Region.of("snow")).endpointOverride(new URI(s3SnowEndpoint)).credentialsProvider(StaticCredentialsProvider.create(creds)).build();
```

## 存储桶 ARN 格式
<a name="working-s3-snow-buckets-format"></a>

您可以使用此处列出的 Amazon 资源名称（ARN）格式来识别 Snowball Edge 设备上的 Amazon S3 存储桶：

```
arn:partition:s3:snow:account-id:device/device-id/bucket/bucket-name
```

您订购 *partition* Snowball Edge 设备所在地区的分区在哪里。 *device-id*如果设备是独立的 Snowball Edge 设备，则为 job\$1id；*cluster\$1id*如果你有 Snowball Edge 集群，则为 job\$1id。

## 存储桶位置格式
<a name="work-s3-snow-buckets-location"></a>

存储分区位置格式指定了将在其中创建存储分区的 Snowball Edge 设备。存储桶位置具有以下格式：

```
/device-id/bucket/bucket-name
```

有关更多信息，请参阅《 AWS CLI 命令参考》中的 [create-buck](https://awscli.amazonaws.com/v2/documentation/api/2.0.34/reference/s3api/create-bucket.html) et。