Skip to content

fix: prevent perpetual plan diff on serverless cluster computed attrributes#263

Open
bohnen wants to merge 1 commit into
tidbcloud:mainfrom
bohnen:fix/serverless-cluster-perpetual-diff
Open

fix: prevent perpetual plan diff on serverless cluster computed attrributes#263
bohnen wants to merge 1 commit into
tidbcloud:mainfrom
bohnen:fix/serverless-cluster-perpetual-diff

Conversation

@bohnen

@bohnen bohnen commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

After creating Starter cluster, terraform plan always produces in-place update. Actually it changes noting but terraform plan returns 2 and cause confusion.

Terraform will perform the following actions:

  # tidbcloud_serverless_cluster.starter will be updated in-place
  ~ resource "tidbcloud_serverless_cluster" "starter" {
      ~ annotations             = {
          - "tidb.cloud/available-features" = "DISABLE_PUBLIC_LB,DELEGATE_USER"
          - "tidb.cloud/has-set-password"   = "false"
        } -> (known after apply)
      ~ labels                  = {
          - "tidb.cloud/organization" = "<org id>"
          - "tidb.cloud/project"      = "<project id>"
        } -> (known after apply)
      ~ state                   = "ACTIVE" -> (known after apply)
      ~ update_time             = "2026-07-03T05:22:36Z" -> (known after apply)
      ~ version                 = "v8.5.3" -> (known after apply)
        # (11 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

What is changed and how it works?

Add UseStateForUnknown plan modifiers to the computed-only attributes version, update_time, state, labels, and annotations. Without them these attributes were planned as "(known after apply)" on every no-op plan, producing a spurious in-place update. Matches the existing treatment of other computed attributes (create_time, cluster_id, etc.).

Ref: https://developer.hashicorp.com/terraform/plugin/framework/resources/plan-modification#common-use-case-attribute-plan-modifiers

…butes

Add UseStateForUnknown plan modifiers to the computed-only attributes
version, update_time, state, labels, and annotations. Without them these
attributes were planned as "(known after apply)" on every no-op plan,
producing a spurious in-place update. Matches the existing treatment of
other computed attributes (create_time, cluster_id, etc.).

Ref: https://developer.hashicorp.com/terraform/plugin/framework/resources/plan-modification#common-use-case-attribute-plan-modifiers

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ti-chi-bot ti-chi-bot Bot added the size/S label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant