翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
Neptune パブリックエンドポイント
概要
Amazon Neptune クラスターは通常 VPC 内にデプロイされ、その VPC 内からのみアクセスできます。これには、VPC 内でアプリケーションと開発環境を設定するか、プロキシサービスを使用して VPC に接続する必要があります。これにより、セットアップ時間とコストが増加します。
パブリックエンドポイントは、インターネット経由で Neptune に直接接続できるようにすることで、このエクスペリエンスを簡素化します。これにより、専門的なネットワーク知識がなくても、グラフデータベースの使用を簡単に開始できます。
パブリックエンドポイントを使用するタイミング
以下のシナリオでは、パブリックエンドポイントの使用を検討してください。
-
複雑なネットワーク設定なしで開発環境またはテスト環境で Neptune をすばやくテストしたい
-
AWS ネットワークに関する専門知識がない
-
アプリケーションのセキュリティ体制にプライベート VPC が必要ではない
-
ローカル開発環境から Neptune に接続する必要があります
セキュリティに関する考慮事項
パブリックエンドポイントを使用する場合は、以下のセキュリティ上の考慮事項に留意してください。
-
パブリックエンドポイントが有効になっているクラスターには、IAM 認証が必要です。
-
データベースへのアクセスは、使用するセキュリティグループによって制御されます。
-
クラスターに接続できる IP アドレスを制限できます。
-
IAM ポリシーを使用して、パブリックアクセスを持つクラスターを作成または変更できるユーザーを制御できます。参照: パブリックアクセスの作成の制限
パブリックエンドポイントの有効化
デフォルトでは、新しい Neptune データベースはパブリックエンドポイントを無効にして作成されます。クラスターを作成または変更するときは、パブリックアクセスを明示的に有効にする必要があります。
パブリックエンドポイントは、Neptune エンジンリリースバージョン 1.4.6.x からサポートされています。この機能を使用するには、既存のクラスターを少なくともこのバージョンにアップグレードする必要があります。
パブリックエンドポイント設定は、Neptune クラスターではなく Neptune インスタンスで使用できます。したがって、Neptune クラスターは、パブリックエンドポイントを持つインスタンスとそうでないインスタンスで存在できます。ただし、このような設定はお勧めしません。詳細については、「パブリックエンドポイントの仕組み」を参照してください。
前提条件
Neptune クラスターでの IAM 認証設定
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
ネットワーク設定
-
VPC にパブリックルーティングを有効にするサブネットがあることを確認します (サブネットのルートテーブルにインターネットゲートウェイのエントリがある)。クラスターの作成時に
db-subnet-group-nameパラメータを指定しない場合、クラスターの作成にはデフォルトのサブネットグループが選択されます。 -
クラスターにアタッチされたセキュリティグループが、許可された IP 範囲と許可されたポートのインバウンドトラフィックを許可していることを確認します。たとえば、すべての IPs からの TCP トラフィックがポート 8182 で実行されている Neptune インスタンスに接続できるようにする場合、インバウンドルールには次のものが必要です。
-
タイプ: すべての TCP
-
[Protocol]: TCP
-
ポート範囲: 8182
-
CIDR ブロック: 0.0.0.0/0
-
注記
CIDR ブロック範囲を 0.0.0.0/0 に設定することはできますが、セキュリティ体制を強化するために、これをクライアントアプリケーションの特定の IP 範囲に減らすことをお勧めします。
パブリックエンドポイントを使用した新しいインスタンスの作成
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
パブリックアクセス用の既存のインスタンスの変更
パブリックアクセスを有効にするように既存の 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
注記
パブリックアクセスは、クラスターレベルではなくインスタンスレベルで有効になります。クラスターにパブリックエンドポイント経由で常にアクセスできるようにするには、クラスター内のすべてのインスタンスでパブリックアクセスが有効になっている必要があります。
パブリックエンドポイントの使用
データベースが到達可能かどうかを確認するには、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" } }
データベースをクエリする方法の例
AWS CLI
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
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
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
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)) } } }
パブリックエンドポイントの仕組み
Neptune インスタンスがパブリックにアクセスできる場合:
-
その DNS エンドポイントは、DB クラスターの VPC 内からプライベート IP アドレスに解決されます。
-
クラスターの VPC の外部からパブリック IP アドレスに解決されます。
-
アクセスは、クラスターに割り当てられたセキュリティグループによって制御されます。
-
インターネット経由でアクセスできるのは、パブリックにアクセス可能なインスタンスのみです。
リーダーエンドポイントの動作
-
すべてのリーダーインスタンスがパブリックにアクセスできる場合、リーダーエンドポイントは常にパブリックインターネット経由で解決されます。
-
一部のリーダーインスタンスのみがパブリックにアクセス可能である場合、読み取りエンドポイントは、読み取りクエリを処理するためにパブリックにアクセス可能なインスタンスを選択した場合のみ、パブリックに解決されます。
クラスターエンドポイントの動作
-
DB クラスターエンドポイントは常にライターのインスタンスエンドポイントに解決されます。
-
ライターインスタンスでパブリックエンドポイントが有効になっている場合、クラスターエンドポイントはパブリックにアクセスでき、それ以外の場合はアクセスできません。
クラスターフェイルオーバー後の動作
-
Neptune クラスターは、さまざまなパブリックアクセス可能な設定のインスタンスを持つことができます。
-
クラスターにパブリックライターと非パブリックリーダーがある場合、クラスターフェイルオーバーを投稿すると、新しいライター (以前のリーダー) は非パブリックになり、新しいリーダー (以前のライター) はパブリックになります。
ネットワークの設定要件
パブリックエンドポイントが正しく機能するには:
-
Neptune インスタンスは、VPC 内のパブリックサブネットに存在する必要があります。
-
これらのサブネットに関連付けられたルートテーブルには、0.0.0.0/0 のインターネットゲートウェイへのルートが必要です。
-
セキュリティグループは、アクセスを許可するパブリック IP アドレスまたは CIDR 範囲からのアクセスを許可する必要があります。
パブリックアクセスの作成の制限
IAM ポリシーを使用して、パブリックアクセスで Neptune クラスターを作成または変更できるユーザーを制限できます。次のポリシー例では、パブリックアクセスを持つ Neptune インスタンスの作成を拒否します。
rds:PublicAccessEnabled IAM 条件キーの詳細: Amazon RDS サービス認可リファレンス
AWS CloudFormation サポート
を使用して AWS CloudFormation 、 AWS CloudFormation テンプレートで PubliclyAccessibleパラメータを指定することで、パブリックエンドポイントを有効にした Neptune クラスターを起動できます。
Neptune 機能との互換性
パブリックエンドポイントが有効になっているクラスターは、VPC 専用クラスターがサポートする以下を含むすべての Neptune 機能をサポートします。
-
Neptune ワークベンチ
-
全文検索の統合
-
Neptune Streams
-
カスタムエンドポイント
-
Neptune サーバーレス
-
グラフエクスプローラー
料金
パブリックエンドポイントは、標準の Neptune 料金よりも追加料金なしで利用できます。ただし、ローカル環境からパブリック IP 経由で Neptune に接続すると、データ転送コストが増加する可能性があります。