Skip to content

New Resource gitlab_project_settings to manage settings after creation of a project and also after creation of other resources, like branches

New Data Source / Resource

When creating a new project it is not possible to set the default_branch in a single execution of terraform. For some workflows, it may be preferable to not turn on features or enable access until all related settings are configured. This better matches the UI workflow, and supports other use cases for automating user actions

resource "gitlab_project" "main" {
  project      = "namespace/myproject"
  namespace_id = data.gitlab_group.example.id
}

resource "gitlab_branch" "default" {
  name    = "develop"
  ref     = "production"
  project = gitlab_project.main.id
}

resource "gitlab_project_settings" "main" {
  project = gitlab_project.main.id
  default_branch = gitlab_branch.default.name
  push_rules {
    author_email_regex     = "@example\\.com$"
    commit_committer_check = true
    member_check           = true
    prevent_secrets        = true
  }
}

-->

Related GitLab APIs

API documentation: https://docs.gitlab.com/ee/api/projects.html

Additional Details

Edited by Aaron Sua