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

mongocli atlas networking peering aws create

On this page

  • Syntax
  • Options
  • Output
  • Example

The networking peering create aws command creates a peering connection between the Atlas VPC and your AWS VPC for a given Atlas project.

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

mongocli atlas networking peering aws create
--accountId <aws-account-id>
[ --atlasCidrBlock <atlas-cidr-block> ]
--region <atlas-vpc-region>
--routeTableCidrBlock <vpc-cidr-block-or-subnet>
--vpcId <aws-vpc-id>
[ --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?
--accountId
string
AWS Account ID of the owner of the peer VPC.
yes
--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 Network Peering connections created in the project. The Atlas CIDR block must be at least a /24 and at most a /21 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 Network 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 Network Peering Connection to set the desired Atlas VPC CIDR block for that project.

Important

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

Example

A project in an AWS region supporting 3 availability zones and a Atlas CIDR VPC block of /24 is limited to the equivalent of 27 three-node replica sets.

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

no
--region
string
AWS region in which the peer VPC resides. See the Atlas documentation for a list of supported regions.
yes
--routeTableCidrBlock
string
Peer AWS VPC CIDR block or subnet.
yes
--vpcId
string
Unique identifier of the peer AWS 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 AWS VPC for a project using the default profile, which contains credentials and the project ID. The output is returned in the default format.

atlas networking peering create aws --accountId <aws-account-id> \
--atlasCidrBlock 192.168.0.0/24 --region us-east-1 \
--routeTableCidrBlock 10.0.0.0/24 --vpcId vpc-078ac381aa90e1e63

The previous command prints the following to the terminal.

Network peering connection '5f60c5bd0948295c093565ba' created.

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

atlas networking peering create aws --accountId <aws-account-id> \
--atlasCidrBlock 192.168.0.0/24 --region us-east-1 \
--routeTableCidrBlock 10.0.0.0/24 --vpcId vpc-078ac381aa90e1e63 \
--output json

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

{
"awsAccountId": "<aws-account-id>",
"containerId": "5f4eb2178c9ff67e809a3619",
"id": "5f60c5bd0948295c093565ba",
"routeTableCidrBlock": "10.0.0.0/24",
"statusName": "INITIATING",
"vpcId": "vpc-078ac381aa90e1e63"
}

Back

List All Network Peering Connections