Archived projects are not properly handled by provider

Created by: czomo

GitLab Provider version

3.18.0

GitLab version

Gitlab 15.4 SaaS

Terraform version

1.3.1

Relevant Terraform Configuration

Pseudocode!

resource "gitlab_project" "project" {
  name           = var.name
  namespace_id   = var.group_id
  description    = var.description
  archived       = true
  ...
}

resource "gitlab_branch_protected" "feature" {
  project = gitlab_project.project.id

  merge_access_level = "maintainer"
  push_access_level  = "developer"
  branch = "feature*"
}

Relevant log output

Error: POST https://gitlab.com/api/v4/projects/*/pipeline_schedules: 403 {message: 403 Forbidden}

Description

We have all gitlab project described using terraform-provider-gitlab v3.18.0. Before we set some of the project to archived they have been setup with protected branches,schedules and so on. Configuration of protected branch resource has changed(setuped by module) after a while and and we seeing multiple errors for archived project that terraform failed to update to newer module because of 403 permission issues. We planed to add simple conditional but failed, seems we are deadlocked with it

What we considered:

  • adding count resulted in switching hundreds of resources to set of resources
  • adding count & moved statement to mitigate count migration. resulted in another deadlock where terraform plan to destroy resources of archived project(created before archiving it,because of count = gitlab_project.project.archived ? 0 : 1) as we ended with permission errors
  • lifecycle - i guess we can't set any condition with it

Shouldn't it be handled on provider side? We should be able to at least skip errors when gitlab return 403 because of archived projects. It's simmilar to https://github.com/gitlabhq/terraform-provider-gitlab/issues/1090 but there no way to filter resources or fix state

Edited by Timo Furrer