gitlab_branch_protection casuing replacment of resources rather then update in place

We being asked by security team to create gitlab policy which restricts deletion of branch protection rule. When we do it with GitLab UI its not a destructive activity , we can simply change the rule . but with terraform if we need to change role its destroy and create which is something blocking us . can we something about this. why its not a update in place ?

  # module.oseng_wsus_repo.gitlab_branch_protection.master_branch_protection[0] must be replaced
-/+ resource "gitlab_branch_protection" "master_branch_protection" {
      ~ branch_protection_id         = 334459 -> (known after apply)
      ~ id                           = "80278:master" -> (known after apply)
      ~ push_access_level            = "maintainer" -> "no one" # forces replacement
        # (6 unchanged attributes hidden)
    }
  # module.rhel7_images_repo.gitlab_branch_protection.master_branch_protection[0] must be replaced
-/+ resource "gitlab_branch_protection" "master_branch_protection" {
      ~ branch_protection_id         = 334446 -> (known after apply)
      ~ id                           = "80281:master" -> (known after apply)
      ~ push_access_level            = "maintainer" -> "no one" # forces replacement
        # (6 unchanged attributes hidden)
    }

Implementation Guide

  • Follow the CONTRIBUTING.md guide for setting up your local development environment and clone the community fork of this project.
  • Amend the resource schema for gitlab_branch_protection to remove the RequiresReplace plan modifiers from merge_access_level, push_access_level and unprotect_access_level.
  • Ensure all three attributes are updated successfully when changed with an acceptance test.
  • Run make reviewable before raising a merge request with your changes.
Edited Feb 21, 2026 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading