Built.io joins Software AG! Read all about the news.

Built.io Blog

[Repost] How To Use MongoDB Atlas In API Integration Services


To say we’re huge fans of MongoDB is an understatement of the year. We recently rewrote our entire architecture to enable a pluggable environment with direct access and customization of the DB taking advantage of major updates in MongoDB 3. So you get the idea.

That said, we were beyond excited to partner with Aleksey Savateyev of MongoDB to share how to take advantage of Atlas and MongoDB features with API integration platform Built.io Flow. 

Check out the original post on MongoDB here. See the integration steps below. 

How To Use MongoDB Atlas And Built.io® Flow™

The following is a quick guide on how to spin up a new cluster in MongoDB Atlas and email its status with Built.io Flow. This same workflow can be used as the foundation for many other integrations, including Cisco Spark, PagerDuty, Slack, and others.

Getting Started With Built.io® Flow™

To get started with Built.io, you will need a Built.io Flow Enterprise account. If you don’t have an existing account, sign up for a free trial account here. At the end of this process, you should have constructed a flow that looks like the one below:

Develop a MongoDB-based application with Built.io

Starting from scratch, drag the following actions onto your blank canvas organized in a similar layout as shown above:

  1. Create Cluster
  2. Add Group Whitelist Entry
  3. Create Database User
  4. Send an Email

Connect the actions as displayed in the image above.

MongoDB Cluster Configuration In Built.io® Flow™

After connecting everything, edit the Create Cluster action. The following screen is an example of the information you’ll need to input in order to set up the Create Cluster action:

Create MongoDB Cluster

The first thing in the edit window is the Connect to MongoDB Atlas section. Choose Add New and the following screen should pop up. Input your MongoDB Atlas username and then input your API key:

Connecting to MongoDB Atlas

Once you’ve completed adding the connection, get the Group ID from your MongoDB Atlas installation and input it in the Group ID field. Input the Instance Size, the Provider Name, and the Region Name you’d prefer for your new cluster. Be sure to examine all of the fields and their descriptions to customize your new cluster appropriately.

The second step is to enter in the appropriate information for whitelisting an IP Address (or CIDR block) to enable access to your MongoDB cluster. In this case, you’ll need to do a few things:

  1. First, you’ll need to click on Show optional fields to display all of the options.
  2. Second, click inside the Group ID box to grab the mouse focus.
  3. Third, notice the Input section on the right-hand side of the edit window. Click on groupId to place the groupId from the newly formed cluster into the Group ID field here.
  4. Last, go ahead and enter the IP Address or CIDR Block you’d like to whitelist for access to your cluster.

Add group whitelist entry

The third step is to create a new user for your MongoDB database:

  1. As before, pull the Group ID information directly from the newly created cluster.
  2. Then go through and enter all the required information.
  3. Be careful: If you end up changing "Is Editable" to false then you will be unable to edit or delete the created user.
  4. Be sure to record the password as you will never be able to retrieve it from the MongoDB Atlas API.

Create a new user for your MongoDB database

The final step is to send out a confirmation email that everything has been done. This particular action is sent from Built.io’s servers, so it does not require any authentication on your part:

  1. Make sure to show the optional fields if you want to specify whether to send the email via HTML or plain text.
  2. Choose the email address and subject you’d like.
  3. In the Body section, you can click on username from the Create Database User response and name from the Create Cluster response to place both of those in the email.
  4. Press Done.

Send a confirmation email

If you have followed the steps correctly, your MongoDB Atlas workflow is now fully configured.

Testing Your Built.io® Flow™ Workflow

Now that you’re done with your MongoDB Atlas workflow, you can execute it any time you want to by pressing the Play button in the top right corner of the window.

Testing Built.io workflow

There are some other interesting things you can do with Built.io Flow Enterprise. In this particular workflow, you may want to consider looking at the triggers by pressing the Settings icon over the Play action on the canvas. The very first trigger you’ll see available is the Webhook trigger. If you select it and press Save, you’ll set your workflow up to be triggered via a URL. You can use this URL in your scripts or anywhere else that accepts a URL for a webhook.

Another interesting trigger to explore is the PagerDuty trigger. Using a MongoDB Atlas integration with PagerDuty, you can have your Flow execute automatically every time a PagerDuty alert goes out. This can allow you to automate updating a cluster every time you get a low disk space alert from PagerDuty, for example.

Photo credit: letavua via Visual hunt / CC BY-SA

Popular Posts

Subscribe to our blog