在 Snowball 邊緣裝置上使用 S3 儲存貯體 - AWS Snowball Edge 開發者指南

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

在 Snowball 邊緣裝置上使用 S3 儲存貯體

您可以在 Snowball Edge 裝置上建立 Amazon S3 儲存貯體,針對需要本機資料存取、本機資料處理和資料存放的應用程式在內部部署存放和擷取物件。Snow 系列裝置上的 Amazon S3 相容儲存提供新的儲存類別SNOW,該類別使用 Amazon S3 API,其設計用於在多個 Snowball Edge 裝置上持久且冗餘地存放資料。您可以在 Amazon S3 上使用與 Snowball Edge 儲存貯體相同的 API 和功能,包括儲存貯體生命週期政策、加密和標記。

使用 AWS CLI

請遵循下列指示,使用裝置上的 Amazon S3 儲存貯體使用 AWS CLI.

若要設定 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
  2. 從您的裝置取得憑證。如需詳細資訊,請參閱 S nowball 邊緣開發人員指南

  3. 如果您在虛擬環境中安裝 SDK,請使用以下命令將其啟動:

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

設定作業之後,您可以使用 API 呼叫與 AWS CLI. 在下列範例中,cert是您剛才使用 IAM 取得的裝置憑證。

訪問對象操作

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

存取值區作業

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

使用 Java 開發套件

使用下列範例來使用 Java 開發套件處理 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; 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 格式

您可以使用此處列出的亞馬遜資源名稱 (ARN) 格式來識別 Snowball 邊緣裝置上的 Amazon S3 儲存貯體:

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

其中分割區是您訂購 Snowball Edge 裝置所在地區的分割區。 如果裝置是獨立的 Snowball 邊緣裝置,則裝置識別碼為 job_id;如果您有一個 Snowball 邊緣叢集,則為叢集識別碼

在 Snowball 邊緣裝置上建立 S3 儲存貯體

您可以在 Snowball Edge 裝置上建立 Amazon S3 儲存貯體,針對需要本機資料存取、本機資料處理和資料存放的應用程式在邊緣存放和擷取物件。Snow 系列裝置上的 Amazon S3 相容儲存提供新的儲存類別SNOW,該儲存類別使用 Amazon S3,其設計用於在多個裝置上持久且冗餘地存放資料。您可以使用與 Amazon S3 儲存貯體相同的 API 和功能,包括儲存貯體生命週期政策、加密和標記。

下列範例會使用為 Snowball 邊緣裝置建立 Amazon S3 儲存貯體。 AWS CLI若要執行此命令,請以您自己的資訊取代使用者輸入預留位置。

aws s3control --profile your-profile create-bucket --bucket your-snow-bucket --endpoint-url https://s3ctrlapi-endpoint-ip

使用建立和管理物件生命週期組態 AWS CLI

您可以使用 Amazon S3 生命週期為 Snow 系列裝置上的 Amazon S3 相容儲存最佳化儲存容量。您可以建立生命週期規則,在物件老化或取代為較新的版本時使這些物件過期。您可以建立、啟用、停用或刪除生命週期規則。如需 Amazon S3 生命週期的詳細資訊,請參閱管理儲存生命週期

注意

建立值區的 AWS 帳戶 使用者擁有該值區,並且是唯一可以建立、啟用、停用或刪除生命週期規則的儲存貯體。

若要使用 AWS Command Line Interface (AWS CLI) 在 Snow 系列裝置儲存貯體上建立和管理 Amazon S3 相容儲存體的生命週期組態,請參閱下列範例。

將生命週期配置放在 Snowball 邊緣存儲桶上

下列 AWS CLI 範例會在 Snowball Edge 儲存貯體上放置生命週期組態原則。此原則指定具有標記前置詞 (myprefix) 和標籤的所有物件都會在 10 天後到期。若要使用此範例,請以您自己的資訊取代每個使用者輸入預留位置。

首先,將生命週期組態原則儲存到 JSON 檔案。在此範例中,檔案的名稱為lifecycle-example.json

{ "Rules": [{ "ID": "id-1", "Filter": { "And": { "Prefix": "myprefix", "Tags": [{ "Value": "mytagvalue1", "Key": "mytagkey1" }, { "Value": "mytagvalue2", "Key": "mytagkey2" } ], } }, "Status": "Enabled", "Expiration": { "Days": 10 } }] }

儲存檔案後,請提交 JSON 檔案做為put-bucket-lifecycle-configuration命令的一部分。若要使用此指令,請以您自己的資訊取代每個使用者輸入預留位置。

aws s3control put-bucket-lifecycle-configuration --bucket example-snow-bucket --profile your-profile --lifecycle-configuration file://lifecycle-example.json --endpoint-url https://s3ctrlapi-endpoint-ip

若要取得有關此指令的更多資訊,請參閱《指AWS CLI 令參考put-bucket-lifecycle-configuration中的。

在 Snowball 邊緣裝置上使用 S3 儲存貯體

使用 Snow 系列裝置上的 Amazon S3 相容儲存空間,您可以在 Snowball Edge 裝置上建立 Amazon S3 儲存貯體,在現場部署存放和擷取物件,以供需要本機資料存取、本機資料處理和資料存放區的應用程式使用。Snow 系列裝置上的 Amazon S3 相容儲存提供新的儲存類別SNOW,該類別使用 Amazon S3 API,其設計用於在多個 Snowball Edge 裝置上持久且冗餘地存放資料。您可以在 Amazon S3 上使用與 Snowball Edge 儲存貯體相同的 API 和功能,包括儲存貯體生命週期政策、加密和標記。您可以使用 AWS Command Line Interface (AWS CLI) 或開發套件,在 AWS Snow 系列裝置上使用 Amazon S3 相容的儲存裝置。

判斷您是否可以在 Snow 系列裝置儲存貯體上存取 Amazon S3 相容的儲存

下列範例使用head-bucket命令來判斷 Amazon S3 儲存貯體是否存在,以及您有使用存取該儲存貯體的權限 AWS CLI。若要使用此指令,請以您自己的資訊取代每個使用者輸入預留位置。

aws s3api head-bucket --bucket sample-bucket --profile your-profile --endpoint-url https://s3api-endpoint-ip

擷取值區或地區值區的清單

使用list-regional-bucketslist buckets列出 Snow 系列裝置儲存貯體上使用的 Amazon S3 相容儲存貯體 AWS CLI。

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

若要取得有關該list-regional-buckets指令的更多資訊,請參閱《指AWS CLI 令參考list-regional-buckets中的。

aws s3 list-buckets --account-id 123456789012 --endpoint-url https://s3api-endpoint-ip

若要取得有關list-buckets指令的詳細資訊,請參閱《指令參考》中的AWS CLI list 值區

下列 SDK for Java 範例會取得 Snowball 邊緣裝置上的值區清單。如需詳細資訊,請參閱 Amazon 簡易儲存服務 API 參考ListBuckets中的。

import com.amazonaws.services.s3.model.*; public void listBuckets() { ListBucketsRequest reqListBuckets = new ListBucketsRequest() .withAccountId(AccountId) ListBucketsResult respListBuckets = s3APIClient.RegionalBuckets(reqListBuckets); System.out.printf("ListBuckets Response: %s%n", respListBuckets.toString()); }

下列 PowerShell 範例會取得 Snowball Edge 裝置上的值區清單。

Get-S3CRegionalBucketList -AccountId 012345678910 -Endpoint "https://snowball_ip" -Region snow

下列 .NET 範例會取得 Snowball 邊緣裝置上的值區清單。

using Amazon.S3Control; using Amazon.S3Control.Model; namespace SnowTest; internal class Program { static async Task Main(string[] args) { var config = new AmazonS3ControlConfig { ServiceURL = "https://snowball_ip", AuthenticationRegion = "snow" // Note that this is not RegionEndpoint }; var client = new AmazonS3ControlClient(config); var response = await client.ListRegionalBucketsAsync(new ListRegionalBucketsRequest() { AccountId = "012345678910" }); } }

得到一個桶

下列範例使用取得 Snow 系列裝置儲存貯體上的 Amazon S3 相容儲存貯體 AWS CLI。若要使用此指令,請以您自己的資訊取代每個使用者輸入預留位置。

aws s3control get-bucket --account-id 123456789012 --bucket DOC-EXAMPLE-BUCKET --profile your-profile --endpoint-url https://s3ctrlapi-endpoint-ip

如需有關此命令的詳細資訊,請參閱命AWS CLI 令參考中的 get-bucket

下列 Snow 系列裝置上的 Amazon S3 相容儲存範例會使用適用 SDK for Java 取得儲存貯體。如需詳細資訊,請參閱 Amazon 簡易儲存服務 API 參考GetBucket中的。

import com.amazonaws.services.s3control.model.*; public void getBucket(String bucketName) { GetBucketRequest reqGetBucket = new GetBucketRequest() .withBucket(bucketName) .withAccountId(AccountId); GetBucketResult respGetBucket = s3ControlClient.getBucket(reqGetBucket); System.out.printf("GetBucket Response: %s%n", respGetBucket.toString()); }

刪除值區

重要
  • 創建 AWS 帳戶 存儲桶的擁有它,並且是唯一可以刪除它的存儲桶。

  • Snow 系列裝置儲存貯體必須是空的,才能刪除它們。

  • 您無法恢復刪除後的儲存貯體。

下列範例會使用刪除 Snow 系列裝置儲存貯體上的 Amazon S3 相容儲存貯體 AWS CLI。若要使用此指令,請以您自己的資訊取代每個使用者輸入預留位置。

aws s3control delete-bucket --account-id 123456789012 --bucket DOC-EXAMPLE-BUCKET --profile your-profile --endpoint-url https://s3ctrlapi-endpoint-ip

如需有關此命令的詳細資訊,請參閱命AWS CLI 令參考中的 delete bucket