Skip to content

gitlab_project_security_policy_attachment not applying policy

Bug Report

Adding a gitlab_project_security_policy_attachment seems to run through and apply what was intended with no modification at Gitlab.

In plan:

  # gitlab_project_security_policy_attachment.ds-project-policies["1234567"] will be created
  + resource "gitlab_project_security_policy_attachment" "project-policies" {
      + id                        = (known after apply)
      + policy_project            = "2345678"
      + policy_project_graphql_id = (known after apply)
      + project                   = "1234567"
      + project_graphql_id        = (known after apply)
    }

Results in:

image

Which i then have to manually assign.

Relevant Terraform Configuration

# For testing
locals {
  policy-attachement-projects = toset([
    module.squad-repos["project1"].project_id
  ])
}

resource "gitlab_project_security_policy_attachment" "project-policies" {
  for_each = local.policy-attachement-projects

  project        = each.value
  policy_project = module.policy-repo.project_id
}

Relevant Terraform Command

terraform ...

Relevant Log Output

No issues reported, terraform process completes successfully.

Additional Details

  • GitLab Terraform Provider Version: v17.6.1
  • GitLab Version: 17.7.0. # GitLab Enterprise Edition 17.7.0-pre
  • Terraform Version: 1.5