在 Outposts 雙堆疊端點上使用 S3 - Amazon Simple Storage Service

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

在 Outposts 雙堆疊端點上使用 S3

Outposts 上的 S3 雙堆疊端點支援透過 IPv6 和 IPv4 向 Outposts 儲存貯體上的 S3 請求。本節說明如何在 Outposts 雙堆疊端點上使用 S3。

Outposts 雙堆疊端點上的 S3

當您向雙堆疊端點發出要求時,Outposts 儲存貯體上的 S3 會解析為 IPv6 或 IPv4 位址。如需透過 IPv6 存取 Outposts 儲存貯體上 S3 的詳細資訊,請參閱通過 IPv6 向 Outposts 上的 S3 發出請求

若要透過雙堆疊端點存取 Outposts 儲存貯體上的 S3,請使用路徑樣式端點名稱。Outposts 上的 S3 僅支援地區雙堆疊端點名稱,這表示您必須將區域指定為名稱的一部分。

對於雙堆疊路徑樣式 FIP 端點,請使用下列命名慣例:

s3-outposts-fips.region.api.aws

對於雙堆疊非 FIP 端點,請使用下列命名慣例:

s3-outposts.region.api.aws
注意

Outposts 上的 S3 不支援虛擬託管式端點名稱。

從 AWS CLI 使用雙堆疊端點

本節提供可用於要求雙堆疊端點的 AWS CLI 命令範例。如需設定 AWS CLI 的說明,請參閱使用 AWS CLI 和 SDK for Java 開始使用

您可以在檔案中的設定AWS Config檔trueuse_dualstack_endpoint將組態值設定為,以將s3s3apiAWS CLI命令發出的所有 Amazon S3 請求導向指定區域的雙堆疊端點。您可以在組態檔案中或使用--region選項的指令中指定 Region。

搭配使用雙堆疊端點時AWS CLI,僅支援path定址樣式。在配置文件中設置的地址樣式會決定存儲桶名稱是在主機名稱還是在 URL 中。如需詳細資訊,請參閱《AWS CLI 使用者指南》中的 s3outposts

若要透過使用雙堆疊端點AWS CLI,請將--endpoint-url參數與http://s3.dualstack.region.amazonaws.com.rproxy.goskope.comhttps://s3-outposts-fips.region.api.aws端點搭配使用,以執行任何s3controls3outposts命令。

例如:

$ aws s3control list-regional-buckets --endpoint-url https://s3-outposts.region.api.aws

在來自開發套件的 Outposts 雙堆疊端點上使用 S3 AWS

本節提供如何使用 AWS 開發套件存取雙堆疊端點的範例。

AWS SDK for Java 2.x 雙堆疊端點範例

下列範例說明在 Outposts 用戶端上使用建立 S3 時,如何使用S3ControlClientS3OutpostsClient類別啟用雙堆疊端點。AWS SDK for Java 2.x如需在 Outposts 上為 Amazon S3 建立和測試工作 Java 範例的指示,請參閱使用 AWS CLI 和 SDK for Java 開始使用

範例 — 建立啟用雙堆疊端點的S3ControlClient類別
import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3control.S3ControlClient; import software.amazon.awssdk.services.s3control.model.ListRegionalBucketsRequest; import software.amazon.awssdk.services.s3control.model.ListRegionalBucketsResponse; import software.amazon.awssdk.services.s3control.model.S3ControlException; public class DualStackEndpointsExample1 { public static void main(String[] args) { Region clientRegion = Region.of("us-east-1"); String accountId = "111122223333"; String navyId = "9876543210"; try { // Create an S3ControlClient with dual-stack endpoints enabled. S3ControlClient s3ControlClient = S3ControlClient.builder() .region(clientRegion) .dualstackEnabled(true) .build(); ListRegionalBucketsRequest listRegionalBucketsRequest = ListRegionalBucketsRequest.builder() .accountId(accountId) .outpostId(navyId) .build(); ListRegionalBucketsResponse listBuckets = s3ControlClient.listRegionalBuckets(listRegionalBucketsRequest); System.out.printf("ListRegionalBuckets Response: %s%n", listBuckets.toString()); } catch (AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 on Outposts couldn't process // it, so it returned an error response. e.printStackTrace(); } catch (S3ControlException e) { // Unknown exceptions will be thrown as an instance of this type. e.printStackTrace(); } catch (SdkClientException e) { // Amazon S3 on Outposts couldn't be contacted for a response, or the client // couldn't parse the response from Amazon S3 on Outposts. e.printStackTrace(); } } }
範例 — 創建啟S3OutpostsClient用雙堆棧端點
import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3outposts.S3OutpostsClient; import software.amazon.awssdk.services.s3outposts.model.ListEndpointsRequest; import software.amazon.awssdk.services.s3outposts.model.ListEndpointsResponse; import software.amazon.awssdk.services.s3outposts.model.S3OutpostsException; public class DualStackEndpointsExample2 { public static void main(String[] args) { Region clientRegion = Region.of("us-east-1"); try { // Create an S3OutpostsClient with dual-stack endpoints enabled. S3OutpostsClient s3OutpostsClient = S3OutpostsClient.builder() .region(clientRegion) .dualstackEnabled(true) .build(); ListEndpointsRequest listEndpointsRequest = ListEndpointsRequest.builder().build(); ListEndpointsResponse listEndpoints = s3OutpostsClient.listEndpoints(listEndpointsRequest); System.out.printf("ListEndpoints Response: %s%n", listEndpoints.toString()); } catch (AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 on Outposts couldn't process // it, so it returned an error response. e.printStackTrace(); } catch (S3OutpostsException e) { // Unknown exceptions will be thrown as an instance of this type. e.printStackTrace(); } catch (SdkClientException e) { // Amazon S3 on Outposts couldn't be contacted for a response, or the client // couldn't parse the response from Amazon S3 on Outposts. e.printStackTrace(); } } }

如果您AWS SDK for Java 2.x在視窗上使用,您可能必須設定下列 Java 虛擬機器 (JVM) 屬性:

java.net.preferIPv6Addresses=true