Docs Menu
Docs Home
/ /
MongoDB Command Line Interface
/ / /

mongocli atlas networking peering gcp create

On this page

  • Syntax
  • Options
  • Output
  • Example

The networking peering create gcp command creates a peering connection between the Atlas VPC and your Google Cloud Platform VPC for a given Atlas project.

The networking peering create gcp command checks if a VPC exists for your Atlas project. If one exists, this command creates the peering connection between that VPC and your VPC. If an Atlas VPC does not exist, this command creates one and creates a connection between it and your VPC.

mongocli atlas networking peering gcp create
[ --atlasCidrBlock <atlas-cidr-block> ]
--gcpProjectId <gcp-project-id>
--network <gcp-vpc-name>
[ --output|-o <output-format> ]
[ --profile|-P <profile-name> ]
[ --projectId <project-ID> ]

Note

Use -h or --help to view the command-line help for this command.

Option
Type
Description
Required?
--atlasCidrBlock
string

CIDR block that Atlas uses for your clusters. Required only if you do not already have an Atlas VPC.

Atlas uses the specified CIDR block for all other VPC peering connections created in the project. The Atlas CIDR block must be at least a /18 in one of the following private networks:

Lower Bound
Upper Bound
Prefix
10.0.0.0
10.255.255.255
10/8
172.16.0.0
172.31.255.255
172.16/12
192.168.0.0
192.168.255.255
192.168/16

Atlas locks this value if an M10+ cluster or a VPC peering connection already exists. To modify the CIDR block, ensure there are no M10+ clusters in the project and no other VPC peering connections in the project.

Alternatively, create a new project and create a VPC Peering Connection to set the desired Atlas VPC CIDR block for that project.

Important

Atlas limits the number of MongoDB nodes per VPC based on the CIDR block and the region selected for the project.

Example

A project with an Atlas VPC CIDR block of /18 is limited to approximately 80 three-node replica sets per GCP region.

Contact MongoDB Support for any questions on Atlas limits of MongoDB nodes per VPC.

no
--gcpProjectId
string
Unique identifer of the Google Cloud Platform project that contains your VPC.
yes
--network
string
Name of the peer VPC.
yes
--output, -o
string

Command output format. Valid values are:

  • json for output in JSON format

  • go-template for custom output using the Go template

  • go-template-file for custom output specified using Go template file

If omitted, the command returns output in the default format.

no
--profile, -P
string
Name of the profile where the public and private keys for the project are saved. If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI.
no
--projectId
string

Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable.

no

If the command succeeds, it returns the following output in the default format. If the command returns errors, see Troubleshooting for recommended solutions.

Network peering connection '<peering-connection-id>' created.

The default output is a subset of the fields returned by this command. For the complete list of JSON fields returned by the command, see the Public API reference for your MongoDB service:

The following command creates a peering connection between the Atlas VPC and your GCP VPC for a project using the default profile, which contains credentials and the project ID. The output is returned in the default format.

mongocli atlas networking peering create gcp --atlasCidrBlock 192.168.0.0/18 \
--gcpProjectId grandiose-branch-256701 --network mongocli-test \
--projectId 5f0e15e3d52a043fed8b1c92

The previous command prints the following to the terminal.

Network peering connection '5f621dc701240c5b7c3a888e' created.

The following command creates a peering connection between the Atlas VPC and your GCP VPC for a project using the default profile, which contains credentials and the project ID. The output is returned in JSON format.

mongocli atlas networking peering create gcp --atlasCidrBlock 192.168.0.0/18 \
--gcpProjectId grandiose-branch-256701 --network mongocli-test \
--projectId 5f0e15e3d52a043fed8b1c92 --output json

The previous command prints the following to the terminal in JSON format.

{
"containerId": "5f621dc701240c5b7c3a888d",
"id": "5f621dc701240c5b7c3a888e",
"status": "ADDING_PEER",
"gcpProjectId": "grandiose-branch-256701",
"networkName": "mongocli-test"
}

Back

Create One Network Peering Connection to an Azure VNet