liveBook · Manning

MongoDB Atlas CLI

As explained in MongoDB 8.0 in Action, Third Edition

MongoDB Atlas CLI is a command-line tool for managing MongoDB Atlas resources and deployments.

MongoDB Atlas CLI is a terminal tool for setting up and managing Atlas resources. Its `atlas` commands handle organizations, projects, clusters, sample data, connections, and deployments, including local deployments for search development. section 2.1 section 13.0

A practical first-cluster workflow is:

  • Install the CLI with `brew install mongodb-atlas` on a system with Homebrew. Other installation methods are available for Windows and Linux. section 2.1.1
  • Run `atlas auth register` to create an Atlas account, then `atlas login` to authenticate. Registration redirects you to the Atlas interface to finish signing up. section 2.1.2
  • Create an organization with `atlas organizations create "My Organization"` and find its ID with `atlas organizations list`. Save it using `atlas config set org_id <organization ID>`. section 2.1.3
  • Create a project with `atlas project create "My Project"`, find its ID with `atlas project list`, and save it using `atlas config set project_id <project ID>`. Projects contain deployments; profile settings spare you from repeating IDs on commands. section 2.1.4
  • After creating a cluster, load exercise data with `atlas clusters sampleData load "<cluster name>"`. Retrieve its address with `atlas clusters connectionStrings describe "<cluster name>"`, then use that connection string with `mongosh` for direct database work. section 2.2 section 2.5

Profiles can store organization and project IDs, and optionally API keys. Environment variables can also supply IDs and override profile values; explicit `--orgId` and `--projectId` flags take precedence. Use `atlas --help` when you need to discover a command. section 2.1.3 section 2.1.4 section 2.5

A sharded cluster

For a MongoDB 8.0 sharding exercise, `atlas clusters create "My-Sharded-Cluster" --provider GCP --region CENTRAL_US --tier M30 --type SHARDED --shards 2 --mdbVersion 8.0` requests a two-shard deployment. Sharding requires M30 or higher and a payment method; Atlas automates the shard, config-server, and `mongos` setup. Check progress with `atlas clusters list`. Pause a nonproduction cluster with `atlas clusters pause "My-Sharded-Cluster"` to save costs, and resume it with `atlas clusters start "My-Sharded-Cluster"`. section 9.3.2

For local development, `atlas deployments setup --type local` guides deployment setup; `atlas deployments` also provides connection, logs, pause, start, and delete operations. The described local workflow requires Docker and supports Atlas Search and Vector Search development. Atlas CLI does not load sample data into local clusters: download the data and import it with `mongorestore` instead. section 13.1 section 13.6

The CLI also manages search-related setup and Atlas Stream Processing resources. A Vector Search index definition can be kept in a JSON file for CLI use; `atlas streams` manages stream processing instances and connections. Use `mongosh`, rather than the Atlas CLI, when the next task is querying or directly changing database data. section 12.2.3 section 15.6.2 section 2.5

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Walks through installation, authentication, saved settings, and deployment commands, with operational caveats rather than CLI internals.
Examples
Uses account and project setup, sample-data loading, a two-shard MongoDB 8.0 cluster, and local deployment commands.
What it assumes
Starts with CLI installation and account registration; requires Docker for the described local workflow and payment for sharded clusters.
What you can do after
Operate/configure it to prepare Atlas projects and clusters, retrieve connection strings, and manage local deployments.
How it connects
Connects Atlas organizations, projects, clusters, mongosh, sharding, Atlas Search, Vector Search, and Atlas Stream Processing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.