Renaming a group (or project) label triggers a replacement, it should update the label in-place instead

Changing an existing gitlab_group_label's name

resource "gitlab_group_label" "some_label" {
   group       = "0123456"
-   name        = "awful_name"
+   name        = "beautiful_name"
}

Would generate this plan:

  # gitlab_group_label.some_label must be replaced
-/+ resource "gitlab_group_label" "some_label" {
      ~ id          = "0123456:78901234" -> (known after apply)
      ~ label_id    = 42424242 -> (known after apply)
      ~ name        = "awful_name" -> "beautiful_name" # forces replacement
        # (X unchanged attributes hidden)
    }

Where I would expect:

  # gitlab_group_label.some_label will be updated in-place
  ~ resource "gitlab_group_label" "some_label" {
      ~ name        = "awful_name" -> "beautiful_name"
        id          = "0123456:78901234"
        # (X unchanged attributes hidden)
    }

Implementation Guide

See Patricks comment in #5447 (comment 1532781829).

The idea is to use the label id as a Terraform resource id instead of the label name. This needs a schema change and with that a state migration:

  1. Register a new schema version V1 for the resource.
  2. Implement a new state migration to move from schema V0 (the present one with the name id) to V1 (the new one with id as id).
  3. Test & Document

An example of a state migration can be found in this resource.

The same applies to the project label resource and they can be done at the same time.

Edited by Francis St-Amour