AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

ワークロード ID フェデレーションを使用した認証

1.8.1 以降、Atlas Workload Identity Federation で を使用して、mongosync Microsoft AzureとGoogle Cloud Platformで実行中されているMongoDBクラスターへの接続を認証できます。

このセクションの例では、ワークロードアイデンティティフェデレーションでmongosyncを使用します。

In the connection string, set authMechanism to MONGODB-OIDC and set authMechanismProperties as needed:

  • Microsoft Azureの場合は、authMechanismProperties を ENVIRONMENT:azure,TOKEN_RESOURCE:<audience> に設定します。Microsoft Azure Kubernetes Service(AKS)を使用する場合は、TOKEN_RESOURCE を省略します。

  • Google Cloud Platformの場合は、authMechanismProperties を ENVIRONMENT:gcp,TOKEN_RESOURCE:<audience> に設定します。

Replace <audience> with the application or service that the access token is intended for. For details, see Identity Provider Fields.

For details about connection string options, see Authentication Options.

次の mongosync の例では、 Microsoft Azure Instance Metadata Service(MDS)を使用してMongoDBクラスターに接続します。

./bin/mongosync \
--logPath /var/log/mongosync \
--cluster0 "mongodb://clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure,TOKEN_RESOURCE:https://www.example.com" \
--cluster1 "mongodb://clusterTwo01.fancyCorp.com:20020,clusterTwo02.fancyCorp.com:20020,clusterTwo03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure,TOKEN_RESOURCE:https://www.example.com"

Microsoft Azure Kubernetes Service を使用してMongoDBクラスターに接続するには、次の環境変数を定義します。

環境変数
説明

AZURE_TENANT_ID

Azure tenant identifier.

AZURE_APP_CLIENT_ID

Azureアプリケーションクライアント識別子です。

AZURE_CLIENT_ID

認証するマネージド ID のAzureクライアント識別子。

AZURE_FEDERATED_TOKEN_FILE

Azureフェデレーティッド トークンのファイルパス。

Azureと変数の詳細については、 Microsoft Azureのドキュメントを参照してください。

次の mongosync の例では、環境変数を定義し、 MongoDBクラスターに接続します。

AZURE_TENANT_ID=08206ab8-16a0-406d-85e4-2f15f5620fac \
AZURE_APP_CLIENT_ID=b6c835da-e536-425b-9405-64bc471e245b \
AZURE_CLIENT_ID=f176d4eb-7dcd-4f66-bccf-aaa316ee61fd \
AZURE_FEDERATED_TOKEN_FILE=/var/run/secrets/azure/tokens/azure-identity-token \
./bin/mongosync \
--logPath /var/log/mongosync \
--cluster0 "mongodb://clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure" \
--cluster1 "mongodb://clusterTwo01.fancyCorp.com:20020,clusterTwo02.fancyCorp.com:20020,clusterTwo03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure"

この例には TOKEN_RESOURCE は必要ありません。

次の mongosync の例では、 Google Cloud PlatformのMongoDBクラスターに接続しています。

./bin/mongosync \
--logPath /var/log/mongosync \
--cluster0 "mongodb://clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:gcp,TOKEN_RESOURCE:https://www.example.com" \
--cluster1 "mongodb://clusterTwo01.fancyCorp.com:20020,clusterTwo02.fancyCorp.com:20020,clusterTwo03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:gcp,TOKEN_RESOURCE:https://www.example.com"

Google Cloud Platform には環境変数は必要ありません。

このページを評価

項目一覧