Skip to content

Server: inconsistent result error after downsizing machine_type #1091

@ps-misc

Description

@ps-misc

Description

Please add a clear and concise description of what the bug is.

After increasing the resources of a Server due to initial load, we now want to decrease it again because it is no longer needed. After terraform plan outputs that it's going to change the machine_type (with less resources than the current one) and starting terraform apply. it keeps failing due to a provider error.

Steps to reproduce

# put your terraform example here
host_dict = {
  "example-server" = {
    name = "example-server"
    boot_volume = {
      size              = 50
      source_type       = "image"
	  source_id			= "6ea6076b-616e-4d7d-906c-c54411ba6585"
      performance_class = "storage_premium_perf6"
    }
    machine_type      = "b1a.60d" # <- previously b1a.120d
    availability_zone = "eu01-1"
    ip_address        = "x.x.x.x"
    network           = "network"
  }
}

resource "stackit_server" "servers" {
  for_each = var.host_dict

  project_id = stackit_resourcemanager_project.project.project_id
  name       = each.value.name
  boot_volume = {
    size                  = each.value.boot_volume.size
    source_type           = each.value.boot_volume.source_type
    source_id             = each.value.boot_volume.source_id
    performance_class     = each.value.boot_volume.performance_class
    delete_on_termination = true
  }
  machine_type      = each.value.machine_type
  availability_zone = each.value.availability_zone
  user_data         = local.user_data
  keypair_name       = data.stackit_key_pair.admin_keypair.name
  network_interfaces = [stackit_network_interface.interfaces[each.key].network_interface_id]
}
  1. Have a running Server on any machine_type
  2. Adjust the machine_type to one with less resources
  3. Run terraform plan and terraform apply

Please describe the current behavior of the STACKIT Terraform provider. Don't forget to add detailed information like error messages.

terraform plan properly shows what will be done:

# stackit_server.servers["example-server"] will be updated in-place
~ resource "stackit_server" "servers" {
      id                 = "redacted"
    ~ launched_at        = "2025-12-09T09:46:33Z" -> (known after apply)
    ~ machine_type       = "b1a.120d" -> "b1a.60d"
      name               = "example-server"
    ~ updated_at         = "2025-12-09T09:51:03Z" -> (known after apply)
      # (7 unchanged attributes hidden)
  }

After starting terraform apply however, the task will fail with this error:

│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to stackit_server.servers["example-server"], provider
│ "provider[\"registry.terraform.io/stackitcloud/stackit\"]" produced an
│ unexpected new value: .machine_type: was cty.StringVal("b1a.60d"), but now
│ cty.StringVal("b1a.120d").
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Expected behavior

Please describe the behavior which you would expect from the STACKIT Terraform provider in that case.

The server will be stopped/restarted with the new machine_type, similar to how upgrading/expanding the Servers resources works.

Environment

  • OS: alpine:3.18.4 via Docker Image gitlab-org/terraform-images/stable:latest
  • Terraform version (see terraform --version): v1.5.0
  • Version of the STACKIT Terraform provider: v0.73.0

Additional information

Feel free to add any additional information here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions