Skip to content

planetscale_database with default_branch leads to inconsistent result after apply #145

@kota65535

Description

@kota65535

Creating the following resource:

resource "planetscale_database" "main" {
  organization         = "foo"
  name                 = "bar"
  cluster_size         = "PS-10"
  region               = "ap-northeast"
  default_branch       = "baz"
}

When I run terraform apply, got the following error.

╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to planetscale_database.main, provider "provider[\"registry.terraform.io/planetscale/planetscale\"]" produced an unexpected new value: .default_branch: was
│ cty.StringVal("baz"), but now cty.StringVal("main").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

This bug is similar to #135, but more reasonable because the default branch must exist before setting it as a default branch.
It would be better to deprecate default_branch input, and add a new resource planetscale_database_default_branch to resolve this.

For example:

# First we create a database
resource "planetscale_database" "main" {
  organization         = "foo"
  name                 = "bar"
  cluster_size         = "PS-10"
  region               = "ap-northeast"
}

# Then create another branch
resource "planetscale_branch" "dev" {
  organization  = planetscale_database.main.organization
  database      = planetscale_database.main.name
  parent_branch = "main"
  name          = "dev"
}

# Finally, set the another branch as default
resource planetscale_database_default_branch "dev" {
  database = planetscale_database.main.name
  branch = planetscale_branch.dev.name
}

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