-
Notifications
You must be signed in to change notification settings - Fork 690
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]() | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
|
||||||||||||||
## Step 1. Select the `tidbcloud_cluster` resource to migrate | ||||||||||||||
|
||||||||||||||
Use the command below to get all resources. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||
|
||||||||||||||
```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. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||
|
||||||||||||||
```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. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be helpful to clarify where the
Suggested change
|
||||||||||||||
|
||||||||||||||
## Step 3. Delete the configuration of your target resource | ||||||||||||||
|
||||||||||||||
Find the configuration of your target resource in tf file and delete the related code. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||
|
||||||||||||||
## 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: | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||
``` | ||||||||||||||
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Serverless | ||||||||||||||
resource "tidbcloud_serverless_cluster" "new_cluster" {} # Dedicated | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback
Comment on lines
+40
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the same resource name
Suggested change
|
||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
## Step 5. Import the target cluster | ||||||||||||||
|
||||||||||||||
Run the following command to import the resource, replacing ${id} with the previously recorded cluster ID: | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||
```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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To align with the previous suggestion, the resource names here should be updated to reflect the new resource names.
Suggested change
|
||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
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). | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
There was a problem hiding this comment.
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.