Create an Atlas Cluster Using a Configuration File
On this page
This tutorial demonstrates how to use Atlas CLI commands to create a new Atlas cluster from a configuration file. Specifically, it demonstrates how to:
Get the configuration settings of an existing Atlas cluster and save the settings to a configuration file using the atlas clusters describe command.
Create an Atlas cluster from the configuration file using the atlas clusters create command.
Prerequisites
Before you begin, you must have the following:
A profile that contains the IDs of the Atlas organization and project from where you wish to retrieve existing cluster settings and where you wish to create the new cluster.
Create an Atlas Cluster From a Configuration File
You can use the procedures in this section to easily create a new cluster by exporting settings from an existing cluster instead of manually creating a configuration file yourself.
Export Existing Cluster Configuration Settings to a File
Connect to your Atlas account for programmatic access if you haven't connected yet.
To learn more, see Connect from the Atlas CLI.
(Optional) Edit the Configuration File for the new Cluster
Open the JSON file in a text editor to view the configuration settings.
Example
The following example uses the vi
editor to view the
replica set settings for an M10
cluster named
mySandbox
in the myCluster.json
file.
vi myCluster.json
1 { 2 "backupEnabled": true, 3 "biConnector": { 4 "enabled": false, 5 "readPreference": "secondary" 6 }, 7 "clusterType": "REPLICASET", 8 "connectionStrings": { 9 "standard": "<connection-string>" 10 }, 11 "diskSizeGB": 10, 12 "encryptionAtRestProvider": "NONE", 13 "groupId": "<group-id>", 14 "id": "<64403dd1f2a6b45e71527d5a>", 15 "mongoDBMajorVersion": "6.0", 16 "mongoDBVersion": "6.0.5", 17 "name": "mySandbox", 18 "paused": false, 19 "pitEnabled": true, 20 "stateName": "IDLE", 21 "replicationSpecs": [ 22 { 23 "numShards": 1, 24 "id": "64403dbb0a052449df3d04ae", 25 "zoneName": "Zone 1", 26 "regionConfigs": [ 27 { 28 "analyticsAutoScaling": { 29 "diskGB": { 30 "enabled": true 31 }, 32 "compute": { 33 "enabled": true, 34 "scaleDownEnabled": true, 35 "minInstanceSize": "M10", 36 "maxInstanceSize": "M40" 37 } 38 }, 39 "analyticsSpecs": { 40 "diskIOPS": 3000, 41 "ebsVolumeType": "STANDARD", 42 "instanceSize": "M10", 43 "nodeCount": 0 44 }, 45 "electableSpecs": { 46 "diskIOPS": 3000, 47 "ebsVolumeType": "STANDARD", 48 "instanceSize": "M10", 49 "nodeCount": 3 50 }, 51 "readOnlySpecs": { 52 "diskIOPS": 3000, 53 "ebsVolumeType": "STANDARD", 54 "instanceSize": "M10", 55 "nodeCount": 0 56 }, 57 "autoScaling": { 58 "diskGB": { 59 "enabled": true 60 }, 61 "compute": { 62 "enabled": true, 63 "scaleDownEnabled": true, 64 "minInstanceSize": "M10", 65 "maxInstanceSize": "M40" 66 } 67 }, 68 "priority": 7, 69 "providerName": "AWS", 70 "regionName": "US_EAST_1" 71 } 72 ] 73 } 74 ], 75 "createDate": "2023-04-19T19:15:29Z", 76 "rootCertType": "ISRGROOTX1", 77 "versionReleaseSystem": "LTS", 78 "terminationProtectionEnabled": false 79 }
(Optional) Make changes to the settings in the configuration file as needed.
To learn more about the optional and required settings, see Cluster Configuration File.
Create a New Cluster Using the Configuration File
Connect to your Atlas account for programmatic access if you aren't already connected to your Atlas account.
To learn more, see Connect from the Atlas CLI.
Run the following command to check the status of the cluster.
atlas clusters watch <new-cluster-name>
Replace <new-cluster-name> in the preceding command with the name of the new cluster.
This command checks the cluster's status periodically until
it reaches an IDLE
state. Once the cluster reaches the
expected state, the command prints "Cluster available."