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.
string接続文字列オプションの詳細については、「 認証オプション 」を参照してください。
Microsoft Azureインスタンス メタデータ サービスを使用したMongoDBクラスターへの接続
次の 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クラスターへの接続
Microsoft Azure Kubernetes Service を使用してMongoDBクラスターに接続するには、次の環境変数を定義します。
環境変数 | 説明 |
|---|---|
| Azure tenant identifier. |
| Azureアプリケーションクライアント識別子です。 |
| 認証するマネージド ID のAzureクライアント識別子。 |
| 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 は必要ありません。
Google Cloud PlatformでMongoDBクラスターに接続する
次の 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 には環境変数は必要ありません。