Skip to content

V1.5 #1110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed

V1.5 #1110

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ensures that we always use the latest version of the script
if [ -f build-site.sh ]; then
rm build-site.sh
fi

curl https://raw.githubusercontent.com/mongodb/docs-worker-pool/netlify-poc/scripts/build-site.sh -o build-site.sh
sh build-site.sh
6 changes: 6 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[integrations]]
name = "snooty-cache-plugin"

[build]
publish = "snooty/public"
command = ". ./build.sh"
9 changes: 9 additions & 0 deletions snooty.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name = "atlas-cli"
title = "Atlas Command Line Interface"
eol = true

intersphinx = [ "https://www.mongodb.com/docs/ops-manager/current/objects.inv",
"https://www.mongodb.com/docs/manual/objects.inv",
Expand All @@ -10,6 +11,7 @@ intersphinx = [ "https://www.mongodb.com/docs/ops-manager/current/objects.inv",
toc_landing_pages = [
"/atlas-cli-changelog",
"/atlas-cli-env-variables",
"/atlas-cli-automate",
"/atlas-cli-profiles",
"/atlas-cli-quickstart",
"/atlas-cli-tutorials",
Expand Down Expand Up @@ -120,3 +122,10 @@ value = """\
new set of CLI commands for our new Data Lake functionality, we \
will reach out to you to prevent any interruption of service.\
"""

[[banners]]
targets = ["*"]
variant = "info"
value = """\
This version of the documentation is archived and no longer supported. View the `current documentation <https://www.mongodb.com/docs/atlas/cli/current/>`__ to learn how to `upgrade your version of the Atlas CLI <https://www.mongodb.com/docs/atlas/cli/current/install-atlas-cli>`__.\
"""
101 changes: 101 additions & 0 deletions source/atlas-cli-automate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
.. _atlas-cli-automate:

=========================================
Automate Processes with the {+atlas-cli+}
=========================================

.. default-domain:: mongodb

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

To automate a process with the {+atlas-cli+} in a script, use
the following resources and best practices as guidance.

To learn how to connect to the {+atlas-cli+} programmatically, see
the :guilabel:`Programmatic User` tabs on :ref:`connect-atlas-cli`.

Resources for Automation with the {+atlas-cli+}
-----------------------------------------------

.. list-table::
:header-rows: 1
:widths: 40 60

* - Resource
- Objective

* - :ref:`atlas-cli-env-vars`
- Set environment variables that you can define once and use
across all of your scripts.

* - :ref:`go-template-output`
- Use Go templates or |json| paths to customize the output from
the {+atlas-cli+}. You can include the anticipated custom output in your scripts.

Best Practices for Automation with the {+atlas-cli+}
----------------------------------------------------

Follow these best practices when you automate processes with the
{+atlas-cli+}:

Base Your Script on the Version of the {+atlas-cli+} that You Run
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When you create a script to automate processes, you should base the
script on the version of the {+atlas-cli+} that you currently run.
**Don't** build automatic upgrades for the {+atlas-cli+} into your
script because new {+atlas-cli+} releases could introduce breaking
changes, which could break your automated processes.

Instead, check release notes for deprecated features and
breaking changes before you manually upgrade your version of the
{+atlas-cli+}.

.. _atlas-cli-redirect-stderr:

Redirect ``stderr``
~~~~~~~~~~~~~~~~~~~

The {+atlas-cli+} prints error messages and command deprecation
warnings in the output for commands. These unanticipated error messages
and warnings can cause issues for your automated processes that
anticipate a specific output. To prevent issues, you can redirect
``stderr`` to an output file in your script.

For example, the following command redirects the ``stderr`` output from
a script called ``myScript.sh`` to a text file called ``error.txt``:

.. code-block::

myScript.sh 2> error.txt

In the previous example, all error messages and deprecation warnings
are stored in ``error.txt`` and don't display in the output, so
they don't disrupt your automated processes.

Command deprecation messages are similar to the following text:

.. code-block::

Command "describe" is deprecated, Please use atlas privateEndpoints aws interfaces describe <atlasPrivateEndpointId> [--privateEndpointId privateEndpointID] [--projectId projected]

Update Scripts Regularly
~~~~~~~~~~~~~~~~~~~~~~~~

You should regularly update your scripts to discontinue use of
deprecated commands because they will be removed in future releases.
You can learn which commands are deprecated from the
:ref:`atlas-cli-changelog`. If you
:ref:`set up a redirect file for stderr <atlas-cli-redirect-stderr>`,
you can also check that file for deprecation warnings.

.. toctree::
:titlesonly:

Environment Variables </atlas-cli-env-variables>
Customize Output </custom-output-cli>

2 changes: 2 additions & 0 deletions source/atlas-cli-changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _atlas-cli-changelog:

:noprevnext:

=======================
Expand Down
213 changes: 213 additions & 0 deletions source/atlas-cli-create-cluster-from-config-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
.. _atlas-cli-create-cluster-from-config-file:

======================================================
Create an |service| Cluster Using a Configuration File
======================================================

.. default-domain:: mongodb

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

This tutorial demonstrates how to use {+atlas-cli+} commands to create
a new |service| cluster from a configuration file. Specifically, it
demonstrates how to:

1. Get the configuration settings of an :ref:`existing Atlas cluster
<atlas-clusters-create>` and save the settings to a
configuration file using the :ref:`atlas-clusters-describe` command.
#. Create an |service| {+cluster+} from the configuration file using the
:ref:`atlas-clusters-create` command.

.. _atlas-cli-create-cluster-from-config-file-reqs:

Prerequisites
-------------

Before you begin, you must have the following:

- :ref:`An Atlas cluster <atlas-clusters-create>`
- :ref:`Atlas CLI <install-atlas-cli>`
- :ref:`A profile <atlas-cli-profiles>` that contains the IDs of the
|service| organization and project from where you wish to retrieve
existing cluster settings and where you wish to create the new
{+cluster+}.

.. _atlas-cli-create-cluster-from-config-file-procedure:

Create an |service| 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. procedure::
:style: normal

.. step:: Connect to your |service| account for programmatic access if you haven't connected yet.

To learn more, see :ref:`connect-atlas-cli`.

.. step:: Run the following command to export the details of an existing cluster to a |json| configuration file named ``myCluster``.

.. code-block:: shell
:copyable: true

atlas clusters describe <cluster-name> --output json > myCluster.json

Replace <cluster-name> in the preceding command with the name of
the existing {+cluster+} that you wish to clone.

(Optional) Edit the Configuration File for the new Cluster
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. procedure::
:style: normal

.. step:: 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.

.. io-code-block::
:copyable: false

.. input::
:language: shell

vi myCluster.json

.. output::
:language: json
:linenos:

{
"backupEnabled": true,
"biConnector": {
"enabled": false,
"readPreference": "secondary"
},
"clusterType": "REPLICASET",
"connectionStrings": {
"standard": "<connection-string>"
},
"diskSizeGB": 10,
"encryptionAtRestProvider": "NONE",
"groupId": "<group-id>",
"id": "<64403dd1f2a6b45e71527d5a>",
"mongoDBMajorVersion": "6.0",
"mongoDBVersion": "6.0.5",
"name": "mySandbox",
"paused": false,
"pitEnabled": true,
"stateName": "IDLE",
"replicationSpecs": [
{
"numShards": 1,
"id": "64403dbb0a052449df3d04ae",
"zoneName": "Zone 1",
"regionConfigs": [
{
"analyticsAutoScaling": {
"diskGB": {
"enabled": true
},
"compute": {
"enabled": true,
"scaleDownEnabled": true,
"minInstanceSize": "M10",
"maxInstanceSize": "M40"
}
},
"analyticsSpecs": {
"diskIOPS": 3000,
"ebsVolumeType": "STANDARD",
"instanceSize": "M10",
"nodeCount": 0
},
"electableSpecs": {
"diskIOPS": 3000,
"ebsVolumeType": "STANDARD",
"instanceSize": "M10",
"nodeCount": 3
},
"readOnlySpecs": {
"diskIOPS": 3000,
"ebsVolumeType": "STANDARD",
"instanceSize": "M10",
"nodeCount": 0
},
"autoScaling": {
"diskGB": {
"enabled": true
},
"compute": {
"enabled": true,
"scaleDownEnabled": true,
"minInstanceSize": "M10",
"maxInstanceSize": "M40"
}
},
"priority": 7,
"providerName": "AWS",
"regionName": "US_EAST_1"
}
]
}
],
"createDate": "2023-04-19T19:15:29Z",
"rootCertType": "ISRGROOTX1",
"versionReleaseSystem": "LTS",
"terminationProtectionEnabled": false
}

.. step:: (Optional) Make changes to the settings in the configuration file as needed.

To learn more about the optional and required settings, see
:ref:`atlas-cli-cluster-config-file`.

.. step:: Save and close the configuration file.

Create a New Cluster Using the Configuration File
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. procedure::
:style: normal

.. step:: Connect to your |service| account for programmatic access if you aren't already connected to your |service| account.

To learn more, see :ref:`connect-atlas-cli`.

.. step:: Run the following command to create an |service| cluster using the configuration file.

.. code-block::
:copyable: true

atlas clusters create <new-cluster-name> -f myCluster.json

Replace ``<new-cluster-name>`` in the preceding command with the
name of the new {+cluster+} you wish to create.

.. step:: Run the following command to check the status of the {+cluster+}.

.. code-block:: shell
:copyable: true

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."
Loading