Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add terraform migrate cluster resource doc #20659

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TOC-tidb-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
- [Use Backup Resource](/tidb-cloud/terraform-use-backup-resource.md)
- [Use Restore Resource](/tidb-cloud/terraform-use-restore-resource.md)
- [Use Import Resource](/tidb-cloud/terraform-use-import-resource.md)
- [Migrate Cluster Resource](/tidb-cloud/terraform-migrate-cluster-resource.md)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title 'Migrate Cluster Resource' might be unclear to some users. It would be better to specify what is being migrated and to where.

Suggested change
- [Migrate Cluster Resource](/tidb-cloud/terraform-migrate-cluster-resource.md)
- [Migrate Cluster Resource using Terraform](/tidb-cloud/terraform-migrate-cluster-resource.md)

- [Vercel](/tidb-cloud/integrate-tidbcloud-with-vercel.md)
- [Zapier](/tidb-cloud/integrate-tidbcloud-with-zapier.md)
- Reference
Expand Down
62 changes: 62 additions & 0 deletions tidb-cloud/terraform-migrate-cluster-resource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: Migrate Cluster Resource to Serverless/Dedicated Cluster Resource
summary: Learn how to migrate cluster resource to serverless/dedicated cluster resource.
---

# Migrate Cluster Resource to Serverless/Dedicated Cluster Resource

You will learn how to migrate cluster resource to serverless/dedicated cluster resource in this document.

## Prerequisites
Copy link

@github-actions github-actions bot Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence is not clear. It is recommended to specify what 'x.x.x' refers to.


- [Update TiDB Cloud Terraform Provider at least x.x.x]()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It's good to specify a minimum version of the Terraform provider to ensure compatibility. Can you replace x.x.x with the actual minimum required version?

Suggested change
- [Update TiDB Cloud Terraform Provider at least x.x.x]()
- [Update TiDB Cloud Terraform Provider at least 1.1.0]()


## Step 1. Select the `tidbcloud_cluster` resource to migrate

Use the command below to get all resources.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence is not clear. It is recommended to specify what 'all resources' refers to.

Suggested change
Use the command below to get all resources.
Use the command below to list all the `tidbcloud_cluster` resources.


```shell
terraform state list | grep "tidbcloud_cluster"
```

Select the cluster resource to migrate and execute the command below to get the `id` for later use.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence is not clear. It is recommended to specify what 'id' refers to.

Suggested change
Select the cluster resource to migrate and execute the command below to get the `id` for later use.
Select the cluster resource to migrate and execute the command below to get its `id` for later use.


```shell
terraform state show tidbcloud_cluster.serverless_tier_cluster | grep ' id '
```

## Step 2. Delete the existed resource from state

Run the `terraform state rm ${your_target_cluster_resource}` to delete the resource from state.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence is not clear. It is recommended to specify what 'the resource' refers to.

Suggested change
Run the `terraform state rm ${your_target_cluster_resource}` to delete the resource from state.
Run the `terraform state rm ${your_target_cluster_resource}` command to delete the target cluster resource from the state.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It would be helpful to clarify where the ${your_target_cluster_resource} value comes from. Perhaps reference the output of the command in Step 1?

Suggested change
Run the `terraform state rm ${your_target_cluster_resource}` to delete the resource from state.
Run the `terraform state rm tidbcloud_cluster.your_old_cluster` to delete the resource from state.


## Step 3. Delete the configuration of your target resource

Find the configuration of your target resource in tf file and delete the related code.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence is not clear. It is recommended to specify what 'the configuration of your target resource' refers to.

Suggested change
Find the configuration of your target resource in tf file and delete the related code.
Find the configuration of your target cluster resource in the tf file and delete the related code.


## Step 4. Create the configuration of your new serverless/dedicated cluster resource

Create the configuration of your new serverless/dedicated cluster resource like the `main.tf` file as below:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence is not clear. It is recommended to specify what 'the configuration of your new serverless/dedicated cluster resource' refers to.

Suggested change
Create the configuration of your new serverless/dedicated cluster resource like the `main.tf` file as below:
Create the configuration for your new serverless or dedicated cluster resource in the `main.tf` file as shown below:

```
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Serverless
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Dedicated
Copy link
Preview

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resource declaration for the Dedicated cluster appears to be incorrect; it reuses 'tidbcloud_serverless_cluster' instead of 'tidbcloud_dedicated_cluster'. Consider updating the resource type to 'tidbcloud_dedicated_cluster'.

Suggested change
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Dedicated
resource "tidbcloud_dedicated_cluster" "new_cluster" {} # Dedicated

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Comment on lines +40 to +41

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using the same resource name new_cluster for both serverless and dedicated clusters might be confusing. Consider using distinct names to avoid potential issues.

Suggested change
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Serverless
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Dedicated
resource "tidbcloud_serverless_cluster" "new_serverless_cluster" {} # Serverless
resource "tidbcloud_dedicated_cluster" "new_dedicated_cluster" {} # Dedicated

```

## Step 5. Import the target cluster

Run the following command to import the resource, replacing ${id} with the previously recorded cluster ID:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence is not clear. It is recommended to specify what 'the resource' refers to.

Suggested change
Run the following command to import the resource, replacing ${id} with the previously recorded cluster ID:
Run the following command to import the target cluster, replacing ${id} with the previously recorded cluster ID:

```shell
terraform import tidbcloud_serverless_cluster.new_cluster ${id} # Serverless
terraform import tidbcloud_dedicated_cluster.new_cluster ${id} # Dedicated
Comment on lines +48 to +49

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To align with the previous suggestion, the resource names here should be updated to reflect the new resource names.

Suggested change
terraform import tidbcloud_serverless_cluster.new_cluster ${id} # Serverless
terraform import tidbcloud_dedicated_cluster.new_cluster ${id} # Dedicated
terraform import tidbcloud_serverless_cluster.new_serverless_cluster ${id} # Serverless
terraform import tidbcloud_dedicated_cluster.new_dedicated_cluster ${id} # Dedicated

```

If the import succeeds, you'll see a confirmation message like this:
```
Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
```

## Next step

Get started by managing a cluster with the [serverless cluster resource](/tidb-cloud/terraform-use-serverless-cluster-resource.md) or [dedicated cluster resource](/tidb-cloud/terraform-use-dedicated-cluster-resource.md).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence is not clear. It is recommended to specify what 'Next step' refers to.

Suggested change
Get started by managing a cluster with the [serverless cluster resource](/tidb-cloud/terraform-use-serverless-cluster-resource.md) or [dedicated cluster resource](/tidb-cloud/terraform-use-dedicated-cluster-resource.md).
Next, you can start managing a cluster with the [serverless cluster resource](/tidb-cloud/terraform-use-serverless-cluster-resource.md) or [dedicated cluster resource](/tidb-cloud/terraform-use-dedicated-cluster-resource.md).

Loading