MongoDB Atlas Cloud

Move faster with an automated cloud MongoDB service built for agile teams who’d rather spend their time building apps than managing databases. Available on AWS, Azure, and GCP.

https://www.mongodb.com/cloud/atlas

We use Altas Cloud for the online 'Test' environment as it is free, very easy to setup, does not require us to setup our own hosted mongo server or container and has a high level of availability and resilience.

When setting up a cluster we can select the underlying hosting from AWS, Azure, GCP etc. 

Steps to create new database on Atlas

1. Register

Register for an account at https://www.mongodb.com/cloud/atlas

Sign in

  • Create a new Project
  • Give members of org access permissions

2. Create a cluster

Select Cloud provider and region

  • AWS ap-southeast-1. - Singapore. ( use this as its free tier
  • AWS ap-southeast-2. - Sydney


Accept all the other defaults for now.

Takes about 5-10 minutes.  - default name is Cluster0

3. Add a database user

Once the cluster is running select the Security Tab and add a database user.  This is the account that the web application will use to read/write the database.

Create a Read/Write user called vly-client.  Select a good long password. 

e.g vly-client:ZhF3BUDiwpy8C3xK

4. Whitelist the source IP address.

Note without this the default is no one can access the database.

Click Add IP Address and select one of

  • Add Current IP address – this will add your current machine, good for local testing 
  • Allow access from anywhere - not ideal but very easy to get going
  • a specific IP address or range.  - what we will do for production once we know the addresses.

for now allow access from anywhere

5. Get the Connection details

Back at the main Clusters page click the CONNECT button for the cluster0.

The popup offers 3 options 

  • Connect with shell
  • Connect your application
  • Connect with MongoDB Compass.

For now connect Your application: Select driver Node.js V3 or later and copy the connection string.

e.g mongodb+srv://vly-client:<password>@cluster0-kwmsu.mongodb.net/test?retryWrites=true

Change 'test' to the name of the database e.g. vly-test . vly-prod 

Now you can use the connection string in your environment,  docker configuration etc to point the application at the database.

see: Setting the Database connection