[Yandex Cloud documentation](../../index.md) > [Yandex StoreDoc](../index.md) > [Step-by-step guides](index.md) > Clusters > Updating cluster settings

# Updating Yandex StoreDoc cluster settings 

After creating a cluster, you can:

* [Change the host class](#change-resource-preset).
* [Change the disk type and expand the storage capacity](#change-disk-size).
* [Configure](#change-mongod-config) Yandex StoreDoc servers as per the MongoDB documentation.
* [Configure advanced cluster settings](#change-additional-settings).
* [Move the cluster](#move-cluster) to another folder.
* [Update security groups](#change-sg-set).

To move a cluster to a different availability zone, follow [this guide](host-migration.md). Following this procedure, you will move the cluster hosts.

## Changing the host class {#change-resource-preset}

{% note info %}

Some Yandex StoreDoc settings [depend on the selected host class](../concepts/settings-list.md#settings-instance-dependent).

{% endnote %}

When changing the host class:

* A single-host cluster will be unavailable for a few minutes and all database connections will be dropped.
* A multi-host cluster will undergo a [primary replica switchover](../concepts/replication.md). The hosts will undergo a rolling update, with each host unavailable for a few minutes while it is stopped and updated.
* A cluster with local SSD storage may be unavailable for an extended period of time in case of data migration to another physical server.

We recommend changing the host class only when the cluster is idle.

{% list tabs group=instructions %}

- Management console {#console}

  1. Open the [folder dashboard](https://console.yandex.cloud).
  1. Navigate to **Yandex StoreDoc**.

  1. Select your cluster and click **Edit** in the top panel.

  1. Depending on the [sharding type](../concepts/sharding.md#shard-management) you select, go to the section of the cluster resources you need to update: **Resources**, **Mongod Resources**, **Mongoinfra Resources**, **Mongocfg Resources**, or **Mongos Resources**.

  
  1. Select:

     * One of the available [platforms](../../compute/concepts/vm-platforms.md).
     * Configuration type: **Memory-optimized**, **cpu-optimized**, **standard**, or **burstable**.
     * [Host class](../concepts/instance-types.md): Defines the technical specifications of the VMs where the DB hosts will be deployed. When you change the host class for the cluster, the characteristics of all existing hosts change, too.


  1. Click **Save changes**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To change the cluster’s [host class](../concepts/instance-types.md):

  1. See the description of the CLI command for updating a cluster:

      ```bash
      yc managed-mongodb cluster update --help
      ```

  1. Get the list of available host classes. The `ZONE IDS` column indicates the availability zones supporting each class:

     
     ```bash
     yc managed-mongodb resource-preset list

     +-----------+--------------------------------+-------+----------+
     |    ID     |            ZONE IDS            | CORES |  MEMORY  |
     +-----------+--------------------------------+-------+----------+
     | s1.micro  | ru-central1-a, ru-central1-b,  |     2 | 8.0 GB   |
     |           | ru-central1-d                  |       |          |
     | ...                                                           |
     +-----------+--------------------------------+-------+----------+
     ```



  1. Run the `cluster update` command, providing the required host class: When changing the class, consider the host’s role, which depends on the [sharding type](../concepts/sharding.md#shard-management). A single command supports arguments for multiple host roles.

      * For `MONGOD` hosts:

          ```bash
          yc managed-mongodb cluster update <cluster_name_or_ID> \
             --mongod-resource-preset <class_ID>
          ```

      * For `MONGOINFRA` hosts:

          ```bash
          yc managed-mongodb cluster update <cluster_name_or_ID> \
             --mongoinfra-resource-preset <class_ID>
          ```

      * For `MONGOS` hosts:

          ```bash
          yc managed-mongodb cluster update <cluster_name_or_ID> \
             --mongos-resource-preset <class_ID>
          ```

      * For `MONGOCFG` hosts:

          ```bash
          yc managed-mongodb cluster update <cluster_name_or_ID> \
             --mongocfg-resource-preset <class_ID>
          ```

      Yandex StoreDoc will start the host class update operation for your cluster.


- Terraform {#tf}

  1. Open the current Terraform configuration file with the infrastructure plan.
  
      To learn how to create this file, see [Creating a cluster](cluster-create.md).
  
  1. In the Yandex StoreDoc cluster description, update the value of the `resource_preset_id` argument for `resources_mongod`, `resources_mongoinfra`, `resources_mongos`, and `resources_mongocfg` resources. The resource type depends on the [sharding type](../concepts/sharding.md#shard-management).

      Here is an example:
  
      ```hcl
      resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
        ...
        resources_mongod {
            resource_preset_id = "<host_class>"
            ...
        }
      }
      ```

  1. Make sure the settings are correct.
  
      1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
      1. Run this command:
      
         ```bash
         terraform validate
         ```
      
         Terraform will show any errors found in your configuration files.
  
  1. Confirm updating the resources.
  
      1. Run this command to view the planned changes:
      
         ```bash
         terraform plan
         ```
      
         If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
      
      1. If everything looks correct, apply the changes:
         1. Run this command:
      
            ```bash
            terraform apply
            ```
      
         1. Confirm updating the resources.
         1. Wait for the operation to complete.
 
  For more information, see [this Terraform provider guide](../../terraform/resources/mdb_mongodb_cluster.md).

  {% note warning "Timeouts" %}
  
  The Terraform provider sets the following timeouts for Yandex StoreDoc cluster operations:
  
  * Creating a cluster, including by restoring one from a backup: 30 minutes.
  * Editing a cluster: 60 minutes.
  
  Operations exceeding the set timeout are interrupted.
  
  {% cut "How do I change these limits?" %}
  
  Add the `timeouts` block to the cluster description, for example:
  
  ```hcl
  resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
    ...
    timeouts {
      create = "1h30m" # An hour and a half
      update = "2h"    # Two hours
    }
  }
  ```
  
  {% endcut %}
  
  {% endnote %}


- REST API {#api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
      
      {% endnote %}

      ```bash
      curl \
          --request PATCH \
          --header "Authorization: Bearer $IAM_TOKEN" \
          --header "Content-Type: application/json" \
          --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \
          --data '{
                    "updateMask": "configSpec.mongodb.<Yandex_StoreDoc_host_type>.resources.resourcePresetId",
                    "configSpec": {
                      "mongodb": {
                        "<Yandex_StoreDoc_host_type>": {
                          "resources": {
                            "resourcePresetId": "<host_class>"
                          }
                        }
                      }
                    }
                  }'
      ```

      Where:

      * `updateMask`: Comma-separated string of settings to update.

          Here, we provide only one setting.

      * `configSpec.mongodb.<Yandex_StoreDoc_host_type>.resources.resourcePresetId`: New [host class](../concepts/instance-types.md).

        The Yandex StoreDoc host type depends on the [sharding type](../concepts/sharding.md). The possible values are `mongod`, `mongocfg`, `mongos`, and `mongoinfra`. For a non-sharded cluster, use `mongod`.

      You can get the cluster ID from the [list of clusters in your folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
  1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `update_mask` parameter as an array of `paths[]` strings.
      
      {% cut "Format for listing settings" %}
      
      ```yaml
      "update_mask": {
          "paths": [
              "<setting_1>",
              "<setting_2>",
              ...
              "<setting_N>"
          ]
      }
      ```
      
      {% endcut %}
      
      {% endnote %}

      ```bash
      grpcurl \
          -format json \
          -import-path ~/cloudapi/ \
          -import-path ~/cloudapi/third_party/googleapis/ \
          -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \
          -rpc-header "Authorization: Bearer $IAM_TOKEN" \
          -d '{
                "cluster_id": "<cluster_ID>",
                "update_mask": {
                  "paths": [
                    "config_spec.mongodb.<Yandex_StoreDoc_host_type>.resources.resource_preset_id"
                  ]
                },
                "config_spec": {
                  "mongodb": {
                    "<Yandex_StoreDoc_host_type>": {
                      "resources": {
                        "resource_preset_id": "<host_class>"
                      }
                    }
                  }
                }
              }' \
          mdb.api.cloud.yandex.net:443 \
          yandex.cloud.mdb.mongodb.v1.ClusterService.Update
      ```

      Where:

      * `update_mask`: List of settings you want to update as an array of strings (`paths[]`).

          Here, we provide only one setting.

      * `config_spec.mongodb.<Yandex_StoreDoc_host_type>.resources.resource_preset_id`: New host class.
      
        The Yandex StoreDoc host type depends on the [sharding type](../concepts/sharding.md). The possible values are `mongod`, `mongocfg`, `mongos`, and `mongoinfra`. For a non-sharded cluster, use `mongod`.

      You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

## Changing the disk type and expanding the storage size {#change-disk-size}

Make sure the cloud has enough quota to increase the storage size. Open the cloud's [Quotas](https://console.yandex.cloud/cloud?section=quotas) page and check the **HDD storage capacity** and **SSD storage capacity** lines under **Managed Databases** to make sure there is available quota for storage space.

{% list tabs group=instructions %}

- Management console {#console}

  To change the disk type and expand the storage size for a cluster:

  1. Open the [folder dashboard](https://console.yandex.cloud).
  1. Navigate to **Yandex StoreDoc**.
  1. Select your cluster and click **Edit** in the top panel.
  1. Depending on the [sharding type](../concepts/sharding.md#shard-management) you select, go to the section of the cluster resources you need to update: **Resources**, **Mongod Resources**, **Mongoinfra Resources**, **Mongocfg Resources**, or **Mongos Resources**.
  1. Under **Storage**:

      * Select the [disk type](../concepts/storage.md).
      * Specify the disk size.

  1. Click **Save changes**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To change the disk type and expand the storage size for a cluster:

  1. View the description of the CLI command for updating a cluster:

      ```bash
      yc managed-mongodb cluster update --help
      ```

  1. Specify the [disk type](../concepts/instance-types.md) and the required storage size in the `cluster update` command. The specified storage size must not be less than the `disk_size` cluster setting.

      When expanding storage, consider the host’s role, which depends on the [sharding type](../concepts/sharding.md#shard-management). A single command supports arguments for multiple host roles.

      * For `MONGOD` hosts:

          ```bash
          yc managed-mongodb cluster update <cluster_name_or_ID> \
             --mongod-disk-type <disk_type> \
             --mongod-disk-size <storage_size_in_GB>
          ```

      * For `MONGOINFRA` hosts:

          ```bash
          yc managed-mongodb cluster update <cluster_name_or_ID> \
             --mongoinfra-disk-type <disk_type> \
             --mongoinfra-disk-size <storage_size_in_GB>
          ```

      * For `MONGOS` hosts:

          ```bash
          yc managed-mongodb cluster update <cluster_name_or_ID> \
             --mongos-disk-type <disk_type> \
             --mongos-disk-size <storage_size_in_GB>
          ```

      * For `MONGOCFG` hosts:

          ```bash
          yc managed-mongodb cluster update <cluster_name_or_ID> \
             --mongocfg-disk-type <disk_type> \
             --mongocfg-disk-size <storage_size_in_GB>
          ```

      If all the conditions are met, Yandex StoreDoc will start storage reconfiguration.


- Terraform {#tf}

  To change the disk type and expand the storage size for a cluster:

  1. Open the current Terraform configuration file with the infrastructure plan.

      To learn how to create this file, see [Creating a cluster](cluster-create.md).

  1. In the Yandex StoreDoc cluster description, change the values of the `disk_type_id` and `disk_size` arguments for the `resources_mongod`, `resources_mongoinfra`, `resources_mongos`, and `resources_mongocfg` resources. The resource type depends on the [sharding type](../concepts/sharding.md#shard-management).

      Here is an example:

      ```hcl
      resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
        ...
        resources_mongod {
          disk_type_id = "<disk_type>"
          disk_size    = <storage_size_in_GB>
          ...
        }
      }
      ```

    1. Make sure the settings are correct.

        1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm updating the resources.

        1. Run this command to view the planned changes:
        
           ```bash
           terraform plan
           ```
        
           If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
        
        1. If everything looks correct, apply the changes:
           1. Run this command:
        
              ```bash
              terraform apply
              ```
        
           1. Confirm updating the resources.
           1. Wait for the operation to complete.

    For more information, see [this Terraform provider guide](../../terraform/resources/mdb_mongodb_cluster.md).

    {% note warning "Timeouts" %}
    
    The Terraform provider sets the following timeouts for Yandex StoreDoc cluster operations:
    
    * Creating a cluster, including by restoring one from a backup: 30 minutes.
    * Editing a cluster: 60 minutes.
    
    Operations exceeding the set timeout are interrupted.
    
    {% cut "How do I change these limits?" %}
    
    Add the `timeouts` block to the cluster description, for example:
    
    ```hcl
    resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
      ...
      timeouts {
        create = "1h30m" # An hour and a half
        update = "2h"    # Two hours
      }
    }
    ```
    
    {% endcut %}
    
    {% endnote %}


- REST API {#api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
      
      {% endnote %}

      ```bash
      curl \
          --request PATCH \
          --header "Authorization: Bearer $IAM_TOKEN" \
          --header "Content-Type: application/json" \
          --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \
          --data '{
                    "updateMask": "configSpec.mongodb.<Yandex_StoreDoc_host_type>.resources.diskTypeId,configSpec.mongodb.<Yandex_StoreDoc_host_type>.resources.diskSize",
                    "configSpec": {
                      "mongodb": { 
                        "<Yandex_StoreDoc_host_type>": {
                          "resources": {
                            "diskTypeId": "<disk_type>",
                            "diskSize": "<storage_size_in_bytes>"
                          }
                        }
                      }
                    }
                  }'
      ``` 

      Where:

      * `updateMask`: Comma-separated string of settings to update.
      
      * `configSpec.mongodb.<Yandex_StoreDoc_host_type>.resources`: Storage settings:

          * `diskTypeId`: [Disk type](../concepts/storage.md).
          * `diskSize`: New storage size in bytes.

        Yandex StoreDoc host type depends on the [sharding type](../concepts/sharding.md). The possible values are `mongod`, `mongocfg`, `mongos`, and `mongoinfra`. For a non-sharded cluster, use `mongod`.

      You can get the cluster ID from the [list of clusters in your folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
  1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `update_mask` parameter as an array of `paths[]` strings.
      
      {% cut "Format for listing settings" %}
      
      ```yaml
      "update_mask": {
          "paths": [
              "<setting_1>",
              "<setting_2>",
              ...
              "<setting_N>"
          ]
      }
      ```
      
      {% endcut %}
      
      {% endnote %}

      ```bash
      grpcurl \
          -format json \
          -import-path ~/cloudapi/ \
          -import-path ~/cloudapi/third_party/googleapis/ \
          -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \
          -rpc-header "Authorization: Bearer $IAM_TOKEN" \
          -d '{
                "cluster_id": "<cluster_ID>",
                "update_mask": {
                  "paths": [
                    "config_spec.mongodb.<Yandex_StoreDoc_host_type>.resources.disk_type_id",
                    "config_spec.mongodb.<Yandex_StoreDoc_host_type>.resources.disk_size"
                  ]
                },
                "config_spec": {
                  "mongodb": {
                    "<Yandex_StoreDoc_host_type>": {
                      "resources": {
                        "disk_type_id": "<disk_type>",
                        "disk_size": "<storage_size_in_bytes>"
                      }
                    }
                  }
                }
              }' \
          mdb.api.cloud.yandex.net:443 \
          yandex.cloud.mdb.mongodb.v1.ClusterService.Update
      ```

      Where:

      * `update_mask`: List of settings to update as an array of strings (`paths[]`).

      * `config_spec.mongodb.<Yandex_StoreDoc_host_type>.resources.disk_size`: Storage settings:

          * `disk_type_id`: [Disk type](../concepts/storage.md).
          * `disk_size`: New storage size in bytes.

        The Yandex StoreDoc host type depends on the [sharding type](../concepts/sharding.md). The possible values are `mongod`, `mongocfg`, `mongos`, and `mongoinfra`. For a non-sharded cluster, use `mongod`.

      You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

## Changing Yandex StoreDoc settings {#change-mongod-config}

You can change the DBMS settings for your cluster hosts.

{% note info %}

Some Yandex StoreDoc settings [depend on the selected host class](../concepts/settings-list.md#settings-instance-dependent).

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

  1. Open the [folder dashboard](https://console.yandex.cloud).
  1. Navigate to **Yandex StoreDoc**.
  1. Select your cluster and click **Edit** in the top panel.
  1. To change the [Yandex StoreDoc settings](../concepts/settings-list.md#dbms-cluster-settings), click **Settings** under **DBMS settings**.
  1. Click **Save changes**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To update the [Yandex StoreDoc cluster settings](../concepts/settings-list.md#dbms-cluster-settings), use the following command:

  ```bash
  yc managed-mongodb cluster update-config
  ```

  For example, run the command below to set `net.maxIncomingConnections` to `4096`:

  ```bash
  yc managed-mongodb cluster update-config <cluster_name> \
     --set net.max_incoming_connections=4096
  ```

  Yandex StoreDoc will launch the reconfiguration of the cluster’s DBMS settings. If an updated setting requires a DBMS restart, Yandex StoreDoc will perform a rolling restart on all cluster hosts.

- REST API {#api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
      
      {% endnote %}

      ```bash
      curl \
          --request PATCH \
          --header "Authorization: Bearer $IAM_TOKEN" \
          --header "Content-Type: application/json" \
          --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \
          --data '{
                    "updateMask": "configSpec.mongodb.<Yandex_StoreDoc_host_type>.config.<setting_1>,configSpec.mongodb.<Yandex_StoreDoc_host_type>.config.<setting_2>,...,configSpec.mongodb.<Yandex_StoreDoc_host_type>.config.<setting_N>",
                    "configSpec": {
                      "mongodb": {    
                        "<Yandex_StoreDoc_host_type>": {
                          "config": {
                            "<setting_1>": "<value_1>",
                            "<setting_2>": "<value_2>",
                            ...
                            "<setting_N>": "<value_N>"
                          }
                        }
                      }
                    }
                  }'
      ```

      Where:

      * `updateMask`: Comma-separated string of settings to update.

      * `configSpec.mongodb.<Yandex_StoreDoc_host_type>.config`: List of Yandex StoreDoc settings. Enter each setting on a new line, separated by commas. All supported settings are described in the [API reference](../api-ref/Cluster/update.md) and in [Yandex StoreDoc settings](../concepts/settings-list.md).

        The Yandex StoreDoc host type depends on the [sharding type](../concepts/sharding.md). The possible values are `mongod`, `mongocfg`, `mongos`, and `mongoinfra`. For a non-sharded cluster, use `mongod`.

      You can get the cluster ID from the [list of clusters in your folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
  1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `update_mask` parameter as an array of `paths[]` strings.
      
      {% cut "Format for listing settings" %}
      
      ```yaml
      "update_mask": {
          "paths": [
              "<setting_1>",
              "<setting_2>",
              ...
              "<setting_N>"
          ]
      }
      ```
      
      {% endcut %}
      
      {% endnote %}

      ```bash
      grpcurl \
          -format json \
          -import-path ~/cloudapi/ \
          -import-path ~/cloudapi/third_party/googleapis/ \
          -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \
          -rpc-header "Authorization: Bearer $IAM_TOKEN" \
          -d '{
                "cluster_id": "<cluster_ID>",
                "update_mask": {
                  "paths": [
                    "config_spec.mongodb.<Yandex_StoreDoc_host_type>.config.<setting_1>",
                    "config_spec.mongodb.<Yandex_StoreDoc_host_type>.config.<setting_2>",
                    ...
                    "config_spec.mongodb.<Yandex_StoreDoc_host_type>.config.<setting_N>"
                  ]
                },
                "config_spec": {
                  "mongodb": {    
                    "<Yandex_StoreDoc_host_type>": {
                      "config": {
                        "<setting_1>": "<value_1>",
                        "<setting_2>": "<value_2>",
                        ...
                        "<setting_N>": "<value_N>"
                      }
                    }
                  }
                }
              }' \
          mdb.api.cloud.yandex.net:443 \
          yandex.cloud.mdb.mongodb.v1.ClusterService.Update
      ```

      Where:

      * `update_mask`: List of settings to update as an array of strings (`paths[]`).

      * `config_spec.mongodb.<Yandex_StoreDoc_host_type>.config`: List of Yandex StoreDoc settings. Enter each setting on a new line, separated by commas. All supported settings are described in the [API reference](../api-ref/grpc/Cluster/update.md) and in [Yandex StoreDoc settings](../concepts/settings-list.md).

        The Yandex StoreDoc host type depends on the [sharding type](../concepts/sharding.md). The possible values are `mongod`, `mongocfg`, `mongos`, and `mongoinfra`. For a non-sharded cluster, use `mongod`.

      You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

## Configuring advanced cluster settings {#change-additional-settings}

{% list tabs group=instructions %}

- Management console {#console}

  1. Open the [folder dashboard](https://console.yandex.cloud).
  1. Navigate to **Yandex StoreDoc**.
  1. Select your cluster and click **Edit** in the top panel.
  1. Configure advanced cluster settings:

     - **Backup start time (UTC)**: Time interval during which the cluster backup starts. Time is specified in 24-hour UTC format. The default time is `22:00 - 23:00` UTC.
     
     - **Retention period for automatic backups, days**{#setting-backup-saving}
       
       Retention period for automatic backups. Backups are automatically deleted once their retention period expires. The default is 7 days. This feature is in [Preview](../../overview/concepts/launch-stages.md). For more information, see [Backups](../concepts/backup.md).
     
     
       Changing the retention period affects both new and existing automatic backups. For example, if the initial retention period was 7 days, and the remaining lifetime of a separate automatic backup is 1 day, increasing the retention period to 9 days will change the remaining lifetime of this backup to 3 days.
     
       For an existing cluster, automatic backups are stored for a specified number of days whereas manually created ones are stored indefinitely. After a cluster is deleted, all backups persist for 7 days.
     
     - **Maintenance**: [Maintenance](../concepts/maintenance.md) window settings:
     
         * To enable maintenance at any time, select **At any time** (default).
         * To specify the preferred maintenance start time, select **By schedule** and specify the day of the week and the UTC time interval. For example, you can choose a time when the cluster is least loaded.
         
         Both active and stopped clusters are subject to maintenance. Maintenance operations include DBMS updates, patches, etc.
     
     
     
     - **WebSQL access**: This option enables you to [run SQL queries](websql.md) against cluster databases from the Yandex Cloud management console using Yandex WebSQL.
     
     
     - **Statistics sampling**: Enable this option to use the built-in [performance diagnostics](performance-diagnostics.md) tool in the cluster. This feature is at the [Preview](../../overview/concepts/launch-stages.md) stage.
     
     - **Deletion protection**: Cluster protection from accidental deletion.
     
       Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.
     
  1. Click **Save changes**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To change advanced cluster settings:

    1. View the description of the CLI command for updating a cluster:

        ```bash
        yc managed-mongodb cluster update --help
        ```

    1. Run the following command, providing the list of settings you want to update:

        ```bash
        yc managed-mongodb cluster update <cluster_ID_or_name> \
          --backup-retain-period-days=<retention_period> \
          --backup-window-start <backup_start_time> \
          --maintenance-window type=<maintenance_type>,`
                               `day=<day_of_week>,`
                               `hour=<hour> \
          --performance-diagnostics=<enable_diagnostics> \
          --deletion-protection
        ```

    You can update the following settings:

    * `--backup-retain-period`: Retention period for automatic backups, in days.
      
      The `<retention_period>` value must be in the range from 7 to 35. The default value is 7. This feature is in [Preview](../../overview/concepts/launch-stages.md). For more information, see [Backups](../concepts/backup.md).


      Changing the retention period affects both new and existing automatic backups.

      For example, if the original retention period was 7 days, and the remaining lifetime of a specific automatic backup was 1 day, then increasing the retention period to 9 days would make that backup’s remaining lifetime 3 days.

    * `--backup-window-start`: The cluster backup start time, set in UTC format `HH:MM:SS`. If the time is not set, the backup will start at 22:00 UTC.

    * `--maintenance-window`: [Maintenance window](../concepts/maintenance.md) settings that apply to both running and stopped clusters. The `type` setting defines the maintenance type:

        * `anytime`: Any time (default).
        * `weekly`: On a schedule. For this value, also specify the following:
            * `day`: Day of week, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
            * `hour`: Sequence number of UTC hour interval, from `1` to `24`.
        
              > For example, `1` stands for the interval from `00:00` to `01:00`, and `5`, from `04:00` to `05:00`.

    * `--performance-diagnostics`: Specify this setting to use the [Performance diagnostics](performance-diagnostics.md) tool in your cluster. This feature is in [Preview](../../overview/concepts/launch-stages.md).

    * `--deletion-protection`: Cluster protection from accidental deletion, `true` or `false`.

      Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.

    You can get the cluster’s name and ID from the [list of clusters in your folder](cluster-list.md#list-clusters).


- Terraform {#tf}

    1. Open the current Terraform configuration file with the infrastructure plan.
      
       To learn how to create this file, see [Creating a cluster](cluster-create.md).

    1. To change the backup start time, locate your Yandex StoreDoc cluster description and add the `backup_window_start` section under `cluster_config`:
  
        ```hcl
        resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
          ...
          cluster_config {
            backup_window_start {
              hours   = <hour>
              minutes = <minute>
            }
            ...
          }
          ...
        }
        ```

        Where `hours` is the hour and `minutes` is the minute of the backup start time.

    1. To set up the [maintenance window](../concepts/maintenance.md) that will also apply to stopped clusters, add the `maintenance_window` section to the cluster description:
       
       ```hcl
       resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
         ...
         maintenance_window {
           type = "<maintenance_type>"
           day  = "<day_of_week>"
           hour = <hour>
         }
         ...
       }
       ```
       
       Where:
       
       * `type`: Maintenance type. The possible values include:
           * `ANYTIME`: Any time.
           * `WEEKLY`: On a schedule.
       * `day`: Day of week for the `WEEKLY` type, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
       * `hour`: Sequence number of UTC hour interval for the `WEEKLY` type, from `1` to `24`.
       
         > For example, `1` stands for the interval from `00:00` to `01:00`, and `5`, from `04:00` to `05:00`.

    1. To protect your cluster against accidental deletion, add the `deletion_protection` field set to `true` to your cluster description:

        ```hcl
        resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
          ...
          deletion_protection = <protect_cluster_from_deletion>
        }
        ```

        Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.

        To disable the protection, set the value to `false`.

    1. Make sure the settings are correct.

        1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm updating the resources.

       1. Run this command to view the planned changes:
       
          ```bash
          terraform plan
          ```
       
          If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
       
       1. If everything looks correct, apply the changes:
          1. Run this command:
       
             ```bash
             terraform apply
             ```
       
          1. Confirm updating the resources.
          1. Wait for the operation to complete.

  For more information, see [this Terraform provider guide](../../terraform/resources/mdb_mongodb_cluster.md).

  {% note warning "Timeouts" %}
  
  The Terraform provider sets the following timeouts for Yandex StoreDoc cluster operations:
  
  * Creating a cluster, including by restoring one from a backup: 30 minutes.
  * Editing a cluster: 60 minutes.
  
  Operations exceeding the set timeout are interrupted.
  
  {% cut "How do I change these limits?" %}
  
  Add the `timeouts` block to the cluster description, for example:
  
  ```hcl
  resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
    ...
    timeouts {
      create = "1h30m" # An hour and a half
      update = "2h"    # Two hours
    }
  }
  ```
  
  {% endcut %}
  
  {% endnote %}


- REST API {#api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Create a file named `body.json` and paste the following code into it:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
      
      {% endnote %}

      
      ```json
      {
        "updateMask": "configSpec.backupWindowStart,configSpec.backupRetainPeriodDays,configSpec.performanceDiagnostics,maintenanceWindow,deletionProtection",
        "configSpec": {
          "backupWindowStart":  {
            "hours": "<hours>",
            "minutes": "<minutes>",
            "seconds": "<seconds>",
            "nanos": "<nanoseconds>"
          },
          "backupRetainPeriodDays": "<backup_retention_in_days>",
          "performanceDiagnostics": {
            "profilingEnabled": <enable_profiler>
          }
        }
        "maintenanceWindow": {
          "weeklyMaintenanceWindow": {
            "day": "<day_of_week>",
            "hour": "<hour>"
          }
        },    
        "deletionProtection": <protect_cluster_from_deletion>
      }
      ```
    

      Where:

      * `updateMask`: Comma-separated string of settings to update.
      * `configSpec`: Cluster settings:

        * `backupWindowStart`: [Backup](../concepts/backup.md) window settings.

          Here, specify the backup start time:

          * `hours`: Between `0` and `23` hours.
          * `minutes`: Between `0` and `59` minutes.
          * `seconds`: Between `0` and `59` seconds.
          * `nanos`: Between `0` and `999999999` nanoseconds.

        * `backupRetainPeriodDays`: Backup retention time in days.

        * `performanceDiagnostics`: [Statistics collection](performance-diagnostics.md#activate-stats-collector) settings:
          * `profilingEnabled`: Enable [profiler](tools.md#explore-profiler), `true` or `false`.

      * `maintenanceWindow`: [Maintenance](../concepts/maintenance.md) window settings, applying to both running and stopped clusters. In `maintenanceWindow`, provide one of these two parameters:

        * `anytime`: Maintenance takes place at any time.
        * `weeklyMaintenanceWindow`: Maintenance takes place once a week at the specified time:

          * `day`: Day of the week, in `DDD` format.
          * `hour`: Hour of the day, in `HH` format. Allowed values range from `1` to `24` hours.

      * `deletionProtection`: Cluster deletion protection, `true` or `false`.

        Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.
        
    1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

        ```bash
        curl \
            --request PATCH \
            --header "Authorization: Bearer $IAM_TOKEN" \
            --header "Content-Type: application/json" \
            --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \
            --data "@body.json"
        ```

       You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
  1. Create a file named `body.json` and paste the following code into it:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `update_mask` parameter as an array of `paths[]` strings.
      
      {% cut "Format for listing settings" %}
      
      ```yaml
      "update_mask": {
          "paths": [
              "<setting_1>",
              "<setting_2>",
              ...
              "<setting_N>"
          ]
      }
      ```
      
      {% endcut %}
      
      {% endnote %}

      
      ```json
      {
        "cluster_id": "<cluster_ID>",
        "update_mask": {
          "paths": [
            "config_spec.backup_window_start",
            "config_spec.backup_retain_period_days",
            "config_spec.performance_diagnostics",
            "maintenance_window",
            "deletion_protection"
          ]
        },
        "config_spec": {
          "backup_window_start": {
            "hours": "<hours>",
            "minutes": "<minutes>",
            "seconds": "<seconds>",
            "nanos": "<nanoseconds>"
          },
          "backup_retain_period_days": "<backup_retention_in_days>",
          "performance_diagnostics": {
            "profiling_enabled": <enable_profiler>
          }
        },
        "maintenance_window": {
          "weekly_maintenance_window": {
            "day": "<day_of_week>",
            "hour": "<hour>"
          }
        },
        "deletion_protection": <protect_cluster_from_deletion>
      }
      ```


      Where:

      * `update_mask`: List of settings to update as an array of strings (`paths[]`).
      * `config_spec`: Cluster settings:

        * `backup_window_start`: [Backup](../concepts/backup.md) window settings.

          Here, specify the backup start time:

          * `hours`: Between `0` and `23` hours.
          * `minutes`: Between `0` and `59` minutes.
          * `seconds`: Between `0` and `59` seconds.
          * `nanos`: Between `0` and `999999999` nanoseconds.

        * `backup_retain_period_days`: Backup retention time in days.

        * `performance_diagnostics`: [Statistics collection](performance-diagnostics.md#activate-stats-collector) settings:

          * `profiling_enabled`: Enable [profiler](tools.md#explore-profiler), `true` or `false`.

      * `maintenance_window`: [Maintenance window](../concepts/maintenance.md) settings, applying to both running and stopped clusters. In `maintenance_window`, provide one of these two parameters:

        * `anytime`: Maintenance takes place at any time.
        * `weekly_maintenance_window`: Maintenance takes place once a week at the specified time:

          * `day`: Day of the week, in `DDD` format.
          * `hour`: Hour of the day, in `HH` format. Allowed values range from `1` to `24` hours.

      * `deletion_protection`: Cluster deletion protection, `true` or `false`.

        Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.

  1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

      ```bash
      grpcurl \
          -format json \
          -import-path ~/cloudapi/ \
          -import-path ~/cloudapi/third_party/googleapis/ \
          -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \
          -rpc-header "Authorization: Bearer $IAM_TOKEN" \
          -d @ \
          mdb.api.cloud.yandex.net:443 \
          yandex.cloud.mdb.mongodb.v1.ClusterService.Update \
          < body.json
      ```

  1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

## Moving a cluster {#move-cluster}

{% list tabs group=instructions %}

- Management console {#console}

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex StoreDoc**.
    1. Click ![image](../../_assets/console-icons/ellipsis.svg) next to the cluster you want to move.
    1. Select **Move**.
    1. Select the destination folder for your cluster.
    1. Click **Move**.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To move a cluster:

    1. See the description of the CLI command for moving a cluster:

        ```bash
        yc managed-mongodb cluster move --help
        ```

    1. Specify the destination folder in the cluster move command:

        ```bash
        yc managed-mongodb cluster move <cluster_name_or_ID> \
           --destination-folder-name=<destination_folder_name>
        ```

        You can get the cluster ID from the [list of clusters in your folder](cluster-list.md#list-clusters).


- Terraform {#tf}

    1. Open the current Terraform configuration file with the infrastructure plan.

        To learn how to create this file, see [Creating a cluster](cluster-create.md).

    1. In the Yandex StoreDoc cluster description, add or update the `folder_id` argument:

        ```hcl
        resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
          ...
          folder_id = "<destination_folder_ID>"
        }
        ```

    1. Make sure the settings are correct.

        1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm updating the resources.

        1. Run this command to view the planned changes:
        
           ```bash
           terraform plan
           ```
        
           If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
        
        1. If everything looks correct, apply the changes:
           1. Run this command:
        
              ```bash
              terraform apply
              ```
        
           1. Confirm updating the resources.
           1. Wait for the operation to complete.

    For more information, see [this Terraform provider guide](../../terraform/resources/mdb_mongodb_cluster.md).

    {% note warning "Timeouts" %}
    
    The Terraform provider sets the following timeouts for Yandex StoreDoc cluster operations:
    
    * Creating a cluster, including by restoring one from a backup: 30 minutes.
    * Editing a cluster: 60 minutes.
    
    Operations exceeding the set timeout are interrupted.
    
    {% cut "How do I change these limits?" %}
    
    Add the `timeouts` block to the cluster description, for example:
    
    ```hcl
    resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
      ...
      timeouts {
        create = "1h30m" # An hour and a half
        update = "2h"    # Two hours
      }
    }
    ```
    
    {% endcut %}
    
    {% endnote %}


- REST API {#api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Call the [Cluster.Move](../api-ref/Cluster/move.md) method, e.g., via the following [cURL](https://curl.se/) request:

      ```bash
      curl \
          --request POST \
          --header "Authorization: Bearer $IAM_TOKEN" \
          --header "Content-Type: application/json" \
          --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>:move' \
          --data '{
                    "destinationFolderId": "<folder_ID>"
                  }'
      ```

      Where `destinationFolderId` is the ID of the target folder for your cluster. You can get it from the [list of your cloud folders](../../resource-manager/operations/folder/get-id.md)

      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/Cluster/move.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
  1. Call the [ClusterService.Move](../api-ref/grpc/Cluster/move.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

      ```bash
      grpcurl \
          -format json \
          -import-path ~/cloudapi/ \
          -import-path ~/cloudapi/third_party/googleapis/ \
          -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \
          -rpc-header "Authorization: Bearer $IAM_TOKEN" \
          -d '{
                "cluster_id": "<cluster_ID>",
                "destination_folder_id": "<folder_ID>"
              }' \
          mdb.api.cloud.yandex.net:443 \
          yandex.cloud.mdb.mongodb.v1.ClusterService.Move
      ```

      Where `destination_folder_id` is the ID of the target folder for your cluster. You can get it from the [list of your cloud folders](../../resource-manager/operations/folder/get-id.md)

      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/grpc/Cluster/move.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}


## Updating security groups {#change-sg-set}

{% list tabs group=instructions %}

- Management console {#console}

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex StoreDoc**.
    1. Select your cluster and click **Edit** in the top panel.
    1. Under **Network settings**, select the security groups that control the cluster’s network traffic.
    1. Click **Save changes**.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To change the list of [security groups](../concepts/network.md#security-groups) for your cluster:

    1. View the description of the CLI command for updating a cluster:

        ```bash
        yc managed-mongodb cluster update --help
        ```

    1. Specify the security groups in the cluster update command:

        ```bash
        yc managed-mongodb cluster update <cluster_name_or_ID> \
          --security-group-ids <list_of_security_group_IDs>
        ```

- Terraform {#tf}

    1. Open the current Terraform configuration file with the infrastructure plan.
      
       To learn how to create this file, see [Creating a cluster](cluster-create.md).

    1. Update the `security_group_ids` value in the Yandex StoreDoc cluster description:
  
        ```hcl
        resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
          ...
          security_group_ids = [ <list_of_security_group_IDs> ]
          ...
        }
        ```

    1. Make sure the settings are correct.

        1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm updating the resources.

       1. Run this command to view the planned changes:
       
          ```bash
          terraform plan
          ```
       
          If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
       
       1. If everything looks correct, apply the changes:
          1. Run this command:
       
             ```bash
             terraform apply
             ```
       
          1. Confirm updating the resources.
          1. Wait for the operation to complete.

  For more information, see [this Terraform provider guide](../../terraform/resources/mdb_mongodb_cluster.md).

  {% note warning "Timeouts" %}
  
  The Terraform provider sets the following timeouts for Yandex StoreDoc cluster operations:
  
  * Creating a cluster, including by restoring one from a backup: 30 minutes.
  * Editing a cluster: 60 minutes.
  
  Operations exceeding the set timeout are interrupted.
  
  {% cut "How do I change these limits?" %}
  
  Add the `timeouts` block to the cluster description, for example:
  
  ```hcl
  resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
    ...
    timeouts {
      create = "1h30m" # An hour and a half
      update = "2h"    # Two hours
    }
  }
  ```
  
  {% endcut %}
  
  {% endnote %}


- REST API {#api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
      
      {% endnote %}

      ```bash
      curl \
          --request PATCH \
          --header "Authorization: Bearer $IAM_TOKEN" \
          --header "Content-Type: application/json" \
          --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \
          --data '{
                    "updateMask": "securityGroupIds",
                    "securityGroupIds": [
                      "<security_group_1_ID>",
                      "<security_group_2_ID>",
                      ...
                      "<security_group_N_ID>"
                    ]
                  }'
      ```

      Where:

      * `updateMask`: Comma-separated string of settings to update.

          Here, we provide only one setting.

      * `securityGroupIds`: List of [security group](../concepts/network.md#security-groups) IDs.

      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
  1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

      {% note warning %}
      
      The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `update_mask` parameter as an array of `paths[]` strings.
      
      {% cut "Format for listing settings" %}
      
      ```yaml
      "update_mask": {
          "paths": [
              "<setting_1>",
              "<setting_2>",
              ...
              "<setting_N>"
          ]
      }
      ```
      
      {% endcut %}
      
      {% endnote %}

      ```bash
      grpcurl \
          -format json \
          -import-path ~/cloudapi/ \
          -import-path ~/cloudapi/third_party/googleapis/ \
          -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \
          -rpc-header "Authorization: Bearer $IAM_TOKEN" \
          -d '{
                "cluster_id": "<cluster_ID>",
                "update_mask": {
                  "paths": [
                    "security_group_ids"
                  ]
                },
                "security_group_ids": [
                  "<security_group_1_ID>",
                  "<security_group_2_ID>",
                  ...
                  "<security_group_N_ID>"
                ]
              }' \
          mdb.api.cloud.yandex.net:443 \
          yandex.cloud.mdb.mongodb.v1.ClusterService.Update
      ```

      Where:

      * `update_mask`: List of settings you want to update as an array of strings (`paths[]`).

          Here, we provide only one setting.

      * `security_group_ids`: List of [security group](../concepts/network.md#security-groups) IDs.

      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

{% note warning %}

You may need to [configure security groups](connect/index.md#configuring-security-groups) to enable access to your cluster.

{% endnote %}