[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for OpenSearch](../index.md) > [Tutorials](index.md) > Migrating and copying data > Migrating data from Elasticsearch

# Migrating data from Elasticsearch

# Migrating data from Elasticsearch to Yandex Managed Service for OpenSearch


{% note info %}

Yandex Managed Service for Elasticsearch is unavailable starting April 11, 2024.

{% endnote %}


There are three ways to migrate data from a source Elasticsearch cluster to a target Yandex Managed Service for OpenSearch cluster:

* [Yandex Data Transfer](../../data-transfer/index.md)

    This method is good for any Elasticsearch cluster.

* Snapshots

    This method is good for Elasticsearch cluster versions 7.11 or lower.

    Learn more about snapshots in the [OpenSearch guides](https://opensearch.org/docs/latest/opensearch/snapshots/index/).

* Remote [reindexing](https://opensearch.org/docs/latest/opensearch/reindex-data/).

    You can use this method to move your existing indexes, aliases, or data streams. This method is good for all version 7 Elasticsearch clusters.

## Required paid resources {#paid-resources}

* Managed Service for OpenSearch cluster: use of computing resources, storage and backup size (see [Managed Service for OpenSearch pricing](../pricing.md)).
* Public IP addresses if public access is enabled for cluster hosts (see [Yandex Virtual Private Cloud pricing](../../vpc/pricing.md)).
* Yandex Object Storage bucket: use of storage, data operations (see [Object Storage pricing](../../storage/pricing.md)).

## Migration using snapshots {#snapshot}

To migrate data from a source Elasticsearch cluster to a target Managed Service for OpenSearch cluster using snapshots:

1. [Create a snapshot in the source cluster](#create-snapshot).
1. [Restore the snapshot in the target cluster](#restore-snapshot).
1. [Complete your migration](#finish-migration-snapshot).

If you no longer need the resources you are using, [delete them](#clear-out-snapshot).

### Getting started {#before-you-begin-snapshot}

#### Set up your infrastructure {#deploy-infrastructure-snapshot}

{% list tabs group=instructions %}

- Manually {#manual}

    1. [Create an Object Storage bucket](../../storage/operations/buckets/create.md) with restricted access. This bucket will serve as a snapshot repository.
    1. [Create a service account](../../iam/operations/sa/create.md) and [assign](../../iam/operations/sa/assign-role-for-sa.md) it the `storage.editor` role. A service account is required to access the bucket from the source and target clusters.

    1. [Create a static access key](../../iam/operations/authentication/manage-access-keys.md#create-access-key) for the service account.

        {% note warning %}

        Save the **key ID** and **secret key**. You will need these at the next steps.

        {% endnote %}

    1. [Create a target Managed Service for OpenSearch cluster](../operations/cluster-create.md#create-cluster) in your desired configuration with public access to a group of hosts with the `DATA` role.

        {% note info %}
        
        Public access to cluster hosts is required if you plan to connect to the cluster via the internet. This connection option is simpler and is recommended for the purposes of this guide. You can connect to non-public hosts as well but only from Yandex Cloud virtual machines located in the same cloud network as the cluster.
        
        {% endnote %}

- Using Terraform {#tf}

    1. If you do not have Terraform yet, [install it](../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
    1. [Get the authentication credentials](../../tutorials/infrastructure-management/terraform-quickstart.md#get-credentials). You can add them to environment variables or specify them later in the provider configuration file.
    1. [Configure and initialize a provider](../../tutorials/infrastructure-management/terraform-quickstart.md#configure-provider). There is no need to create a provider configuration file manually, you can [download it](https://github.com/yandex-cloud-examples/yc-terraform-provider-settings/blob/main/provider.tf).
    1. Place the configuration file in a separate working directory and [specify the parameter values](../../tutorials/infrastructure-management/terraform-quickstart.md#configure-provider). If you did not add the authentication credentials to environment variables, specify them in the configuration file.

    1. Download the [es-mos-migration-snapshot.tf](https://github.com/yandex-cloud-examples/yc-elasticsearch-migration-to-managed-opensearch/blob/main/es-mos-migration-snapshot.tf) configuration file to the same working directory. This file describes:

        * [Network](../../vpc/concepts/network.md#network).
        * [Subnet](../../vpc/concepts/network.md#subnet).
        * [Security group](../../vpc/concepts/security-groups.md) and rules for connection to a Managed Service for OpenSearch cluster.
        * Service account for working with the Object Storage bucket.
        * Object Storage bucket.
        * Target Managed Service for OpenSearch cluster.

    1. In the `es-mos-migration-snapshot.tf` file, specify these variables:

        * `folder_id`: Cloud folder ID, same as in the provider settings.
        * `bucket_name`: Bucket name consistent with the [naming conventions](../../storage/concepts/bucket.md#naming).
        * `os_admin_password`: OpenSearch admin password.
        * `os_version`: OpenSearch version.

    1. Validate your Terraform configuration files using this command:

        ```bash
        terraform validate
        ```

        Terraform will display any configuration errors detected in your files.

    1. Create the required infrastructure:

       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.

       All the required resources will be created in the specified folder. You can check resource availability and their settings in the [management console](https://console.yandex.cloud).

{% endlist %}

#### Complete the configuration and check access to the resources {#complete-setup-snapshot}

1. [Set up the bucket ACL](../../storage/operations/buckets/edit-acl.md):

    1. In the **Select a user** drop-down list, specify the service account you created.
    1. Set the `READ and WRITE` permissions for this service account.
    1. Click **Add**.
    1. Click **Save**.

1. Configure the Elasticsearch source cluster:

    1. [Install the plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/7.11/repository-s3.html) `repository-s3` on all cluster hosts.
    
    1. For the `repository-s3` plugin to work, restart the Elasticsearch and Kibana services on all cluster hosts.
    
    1. Make sure the Elasticsearch source cluster can access the internet.

1. [Install an SSL certificate](../operations/connect/index.md#ssl-certificate).

1. Make sure you can [connect to the target Managed Service for OpenSearch cluster](../operations/connect/index.md) using the OpenSearch API and Dashboards.

### Create a snapshot on the source cluster {#create-snapshot}

1. Connect the bucket as a snapshot repository on the source cluster:

    1. Add the static access key information to the Elasticsearch [keystore](https://www.elastic.co/guide/en/elasticsearch/reference/current/elasticsearch-keystore.html) (keystore).
    
       {% note info %}
    
       Run the procedure on all hosts of the source cluster.
    
       {% endnote %}
    
       Add the following:
    
       * **Key ID**:
    
          ```bash
          $ES_PATH/bin/elasticsearch-keystore add s3.client.default.access_key
          ```
    
       * **Secret key**:
    
          ```bash
          $ES_PATH/bin/elasticsearch-keystore add s3.client.default.secret_key
          ```
    
       {% note info %}
    
       The path to Elasticsearch (`$ES_PATH`) depends on the selected installation method. To find a path to your Elasticsearch installation, see the [installation documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html) (for example, for [DEB](https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html#deb-layout), [RPM](https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html#rpm-layout)).
    
       {% endnote %}
    
    1. Upload the data from the keystore:
    
       ```bash
       curl --request POST "https://<IP_or_FQDN_of_source_cluster_DATA_host>:9200/_nodes/reload_secure_settings"
       ```
    
    1. Register the repository:
    
       ```bash
       curl --request PUT \
            "https://<IP_or_FQDN_of_source_cluster_DATA_host>:9200/_snapshot/<repository_name>" \
            --header 'Content-Type: application/json' \
            --data '{
              "type": "s3",
              "settings": {
                "bucket": "<bucket_name>",
                "endpoint": "storage.yandexcloud.net"
              }
            }'
       ```

    To learn more about connecting the repository, see the [relevant article on the Elastic plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/7.11/repository-s3.html).

    {% note alert %}
    
    If a bucket is registered in an Elasticsearch cluster as a snapshot repository, do not edit the bucket contents manually as this will disrupt the Elasticsearch snapshot mechanism.
    
    {% endnote %}

1. Run snapshot creation in the repository you created at the previous step. You can create a snapshot of the entire cluster or some of the data. For more information, see [this Elasticsearch guide on snapshots](https://www.elastic.co/guide/en/elasticsearch/reference/current/snapshots-take-snapshot.html).

    Example of creating a snapshot named `snapshot_1` for the entire cluster:

    ```bash
    curl --request PUT \
         "https://<IP_or_FQDN_of_the_DATA_host_in_the_source_cluster>:9200/_snapshot/<repository_name>/snapshot_1?wait_for_completion=false&pretty"
    ```

    Creating a snapshot may take a while. Track the operation progress [using Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/snapshots-take-snapshot.html#monitor-snapshot) tools, such as:

    ```bash
    curl --request GET \
         "https://<IP_or_FQDN_of_the_DATA_host_in_the_source_cluster>:9200/_snapshot/<repository_name>/snapshot_1/_status?pretty"
    ```

### Restore a snapshot on the target cluster {#restore-snapshot}

1. [Configure access to the bucket with snapshots](../operations/s3-access.md#configure-acl) for the target cluster. Use the service account you [created earlier](#before-you-begin).

1. [Attach an Object Storage](../operations/s3-access.md#register-snapshot-repository) bucket to the target cluster. This bucket will serve as a read-only snapshot storage:

    ```bash
    curl --request PUT \
         "https://admin:<admin_user_password>@<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_snapshot/<repository_name>" \
         --cacert ~/.opensearch/root.crt \
         --header 'Content-Type: application/json' \
         --data '{
           "type": "s3",
           "settings": {
             "bucket": "<bucket_name>",
             "readonly" : "true",
             "endpoint": "storage.yandexcloud.net"
           }
         }'
    ```

1. Select the index restoration method on the target cluster.

    With the default settings, an attempt to restore an index will fail in a cluster where a same-name index is already open. Even in Managed Service for OpenSearch clusters without user data, there are open system indexes (such as `.apm-custom-link` or `.kibana_*`), which may interfere with the restore operation. To avoid this, use one of the following methods:

    * Migrate only your custom indexes. The existing system indexes are not migrated. The import process only affects the user-created indexes on the source cluster.

    * Use the `rename_pattern` and `rename_replacement` parameters. Indexes will be renamed as they are restored. For more information, see [this OpenSearch guide](https://opensearch.org/docs/latest/opensearch/snapshots/snapshot-restore#conflicts-and-compatibility).

    Example of restoring the entire snapshot:

    ```bash
    curl --request POST \
         "https://admin:<admin_password>@<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_snapshot/<repository_name>/snapshot_1/_restore" \
         --cacert ~/.opensearch/root.crt
    ```

1. Start restoring data from the snapshot on the target cluster.

    Example of restoring a snapshot with indication of the custom indexes to restore on the target cluster:

    ```bash
    curl --request POST \
         "https://admin:<admin_user_password>@<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_snapshot/<repository_name>/snapshot_1/_restore?wait_for_completion=false&pretty" \
         --cacert ~/.opensearch/root.crt \
         --header 'Content-Type: application/json' \
         --data '{
           "indices": "<list_of_indexes>"
         }'
    ```

    Where `indices` is a list of comma-separated indexes to restore, e.g., `my_index*, my_index_2.*`.

    Restoring a snapshot may take a while. To check the restoring status, run this command:

    ```bash
    curl --request GET \
         "https://admin:<admin_user_password>@<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_snapshot/<repository_name>/snapshot_1/_status?pretty" \
         --cacert ~/.opensearch/root.crt
    ```

### Complete your migration {#finish-migration-snapshot}

1. Make sure all indexes have been migrated to the target Managed Service for OpenSearch cluster and the number of documents in them is the same as in the source cluster:

    {% list tabs group=programming_language %}

    - Bash {#bash}

      Run this command:

      ```bash
      curl \
          --user <username_in_target_cluster>:<user_password_in_target_cluster> \
          --cacert ~/.opensearch/root.crt \
          --request GET 'https://<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_cat/indices?v'
      ```

      The list should contain the indexes migrated from Elasticsearch with the number of documents specified in the `docs.count` column.

    - OpenSearch Dashboards {#opensearch}
    
      1. [Connect](../operations/connect/clients.md#dashboards) to the target cluster using OpenSearch Dashboards.
      1. Select the `Global` tenant.
      1. Open the management panel by clicking ![os-dashboards-sandwich](../../_assets/console-icons/bars.svg).
      1. Under **OpenSearch Plugins**, select **Index Management**.
      1. Navigate to **Indexes**.

      The list should contain the indexes migrated from Elasticsearch with the number of documents specified in the **Total documents** column.

    {% endlist %}

1. If required, [disable the snapshot repository](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-snapshot-repo-api.html) on the source and target clusters' end.

### Delete the resources you created {#clear-out-snapshot}

Some resources are not free of charge. Delete the resources you no longer need to avoid paying for them:

{% list tabs group=instructions %}

- Manually {#manual}

    * [Delete the service account](../../iam/operations/sa/delete.md).
    * [Delete the snapshots](../../storage/operations/objects/delete.md) from the bucket and then, the [entire bucket](../../storage/operations/buckets/delete.md).
    * [Delete the Managed Service for OpenSearch cluster](../operations/cluster-delete.md).

- Using Terraform {#tf}

    1. Delete all objects from the bucket.

    1. In the terminal window, go to the directory containing the infrastructure plan.
    
        {% note warning %}
    
        Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.
    
        {% endnote %}
    
    1. Delete resources:
    
        1. Run this command:
    
            ```bash
            terraform destroy
            ```
    
        1. Confirm deleting the resources and wait for the operation to complete.
    
        All the resources described in the Terraform manifests will be deleted.

{% endlist %}

## Migration using reindexing {#reindex}


To migrate data from a source Elasticsearch cluster to a target Managed Service for OpenSearch cluster by reindexing:

1. [Configure the target cluster](#configure-target-reindex).
1. [Start reindexing](#start-reindex).
1. [Check the result](#check-result-reindex).

If you no longer need the resources you created, [delete them](#clear-out-reindex).


### Getting started {#before-you-begin-reindex}


1. Set up your infrastructure:

    {% list tabs group=instructions %}

    - Manually {#manual}

        [Create a target Managed Service for OpenSearch cluster](../operations/cluster-create.md#create-cluster) in your desired configuration with public access to a group of hosts with the `DATA` role.

        {% note info %}
        
        Public access to cluster hosts is required if you plan to connect to the cluster via the internet. This connection option is simpler and is recommended for the purposes of this guide. You can connect to non-public hosts as well but only from Yandex Cloud virtual machines located in the same cloud network as the cluster.
        
        {% endnote %}

    - Using Terraform {#tf}

        1. If you do not have Terraform yet, [install it](../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
        1. [Get the authentication credentials](../../tutorials/infrastructure-management/terraform-quickstart.md#get-credentials). You can add them to environment variables or specify them later in the provider configuration file.
        1. [Configure and initialize a provider](../../tutorials/infrastructure-management/terraform-quickstart.md#configure-provider). There is no need to create a provider configuration file manually, you can [download it](https://github.com/yandex-cloud-examples/yc-terraform-provider-settings/blob/main/provider.tf).
        1. Place the configuration file in a separate working directory and [specify the parameter values](../../tutorials/infrastructure-management/terraform-quickstart.md#configure-provider). If you did not add the authentication credentials to environment variables, specify them in the configuration file.

        1. Download the [es-mos-migration-reindex.tf](https://github.com/yandex-cloud-examples/yc-elasticsearch-migration-to-managed-opensearch/blob/main/es-mos-migration-reindex.tf) configuration file to the same working directory. This file describes:

            * [Network](../../vpc/concepts/network.md#network).
            * [Subnet](../../vpc/concepts/network.md#subnet).
            * [Security group](../../vpc/concepts/security-groups.md) and rules for connection to a Managed Service for OpenSearch cluster.
            * Target Managed Service for OpenSearch cluster.

        1. In the `es-mos-migration-reindex.tf` file, specify these variables:

            * `os_admin_password`: OpenSearch admin password.
            * `os_version`: OpenSearch version.

        1. Validate your Terraform configuration files using this command:

            ```bash
            terraform validate
            ```

            Terraform will display any configuration errors detected in your files.

        1. Create the required infrastructure:

           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.

           All the required resources will be created in the specified folder. You can check resource availability and their settings in the [management console](https://console.yandex.cloud).

    {% endlist %}

1. Install an SSL certificate:

    {% list tabs group=operating_system %}
    
    - Linux (Bash)/macOS (Zsh) {#linux-macos}
    
       ```bash
       mkdir -p ~/.opensearch && \
       wget "https://storage.yandexcloud.net/cloud-certs/CA.pem" \
            --output-document ~/.opensearch/root.crt && \
       chmod 0600 ~/.opensearch/root.crt
       ```
    
       The certificate will be saved to the `~/.opensearch/root.crt` file.
    
    - Windows (PowerShell) {#windows}
    
       ```powershell
       mkdir $HOME\.opensearch; curl.exe -o $HOME\.opensearch\root.crt https://storage.yandexcloud.net/cloud-certs/CA.pem
       ```
    
       The certificate will be saved to the `$HOME\.opensearch\root.crt` file.
    
       Your corporate security policies and antivirus software may block the certificate download. For more information, see [FAQ](../qa/index.md#get-ssl-error).
    
    {% endlist %}

1. Make sure you can [connect to the target Managed Service for OpenSearch cluster](../operations/connect/index.md) using the OpenSearch API and Dashboards.


1. Make sure the source Elasticsearch cluster can access the internet.


1. Create a [user](https://www.elastic.co/guide/en/kibana/current/xpack-security.html#_users_2) with the `monitoring_user` and `viewer` [roles](https://www.elastic.co/guide/en/kibana/current/xpack-security.html#_roles_2) in the target cluster.


### Configure the target cluster {#configure-target-reindex}


1. [Create a role](https://opensearch.org/docs/latest/security-plugin/access-control/users-roles/#create-roles) with the `create_index` and `write` privileges for all indexes (`*`).

1. [Create a user](../operations/cluster-users.md) and assign this role to them.

    {% note tip %}

    In Managed Service for OpenSearch clusters, you can run re-indexing as `admin` with the `superuser` role; however, a more secure strategy is to create dedicated users with limited privileges for each job. For more information, see [Managing OpenSearch users](../operations/cluster-users.md).

    {% endnote %}


### Start reindexing {#start-reindex}


1. [Retrieve the list of hosts](../operations/host-groups.md#list-hosts) in the target cluster.

1. To start reindexing, run a request to the host with the `DATA` role in the target cluster:

    ```bash
    curl --user <username_in_target_cluster>:<user_password_in_target_cluster> \
         --cacert ~/.opensearch/root.crt \
         --request POST \
         "https://<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_reindex?wait_for_completion=false&pretty" \
         --header 'Content-Type: application/json' \
         --data '{
           "source": {
             "remote": {
               "host": "https://<IP_address_or_FQDN_of_host_with_DATA_role_in_source_cluster>:9200",
               "username": "<username_in_source_cluster>",
               "password": "<user_password_in_source_cluster>"
             },
             "index": "<name_of_index_alias_or_data_stream_in_source_cluster>"
           },
           "dest": {
             "index": "<name_of_index_alias_or_data_stream_in_target_cluster>"
           }
         }'
    ```

    Result:

    ```text
    {
      "task" : "<reindexing_job_ID>"
    }
    ```

    To migrate several indexes, use a `for` loop:

    ```bash
    for index in <names_of_alias_indexes_or_data_streams_separated_by_spaces>; do
      curl --user <username_in_target_cluster>:<user_password_in_target_cluster> \
           --cacert ~/.opensearch/root.crt \
           --request POST \
           "https://<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_reindex?wait_for_completion=false&pretty" \
           --header 'Content-Type: application/json' \
           --data '{
             "source": {
               "remote": {
                 "host": "https://<IP_address_or_FQDN_of_host_with_DATA_role_in_source_cluster>:9200",
                 "username": "<username_in_source_cluster>",
                 "password": "<user_password_in_source_cluster>"
               },
               "index": "'$index'"
             },
             "dest": {
               "index": "'$index'"
             }
           }'
    done
    ```

    Result:

    ```text
    {
      "task" : "<ID_of_reindexing_job_1>"
    }
    {
      "task" : "<ID_of_reindexing_job_2>"
    }
    ...
    ```

    Learn more about reindexing parameters in [this OpenSearch guide](https://opensearch.org/docs/latest/opensearch/reindex-data/#source-index-options).

    Reindexing may take a while. To check the operation status, run this command:

    ```bash
    curl --user <username_in_target_cluster>:<user_password_in_target_cluster> \
         --cacert ~/.opensearch/root.crt \
         --request GET \
         "https://<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_tasks/<reindexing_job_ID>"
    ```

1. To cancel reindexing, run this command:

    ```bash
    curl --user <username_in_target_cluster>:<user_password_in_target_cluster> \
         --cacert ~/.opensearch/root.crt \
         --request POST \
         "https://<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_tasks/<reindexing_job_ID>/_cancel"
    ```


### Check the result {#check-result-reindex}


Make sure all indexes have been migrated to the target Managed Service for OpenSearch cluster and the number of documents in them is the same as in the source cluster:

{% list tabs group=programming_language %}

- Bash {#bash}

  Run this command:

  ```bash
  curl \
      --user <username_in_target_cluster>:<user_password_in_target_cluster> \
      --cacert ~/.opensearch/root.crt \
      --request GET 'https://<ID_of_OpenSearch_host_with_DATA_role>.mdb.yandexcloud.net:9200/_cat/indices?v'
  ```

  The list should contain the indexes migrated from Elasticsearch with the number of documents specified in the `docs.count` column.

- OpenSearch Dashboards {#opensearch}

  1. [Connect](../operations/connect/clients.md#dashboards) to the target cluster using OpenSearch Dashboards.
  1. Select the `Global` tenant.
  1. Open the management panel by clicking ![os-dashboards-sandwich](../../_assets/console-icons/bars.svg).
  1. Under **OpenSearch Plugins**, select **Index Management**.
  1. Navigate to **Indexes**.

  The list should contain the indexes migrated from Elasticsearch with the number of documents specified in the **Total documents** column.

{% endlist %}


### Delete the resources you created {#clear-out-reindex}



Some resources are not free of charge. Delete the resources you no longer need to avoid paying for them:

* [Delete the objects](../../storage/operations/objects/delete.md) from the bucket.
* Delete the resources depending on how you created them:

    {% list tabs group=instructions %}

    - Manually {#manual}

        [Delete the Managed Service for OpenSearch cluster](../operations/cluster-delete.md).

    - Using Terraform {#tf}

        1. In the terminal window, go to the directory containing the infrastructure plan.
        
            {% note warning %}
        
            Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.
        
            {% endnote %}
        
        1. Delete resources:
        
            1. Run this command:
        
                ```bash
                terraform destroy
                ```
        
            1. Confirm deleting the resources and wait for the operation to complete.
        
            All the resources described in the Terraform manifests will be deleted.

    {% endlist %}

* If you reserved public static IPs for cluster access, release and [delete them](../../vpc/operations/address-delete.md).