

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Neptune パブリックエンドポイント
<a name="neptune-public-endpoints"></a>

## 概要:
<a name="neptune-public-endpoints-overview"></a>

Amazon Neptune クラスターは通常 VPC 内にデプロイされ、その VPC 内からのみアクセスできます。これには、VPC 内のアプリケーションと開発環境を設定するか、プロキシサービスを使用して VPC に接続する必要があります。これにより、セットアップ時間とコストが増加します。

パブリックエンドポイントは、インターネット経由で Neptune に直接接続できるようにすることで、このエクスペリエンスを簡素化します。これにより、専門的なネットワーク知識がなくても、グラフデータベースの使用を簡単に開始できます。

## パブリックエンドポイントを使用するべき場合
<a name="neptune-public-endpoints-when-to-use"></a>

以下のシナリオでは、パブリックエンドポイントの使用を検討してください。
+ 複雑なネットワーク設定を行うことなく開発環境またはテスト環境で Neptune をすばやくテストする必要がある
+  AWS ネットワークに関する専門知識がない
+ アプリケーションのセキュリティ体制にプライベート VPC が必要ではない
+ ローカル開発環境から Neptune に接続する必要がある

## セキュリティに関する考慮事項
<a name="neptune-public-endpoints-security"></a>

パブリックエンドポイントを使用する場合は、以下のセキュリティ上の考慮事項に留意してください。
+ パブリックエンドポイントが有効になっているクラスターには、IAM 認証が必要です。
+ データベースへのアクセスは、使用されるセキュリティグループによって制御されます。
+ クラスターに接続できる IP アドレスを制限できます。
+ IAM ポリシーを使用して、パブリックアクセスを持つクラスターを作成または変更できるユーザーを制御できます。参照: [パブリックアクセスの作成の制限](#neptune-public-endpoints-restrict-access)

## パブリックエンドポイントの有効化
<a name="neptune-public-endpoints-enabling"></a>

デフォルトでは、新しい Neptune データベースはパブリックエンドポイントを無効にして作成されます。クラスターを作成または変更する場合は、パブリックアクセスを明示的に有効にする必要があります。

パブリックエンドポイントは、Neptune エンジンリリースバージョン 1.4.6.x でサポートされています。この機能を使用するには、既存のクラスターを少なくともこのバージョンにアップグレードする必要があります。

パブリックエンドポイント設定は、Neptune クラスターではなく Neptune インスタンスで使用できます。したがって、Neptune クラスターは、パブリックエンドポイントを持つインスタンスとそうでないインスタンスで存在できます。ただし、このような設定はお勧めしません。詳細については、「[パブリックエンドポイントの仕組み](#neptune-public-endpoints-how-they-work)」を参照してください。

## 前提条件
<a name="neptune-public-endpoints-prerequisites"></a>

### Neptune クラスターでの IAM 認証設定
<a name="neptune-public-endpoints-iam-auth"></a>

Neptune インスタンスでパブリックエンドポイントを有効にする前に、クラスターが IAM 認証をサポートしていることを確認してください。サポートしていない場合は、次のコマンドを使用して有効にします。

```
aws neptune modify-db-cluster \
  --region us-west-2 \
  --engine graphdb \
  --engine-version 1.4.6.x \
  --db-cluster-identifier neptune-public-endpoint \
  --enable-iam-database-authentication
```

### ネットワーク設定
<a name="neptune-public-endpoints-network-settings"></a>

1. VPC にパブリックルーティングを有効にするサブネットがある (サブネットのルートテーブルにインターネットゲートウェイのエントリがある) ことを確認します。クラスターの作成時に `db-subnet-group-name` パラメータを指定しない場合、クラスターの作成にはデフォルトのサブネットグループが選択されます。

1. クラスターにアタッチされたセキュリティグループが、許可された IP 範囲と許可されたポートのインバウンドトラフィックを許可していることを確認します。例えば、すべての IP からの TCP トラフィックがポート 8182 で実行されている Neptune インスタンスに接続できるようにする場合、インバウンドルールには次の設定内容が必要です。

   1. タイプ: すべての TCP

   1. [Protocol]: TCP

   1. ポート範囲: 8182

   1. CIDR ブロック: 0.0.0.0/0

**注記**  
CIDR ブロック範囲を 0.0.0.0/0 に設定することはできますが、セキュリティ体制を強化するために、これをクライアントアプリケーションの特定の IP 範囲に削減することをお勧めします。

## パブリックエンドポイントを使用した新しいインスタンスの作成
<a name="neptune-public-endpoints-creating-instance"></a>

 AWS マネジメントコンソール、 AWS CLI、または AWS SDK を使用して、パブリックエンドポイントを持つ新しい Neptune インスタンスを作成できます。

CLI AWS の使用:

```
aws neptune create-db-instance \
  --region us-west-2 \
  --engine graphdb \
  --engine-version 1.4.6.x \
  --db-cluster-identifier neptune-public-endpoint \
  --publicly-accessible
```

## パブリックアクセス用の既存のインスタンスの変更
<a name="neptune-public-endpoints-modifying-instance"></a>

パブリックアクセスを有効にするように既存の Neptune インスタンスを変更するには:

```
aws neptune modify-db-instance \
  --region us-west-2 \
  --engine graphdb \
  --engine-version 1.4.6.x \
  --db-instance-identifier neptune-public-endpoint \
  --publicly-accessible
```

**注記**  
パブリックアクセスは、クラスターレベルではなくインスタンスレベルで有効になります。クラスターにパブリックエンドポイント経由で常にアクセスできるようにするには、クラスター内のすべてのインスタンスでパブリックアクセスが有効になっている必要があります。

## パブリックエンドポイントの使用
<a name="neptune-public-endpoints-using"></a>

データベースが到達可能かどうかを確認するには、CLI `NeptuneData` API AWS を使用してステータスを確認します。

```
aws neptunedata get-engine-status \
  --endpoint-url https://my-cluster-name.cluster-abcdefgh1234.us-east-1.neptune.amazonaws.com:8182
```

データベースにアクセスできる場合、レスポンスは次のようになります。

```
{
    "status": "healthy",
    "startTime": "Sun Aug 10 06:54:15 UTC 2025",
    "dbEngineVersion": "1.4.6.0.R1",
    "role": "writer",
    "dfeQueryEngine": "viaQueryHint",
    "gremlin": {
        "version": "tinkerpop-3.7.1"
    },
    "sparql": {
        "version": "sparql-1.1"
    },
    "opencypher": {
        "version": "Neptune-9.0.20190305-1.0"
    },
    "labMode": {
        "ObjectIndex": "disabled",
        "ReadWriteConflictDetection": "enabled"
    },
    "features": {
        "SlowQueryLogs": "disabled",
        "InlineServerGeneratedEdgeId": "disabled",
        "ResultCache": {
            "status": "disabled"
        },
        "IAMAuthentication": "disabled",
        "Streams": "disabled",
        "AuditLog": "disabled"
    },
    "settings": {
        "StrictTimeoutValidation": "true",
        "clusterQueryTimeoutInMs": "120000",
        "SlowQueryLogsThreshold": "5000"
    }
}
```

## データベースをクエリする方法の例
<a name="neptune-public-endpoints-examples"></a>

### AWS CLI
<a name="neptune-public-endpoints-aws-cli"></a>

```
aws neptunedata execute-open-cypher-query \
--open-cypher-query "MATCH (n) RETURN n LIMIT 10" \
--endpoint-url https://my-cluster-name.cluster-abcdefgh1234.us-east-1.neptune.amazonaws.com:8182
```

### Python
<a name="neptune-public-endpoints-python"></a>

```
import boto3
import json
from botocore.config import Config

# Configuration - Replace with your actual Neptune cluster details
cluster_endpoint = "my-cluster-name.cluster-abcdefgh1234.my-region.neptune.amazonaws.com"
port = 8182
region = "my-region"

# Configure Neptune client
# This disables retries and sets the client timeout to infinite 
#     (relying on Neptune's query timeout)
endpoint_url = f"https://{cluster_endpoint}:{port}"
config = Config(
    region_name=region,
    retries={'max_attempts': 1},
    read_timeout=None
)

client = boto3.client("neptunedata", config=config, endpoint_url=endpoint_url)

cypher_query = "MATCH (n) RETURN n LIMIT 5"
try:
    response = client.execute_open_cypher_query(openCypherQuery=cypher_query)
    print("openCypher Results:")
    for item in response.get('results', []):
        print(f"  {item}")
except Exception as e:
    print(f"openCypher query failed: {e}")
```

### JavaScript
<a name="neptune-public-endpoints-javascript"></a>

```
import {
    NeptunedataClient,
    GetPropertygraphSummaryCommand
} from "@aws-sdk/client-neptunedata";
import { inspect } from "util";
import { NodeHttpHandler } from "@smithy/node-http-handler";

/**
 * Main execution function
 */
async function main() {
    // Configuration - Replace with your actual Neptune cluster details
    const clusterEndpoint = 'my-cluster-name.cluster-abcdefgh1234.my-region.neptune.amazonaws.com';
    const port = 8182;
    const region = 'my-region';

    // Configure Neptune client
    // This disables retries and sets the client timeout to infinite 
    //     (relying on Neptune's query timeout)
    const endpoint = `https://${clusterEndpoint}:${port}`;
    const clientConfig = {
        endpoint: endpoint,
        sslEnabled: true,
        region: region,
        maxAttempts: 1,  // do not retry
        requestHandler: new NodeHttpHandler({
            requestTimeout: 0  // no client timeout
        })
    };

    const client = new NeptunedataClient(clientConfig);
    try {
        try {
            const command = new GetPropertygraphSummaryCommand({ mode: "basic" });
            const response = await client.send(command);
            console.log("Graph Summary:", inspect(response.payload, { depth: null }));
        } catch (error) {
            console.log("Property graph summary failed:", error.message);
        }    
    } catch (error) {
        console.error("Error in main execution:", error);
    }
}

// Run the main function
main().catch(console.error);
```

### Go
<a name="neptune-public-endpoints-go"></a>

```
package main
import (
    "context"
    "fmt"
    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/config"
    "github.com/aws/aws-sdk-go-v2/service/neptunedata"
    "os"
    "encoding/json"
    "net/http"
)

func main() {    
    // Configuration - Replace with your actual Neptune cluster details
    clusterEndpoint := "my-cluster-name.cluster-abcdefgh1234.my-region.neptune.amazonaws.com"
    port := 8182
    region := "my-region"
    
    // Configure Neptune client
    // Configure HTTP client with no timeout
    //    (relying on Neptune's query timeout)
    endpoint := fmt.Sprintf("https://%s:%d", clusterEndpoint, port)
    // Load AWS SDK configuration
    sdkConfig, _ := config.LoadDefaultConfig(
        context.TODO(),
        config.WithRegion(region),
        config.WithHTTPClient(&http.Client{Timeout: 0}),
    )
    
    // Create Neptune client with custom endpoint
    client := neptunedata.NewFromConfig(sdkConfig, func(o *neptunedata.Options) {
        o.BaseEndpoint = aws.String(endpoint)
        o.Retryer = aws.NopRetryer{} // Do not retry calls if they fail
    })

    gremlinQuery := "g.addV('person').property('name','charlie').property(id,'charlie-1')"
    serializer := "application/vnd.gremlin-v1.0+json;types=false"
    
    gremlinInput := &neptunedata.ExecuteGremlinQueryInput{
        GremlinQuery: &gremlinQuery,
        Serializer:   &serializer,
    }
    gremlinResult, err := client.ExecuteGremlinQuery(context.TODO(), gremlinInput)
    if err != nil {
        fmt.Printf("Gremlin query failed: %v\n", err)
    } else {
        var resultMap map[string]interface{}
        err = gremlinResult.Result.UnmarshalSmithyDocument(&resultMap)
        if err != nil {
            fmt.Printf("Error unmarshaling Gremlin result: %v\n", err)
        } else {
            resultJSON, _ := json.MarshalIndent(resultMap, "", "  ")
            fmt.Printf("Gremlin Result: %s\n", string(resultJSON))
        }
    }
}
```

## パブリックエンドポイントの仕組み
<a name="neptune-public-endpoints-how-they-work"></a>

Neptune インスタンスへのパブリックアクセスが可能である場合:
+ その DNS エンドポイントは、DB クラスターの VPC 内からプライベート IP アドレスに解決されます。
+ クラスターの VPC の外部からパブリック IP アドレスに解決されます。
+ アクセスは、クラスターに割り当てられたセキュリティグループによって制御されます。
+ インターネット経由でアクセスできるのは、パブリックアクセスが可能なインスタンスのみです。

### リーダーエンドポイントの動作
<a name="neptune-public-endpoints-reader-behavior"></a>
+ すべてのリーダーインスタンスへのパブリックアクセスが可能である場合、リーダーエンドポイントは常にパブリックインターネット経由で解決されます。
+ 一部のリーダーインスタンスのみにパブリックアクセス可能である場合、リーダーエンドポイントは、読み取りクエリを処理するためにパブリックアクセスが可能なインスタンスを選択した場合のみ、パブリックに解決されます。

### クラスターエンドポイントの動作
<a name="neptune-public-endpoints-cluster-behavior"></a>
+ DB クラスターエンドポイントは、常にライターのインスタンスエンドポイントに解決されます。
+ ライターインスタンスでパブリックエンドポイントが有効になっている場合、クラスターエンドポイントにはパブリックアクセスが可能であり、それ以外の場合はアクセスできません。

### クラスターフェイルオーバー後の動作
<a name="neptune-public-endpoints-failover-behavior"></a>
+ Neptune クラスターには、さまざまなパブリックアクセス可能な設定のインスタンスを配置できます。
+ クラスターにパブリックライターと非パブリックリーダーが配置されている場合は、クラスターフェイルオーバーを投稿すると、新しいライター (以前のリーダー) は非パブリックになり、新しいリーダー (以前のライター) はパブリックになります。

## ネットワークの設定要件
<a name="neptune-public-endpoints-network-requirements"></a>

パブリックエンドポイントが正しく機能するには:

1. Neptune インスタンスは VPC 内のパブリックサブネットに存在する必要があります。

1. これらのサブネットに関連付けられているルートテーブルには、0.0.0.0/0 のインターネットゲートウェイへのルートが設定されている必要があります。

1. セキュリティグループは、アクセスを許可するパブリック IP アドレスまたは CIDR 範囲からのアクセスを許可する必要があります。

## パブリックアクセスの作成の制限
<a name="neptune-public-endpoints-restrict-access"></a>

IAM ポリシーを使用して、パブリックアクセスが設定された Neptune クラスターを作成または変更できるユーザーを制限できます。次のポリシーの例では、パブリックアクセスが設定されている Neptune インスタンスの作成を拒否します。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Deny",
      "Action": [
        "rds:CreateDBInstance",
        "rds:ModifyDBInstance",
        "rds:RestoreDBInstanceFromDBSnapshot",
        "rds:RestoreDBInstanceToPointInTime"
      ],
      "Resource": "*",
      "Condition": {
        "Bool": {
          "rds:PubliclyAccessible": true
        }
      }
    }
  ]
}
```

------

`rds:PublicAccessEnabled` IAM 条件キーの詳細: [Amazon RDS サービス認可リファレンス](https://docs.aws.amazon.com//service-authorization/latest/reference/list_amazonrds.html#amazonrds-rds_PubliclyAccessible)

## CloudFormation サポート
<a name="neptune-public-endpoints-cloudformation"></a>

を使用して CloudFormation 、 CloudFormation テンプレートで `PubliclyAccessible`パラメータを指定することで、パブリックエンドポイントを有効にした Neptune クラスターを起動できます。

## Neptune 機能との互換性
<a name="neptune-public-endpoints-compatibility"></a>

パブリックエンドポイントが有効になっているクラスターは、VPC 専用クラスターがサポートする以下にようなすべての Neptune 機能をサポートします。
+ Neptune ワークベンチ
+ 全文検索の統合
+ Neptune Streams
+ カスタムエンドポイント
+ Neptune サーバーレス
+ グラフエクスプローラー

## 料金
<a name="neptune-public-endpoints-pricing"></a>

パブリックエンドポイントは、標準の Neptune と比較して追加料金が発生することなく利用できます。ただし、ローカル環境からパブリック IP 経由で Neptune に接続すると、データ転送コストが増加する可能性があります。