Skip to content

Creating a protected environment can lead to "Root resource was present, but now absent"

Bug Report

This was reported by a GitLab Ultimate ~SaaS customer - ZD ticket (internal)

The terraform job is trying to create a variety of GitLab resources in this particular example protecting an environment but the job returns the Root resource was present, but now absent message similar to Group creation results in "Root resource was present, but now absent"

This in turn seems to lead to an out of sync state file which causes 409 and 400 errors when TF is trying to create these missing resources as they were actually created the first time.

Relevant Terraform Configuration

terraform {
  required_providers {
    gitlab = {
      source = "gitlabhq/gitlab"
      version = "15.9.0"
    }
  }
}

Relevant Log Output

The error message from the logs is

Error: Provider produced inconsistent result after apply

│ When applying changes to
│ module.mvp_projects.gitlab_project_protected_environment.production["<project namespace>"],
│ provider "provider[\"registry.terraform.io/gitlabhq/gitlab\"]" produced an
│ unexpected new value: Root resource was present, but now absent.

│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
These are the debug logs of the `terraform` command output:

Additional Details

  • GitLab Terraform Provider Version: 15.9.0 and previously 3.18.0
  • GitLab Version: 15.10.0-pre d9a805c1b18 - GitLab.com
  • Terraform Version: ``

This also happens for other GitLab resources as follows:

  • module.mvp_projects.gitlab_project_protected_environment.production[]
  • module.vpcsc-self-service.gitlab_branch_protection.project
  • module.security-department-access-level.gitlab_branch_protection.project