[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[],[],null,["# Create connection profiles\n==========================\n\nThis page describes the preparation part of the\n[migration process](/firestore/mongodb-compatibility/docs/migrate-data)\nwhere you create Datastream connection profiles that will be\nused later from importing data from the MongoDB-compatible source database to\nthe Cloud Storage bucket.\n\nAt this stage, you do the following:\n\n1. Create a Cloud Storage connection profile for the Cloud Storage bucket that you've created earlier.\n2. Create a connection profile for the MongoDB-compatible source database.\n\nSign in to gcloud CLI\n---------------------\n\nThe migration procedure described in the subsequent sections uses the\ngcloud CLI to configure and actuate the migration steps. Begin by\nlogging into Google Cloud and selecting the project that will host the\nmigration pipeline. \n\n gcloud auth login\n gcloud config set project \"$PROJECT_ID\"\n\nCreate a connection profile for the source database\n---------------------------------------------------\n\n### MongoDB on Compute Engine\n\nRun the following command to create a Datastream connection\nprofile to the MongoDB database hosted on Compute Engine.\n\nOmit the `--mongodb-replica-set` flag from the following command when\nconnecting to a sharded cluster. \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_IP_ADDRESS\" \\\n --mongodb-replica-set=\"$REPLICA_SET\" \\\n --private-connection=\"$PRIVATE_CONNECTION_NAME\" \\\n --mongodb-standard-connection-format \\\n --type=mongodb \\\n --mongodb-direct-connection\n\n### MongoDB over SSH\n\nThis example assumes you have already [configured SSH connectivity](/firestore/mongodb-compatibility/docs/migrate-configure-env-vars#mongodb-over-ssh)\nto your private network, either directly to the machine hosting the MongoDB\ncompatible server, or through a [Bastion](/solutions/connecting-securely#bastion)\nhost.\n\nRun the following command to create a Datastream connection\nprofile to the MongoDB database hosted on Compute Engine.\n\nOmit the `--mongodb-replica-set` flag from the following command when\nconnecting to a sharded cluster.\n\nIf you want to connect with an SSH password, pass the\n`--forward-ssh-password` flag instead of the `--forward-ssh-private-key` flag. \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_IP_ADDRESS\" \\\n --mongodb-replica-set=\"$REPLICA_SET\" \\\n --forward-ssh-hostname=\"$BASTION_IP_ADDRESS\" \\\n --forward-ssh-port=\"$BASTION_SSH_PORT\" \\\n --forward-ssh-username=\"$BASTION_SSH_USERNAME\" \\\n --forward-ssh-private-key=\"$BASTION_SSH_PRIVATE_KEY\" \\\n --mongodb-standard-connection-format \\\n --type=mongodb \\\n --mongodb-direct-connection\n\n### Amazon DocumentDB\n\nThis example assumes you have obtained the parameters and certificates required\nfor [Amazon DocumentDB connectivity](/firestore/mongodb-compatibility/docs/migrate-configure-env-vars#amazon-documentdb).\n\nPrior to creating a connection profile, explicitly enable change streams in\nthe Amazon DocumentDB database. See the [Amazon DocumentDB Change Streams](https://docs.aws.amazon.com/documentdb/latest/developerguide/change_streams.html)\nguide for instructions on enabling this feature.\n\nRun the following command to create a Datastream connection\nprofile to your DocumentDB database: \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_HOST_ADDRESS\" \\\n --mongodb-replica-set=\"$REPLICA_SET\" \\\n --forward-ssh-hostname=\"$BASTION_IP_ADDRESS\" \\\n --forward-ssh-port=\"$BASTION_SSH_PORT\" \\\n --forward-ssh-username=\"$BASTION_SSH_USERNAME\" \\\n --forward-ssh-private-key=\"$BASTION_SSH_PRIVATE_KEY\" \\\n --mongodb-ca-certificate=\"$DOCUMENT_DB_CA_CERTIFICATE\" \\\n --mongodb-tls \\\n --mongodb-standard-connection-format \\\n --type=mongodb \\\n --mongodb-direct-connection\n\n### Azure Cosmos DB\n\nExplicitly enable change streams for MongoDB in Azure Cosmos DB's API to\nenable initiating Datastream streams.\n\nThis step requires\n[installing Azure CLI](/firestore/mongodb-compatibility/docs/migrate-configure-resources#install-source-specific-tools). \n\n az resource patch --ids \"/subscriptions/\u003cvar translate=\"no\"\u003esubscription_id\u003c/var\u003e/resourceGroups/\u003cvar translate=\"no\"\u003eresource_group_name\u003c/var\u003e/providers/Microsoft.DocumentDB/mongoClusters/\u003cvar translate=\"no\"\u003evCore_cluster_name\u003c/var\u003e\" \\\n --api-version 2024-10-01-preview \\\n --properties \"{\\\"previewFeatures\\\": [ \\\"ChangeStreams\\\"]}\"\n\nReplace \u003cvar translate=\"no\"\u003esubscription_id\u003c/var\u003e, \u003cvar translate=\"no\"\u003eresource_group_name\u003c/var\u003e, and\n\u003cvar translate=\"no\"\u003evCore_cluster_name\u003c/var\u003e with values corresponding to your\nAzure Cosmos DB deployment.\n\nRun the following command to create a Datastream connection\nprofile to the source Azure Cosmos DB.\n\nThis example assumes that the source is accessible through a public DNS or IP\naddress that can be expressed in the\n[MongoDB SRV connection format](https://www.mongodb.com/docs/manual/reference/connection-string/).\nThe instructions also assume the Azure Cosmos DB server\nuses a combination of a username and password for authentication. \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_HOST_ADDRESS\" \\\n --mongodb-srv-connection-format \\\n --type=mongodb \\\n --static-ip-connectivity \\\n --labels=skip_all_validations=true\n\n### MongoDB Atlas\n\nRun the following command to create a Datastream connection\nprofile to the source MongoDB Atlas database.\n\nThis example assumes that the source is accessible through a public DNS or IP\naddress that can be expressed in the\n[MongoDB SRV connection format](https://www.mongodb.com/docs/manual/reference/connection-string/).\nThe instructions also assume that MongoDB Atlas server\nuses a combination of a username and password for authentication. \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_HOST_ADDRESS\" \\\n --mongodb-srv-connection-format \\\n --type=mongodb \\\n --static-ip-connectivity\n\nFor more information about monitoring the connection profile creation, see\n[Troubleshooting](/firestore/mongodb-compatibility/docs/migrate-troubleshooting).\n\nCreate a Cloud Storage connection profile\n-----------------------------------------\n\nConfigure the Datastream connection profile for the\nCloud Storage destination, which is the bucket that you've created\nearlier. \n\n gcloud datastream connection-profiles create \"$DST_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$DST_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --type=google-cloud-storage \\\n --bucket=\"$GCS_BUCKET_NAME\" \\\n --root-path=\"/$GCS_BUCKET_ROOT_PATH\"\n\nFor more information about monitoring the connection profile creation, see\n[Troubleshooting](/firestore/mongodb-compatibility/docs/migrate-troubleshooting).\n\nWhat's next\n-----------\n\nProceed to\n[Import from the source database](/firestore/mongodb-compatibility/docs/migrate-import-from-source)."]]