Skip to content

[BUG] serverless_cluster: Provider produced inconsistent result for auto_scaling, then Cannot set both spending limit and capacity on update #249

@MoneyForest

Description

@MoneyForest

Provider version

v0.4.10

Terraform version

v1.14.5

Bug

When creating a tidbcloud_serverless_cluster without setting auto_scaling, the provider returns auto_scaling = {min_rcu = 0, max_rcu = 0} in state, causing Provider produced inconsistent result after apply.

After terraform untaint, any subsequent update fails with Cannot set both spending limit and capacity for serverless cluster because the state now contains both auto_scaling and spending_limit.

Steps to reproduce

resource "tidbcloud_serverless_cluster" "main" {
  display_name = "example"
  project_id   = "xxx"
  region = {
    name = "regions/aws-ap-northeast-1"
  }
}

Step 1: terraform apply

Error: Provider produced inconsistent result after apply

When applying changes to tidbcloud_serverless_cluster.main, provider
"provider[\"registry.terraform.io/tidbcloud/tidbcloud\"]" produced an
unexpected new value: .auto_scaling: was null, but now
cty.ObjectVal(map[string]cty.Value{"max_rcu":cty.NumberIntVal(0),
"min_rcu":cty.NumberIntVal(0)}).

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

The cluster is created, but the resource is tainted in state.

Step 2: terraform untaint tidbcloud_serverless_cluster.main

Step 3: terraform apply

tidbcloud_serverless_cluster.main: Modifying...

Error: Update Error

  with tidbcloud_serverless_cluster.main,
  on tidb_cluster.tf line 4, in resource "tidbcloud_serverless_cluster" "main":
   4: resource "tidbcloud_serverless_cluster" "main" {

Cannot set both spending limit and capacity for serverless cluster

State after step 1

Both auto_scaling and spending_limit are set by the provider, not by user config:

auto_scaling = {
    max_rcu = 0
    min_rcu = 0
}
spending_limit = {
    monthly = 0
}

Workaround

lifecycle {
  ignore_changes = all
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions