Using MongoDB Atlas in Cloud Foundry¶
This document describes how to bind a MongoDB instance from an own MongoDB Atlas account to an app running in Cloud Foundry.
All MongoDB instances in Cloud Foundry have been deleted on 31st October 2020 as communicated.
Create MongoDB cluster MongoDB Atlas¶
- Open MongoDB Atlas.
- Sign In or Create Account.
- Create MongoDB Cluster (in example
For eu1 region, create it on AWS in region Frankfurt For eu2 region, create it on Azure in region westeurope
4.Create Database Access User (in example
Use MongoDB Atlas cluster in Cloud Foundry¶
- In MongoDB Atlas, navigate to your project and select Clusters.
CONNECTbutton of your cluster that you want to connect to. Select
Connect your application.
- Select your driver and version.
- Copy the connection string
<password>with your password, you have created above (in example
With this change, you will have a connection string like this:
cf cli, create an User-Provided-Service:
cf cups <my-mongodb.com-cluster> -p "uri"
If you are using any connector for connecting to MongoDB instance, it may be required to set an tag or label to let the connector find the MongoDB URI in environment variables.
For example, Spring Cloud Cloud Foundry Connector requires a tag
mongodb. For setting the tag, you can extend your
cups command by
7.When requested for uri, insert your connection string
8.Bind User-Provided-Service to your app:
cf bs <myapp> <my-mongodb.com-cluster>
9.Restage your app:
cf restage <myapp>
- Remember to change the service instance name to the User-Provided-Service in your
- MongoDB TLS/SSL is standard
- Latency time may be higher than before
Tip: Create DB in AWS Frankfurt to minimize the latency time
- Your application may need more outbound traffic
- Note that your database endpoint is now accesible over internet. Please consider the security recommendations below and implement all additional security measures recommended by your organization.
- Whitelist MongoDB Atlas cluster access for Cloud Foundry IP addresses only.
You can find the Cloud Foundry IP addresses here.
Except where otherwise noted, content on this site is licensed under the Development License Agreement.