Create a MongoDB connection

Stay organized with collections Save and categorize content based on your preferences.

You're viewing Apigee X documentation.
View Apigee Edge documentation.

The MongoDB connector lets you perform insert, delete, update, and read operations on a MongoDB database.

Before you begin

Before creating a MongoDB Connection, perform the following tasks:

  • In your Google Cloud project:
    • Grant the following roles to the service account that you want to use to create the connection:
      • roles/secretmanager.viewer
      • roles/secretmanager.secretAccessor
    • Enable the following services:
      • (Apigee API)
      • (Secret Manager API)
      • (Connector Platform API)

    If these services or permissions have not been enabled for your project previously, you are prompted to enable them when creating the connection in the Create Connection page.

Create a connection

  1. In the Cloud console, go to the Apigee > Connectors page and then select or create a Google Cloud project.

    Go to the Connections page

  2. Click + CREATE NEW to open the Create Connection page.
  3. Configure the connection:
    1. In the Create Connection section, complete the following:
      • Connector: Select MongoDB from the drop down list of available Connectors.
      • Connector version: Select the Connector version from the drop down list of available versions.
      • In the Connection Name field, enter a name for the Connection instance.

        Connection names must meet the following criteria:

        • Connection names can use letters, numbers, or hyphens.
        • Letters must be lower-case.
        • Connection names must begin with a letter and end with a letter or number.
        • Connection names cannot exceed 63 characters.
      • Optionally, enter a Description for the connection instance.
      • Service Account: Select a service account that has the required roles.
      • Database: The name of the MongoDB database.
      • Server: The host name or IP address of the server hosting the MongoDB database.
      • Auth Database: The name of the MongoDB database for authentication.
      • DNS Server: Specify the DNS server when resolving MongoDB seed list.
      • Data Model: By default, the provider will not automatically discover the metadata for a child table as its own distinct table. To enable this functionality, set DataModel to Relational .
      • No Cursor Timeout: The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.
      • Port: The port for the MongoDB database.
      • Read Preference: Set this to a strategy for reading from a replica set. Accepted values are primary, primaryPreferred, secondary, secondaryPreferred, and nearest.
      • Replica Set: This property allows you to specify multiple servers in addition to the one configured in Server and Port . Specify both a server name and port; separate servers with a comma.
      • Slave OK: This property sets whether the provider is allowed to read from secondary (slave) servers.
      • Use Find API: Execute MongoDB queries using db.collection.find().
      • Optionally, click + ADD LABEL to add a label to the Connection in the form of a key/value pair.
      • Click NEXT.
    2. Location: Choose the location for the connection.
      • Select a location where Apigee is available from the Region drop-down list.

        Supported regions for connectors include:

        • asia-east1
        • asia-northeast1
        • asia-south1
        • asia-southeast1
        • australia-southeast1
        • europe-west1
        • europe-west2
        • europe-west3
        • europe-west4
        • europe-west6
        • northamerica-northeast1
        • southamerica-east1
        • us-central1
        • us-east1
        • us-east4
        • us-west1
        • us-west2
      • Click NEXT.
    3. Authentication: Authentication types supported by the MongoDB connection:
      • Username and password

      Enter the details based on the authentication you want to use.

        • Auth Scheme: The scheme used for authentication
      • Username and password
        • Username: Username for connector
        • Password: Secret Manager Secret containing the password associated with the connector.
        • Auth Scheme: The scheme used for authentication
    4. Click NEXT.
    5. Review: Review your connection and authentication details.
  4. Click Create.

Configuration for the MongoDB Atlas cluster

The authentication configuration for a MongoDB Atlas cluster differ slightly from the previously documented steps. To authenticate against an Atlas cluster, you must first get the Atlas connection string. To obtain the Atlas connection string, perform the following steps:

  1. In the Clusters view, click Connect for the cluster you want to connect to.
  2. Click Connect Your Application.
  3. Select either driver option to display a connection string.

To authenticate against an Atlas cluster, use the following configuration:

  • Auth Database: Set the value to admin, as all MongoDB Atlas users are associated with the admin database.
  • Use SSL: Set the value to true.
  • The authentication configuration for a MongoDB Atlas cluster differs slightly Server: Set the value to mongodb+srv://MongoDB INSTANCE SERVER NAME.
  • DNS Server: Set the value to the hostname of a DNS server that can resolve the necessary DNS entries for server instances.

Create a Connectors task

After you create a MongoDB connection, it becomes available in Apigee integrations. You can then use the connection to configure the Connectors tasks in your integrations. For more information, see Configure the Connectors task.