

# S3 on Outposts デュアルスタックのエンドポイントの使用
<a name="s3-outposts-dual-stack-endpoints"></a>

S3 on Outposts デュアルスタックエンドポイントは、IPv6 および IPv4 を使用した S3 on Outposts バケットへのリクエストをサポートしています。このセクションは、S3 on Outposts デュアルスタックのエンドポイントを使用する方法を説明します。

**Topics**
+ [S3 on Outposts デュアルスタックのエンドポイント](#s3-outposts-dual-stack-endpoints-description)
+ [AWS CLI からのデュアルスタックのエンドポイントの使用](#s3-outposts-dual-stack-endpoints-cli)
+ [AWS SDK から S3 on Outposts デュアルスタックのエンドポイントを使用する](#s3-outposts-dual-stack-endpoints-sdks)

## S3 on Outposts デュアルスタックのエンドポイント
<a name="s3-outposts-dual-stack-endpoints-description"></a>

デュアルスタックのエンドポイントにリクエストを行うと、S3 on Outposts バケット URL は IPv6 または IPv4 アドレスに解決されます。IPv6 での S3 on Outposts バケットへのアクセスに関する詳細は、「[IPv6 経由で S3 on Outposts へのリクエストを行う](S3OutpostsIPv6-access.md)」を参照してください。

デュアルスタックのエンドポイントを介して S3 on Outposts バケットにアクセスするには、パス形式のエンドポイント名を使用します。S3 on Outposts はリージョンのデュアルスタックエンドポイント名のみをサポートしており、名前の一部としてリージョンを指定する必要があります。

デュアルスタックパス形式の FIPS エンドポイントの場合は、次の命名規則を使用します。

```
s3-outposts-fips.region.api.aws
```

デュアルスタックの非 FIPS エンドポイントの場合は、次の命名規則を使用します。

```
s3-outposts.region.api.aws
```

**注記**  
仮想ホスト形式のエンドポイント名は、S3 on Outposts ではサポートされていません。

## AWS CLI からのデュアルスタックのエンドポイントの使用
<a name="s3-outposts-dual-stack-endpoints-cli"></a>

このセクションでは、デュアルスタックのエンドポイントへリクエストするのに使用される AWS CLI コマンドの例を示します。AWS CLI をセットアップする手順については、「[AWS CLI および SDK for Java の使用開始](S3OutpostsGSCLIJava.md)」を参照してください。

AWS Config ファイルのプロファイル内で設定値 `use_dualstack_endpoint` を `true` に設定すると、`s3` と `s3api` AWS CLI コマンドによるすべての Amazon S3 リクエストが、指定されたリージョンのデュアルスタックエンドポイントに転送されます。`--region` オプションを使用して設定ファイルまたはコマンドでリージョンを指定します。

AWS CLI でデュアルスタックのエンドポイントを使用する場合、`path` のアドレス形式のみがサポートされます。設定ファイルで設定されたアドレス形式により、バケット名がホスト名の一部か URL の一部かが決まります。詳細については、*AWS CLI ユーザーガイド*の [https://docs.aws.amazon.com/cli/latest/reference/s3outposts/](https://docs.aws.amazon.com/cli/latest/reference/s3outposts/) を参照してください。

AWS CLI 経由でデュアルスタックのエンドポイントを使用するには、`s3control` コマンドまたは `s3outposts` コマンドの `http://s3.dualstack.region.amazonaws.com` または `https://s3-outposts-fips.region.api.aws` のエンドポイントを指定して、`--endpoint-url` パラメータを使用します。

例えば、次のようになります。

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

## AWS SDK から S3 on Outposts デュアルスタックのエンドポイントを使用する
<a name="s3-outposts-dual-stack-endpoints-sdks"></a>

このセクションでは、AWS SDK を使用してデュアルスタックのエンドポイントにアクセスする方法の例を示します。

### AWS SDK for Java 2.x のデュアルスタックのエンドポイントの例
<a name="s3-outposts-dual-stack-endpoints-examples-javav2"></a>

次の例では、AWS SDK for Java 2.x を使用して S3 on Outposts クライアントを作成する際に、`S3ControlClient` クラスと `S3OutpostsClient` クラスを使用してデュアルスタックエンドポイントを有効化する方法を示しています。Amazon S3 on Outposts の動作する Java の例の作成とテストに関する手順については、「[AWS CLI および SDK for Java の使用開始](S3OutpostsGSCLIJava.md)」を参照してください。

**Example – デュアルスタックのエンドポイントを有効にして `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();
        }
    }
}
```

**Example – デュアルスタックのエンドポイントを有効にして `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();
        }
    }
}
```

Windows で AWS SDK for Java 2.x を使用している場合は、必要に応じて、次の Java 仮想マシン (JVM) のプロパティを設定します。

```
java.net.preferIPv6Addresses=true
```