Stay organized with collections
Save and categorize content based on your preferences.
Create connection profiles
This page describes the preparation part of the
migration process
where you create Datastream connection profiles that will be
used later from importing data from the MongoDB-compatible source database to
the Cloud Storage bucket.
At this stage, you do the following:
Create a Cloud Storage connection profile for the
Cloud Storage bucket that you've created earlier.
Create a connection profile for the MongoDB-compatible source database.
Sign in to gcloud CLI
The migration procedure described in the subsequent sections uses the
gcloud CLI to configure and actuate the migration steps. Begin by
logging into Google Cloud and selecting the project that will host the
migration pipeline.
This example assumes you have already configured SSH connectivity
to your private network, either directly to the machine hosting the MongoDB
compatible server, or through a Bastion
host.
Run the following command to create a Datastream connection
profile to the MongoDB database hosted on Compute Engine.
Omit the --mongodb-replica-set flag from the following command when
connecting to a sharded cluster.
If you want to connect with an SSH password, pass the
--forward-ssh-password flag instead of the --forward-ssh-private-key flag.
Prior to creating a connection profile, explicitly enable change streams in
the Amazon DocumentDB database. See the Amazon DocumentDB Change Streams
guide for instructions on enabling this feature.
Run the following command to create a Datastream connection
profile to your DocumentDB database:
Replace subscription_id, resource_group_name, and
vCore_cluster_name with values corresponding to your
Azure Cosmos DB deployment.
Run the following command to create a Datastream connection
profile to the source Azure Cosmos DB.
This example assumes that the source is accessible through a public DNS or IP
address that can be expressed in the
MongoDB SRV connection format.
The instructions also assume the Azure Cosmos DB server
uses a combination of a username and password for authentication.
Run the following command to create a Datastream connection
profile to the source MongoDB Atlas database.
This example assumes that the source is accessible through a public DNS or IP
address that can be expressed in the
MongoDB SRV connection format.
The instructions also assume that MongoDB Atlas server
uses a combination of a username and password for authentication.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 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)."]]