Terraform module which can help you to create Gitlab resources and assign membership as you want. This module has three submodules for groups, projects and users. Below you can see how to use them.
Due to gitlab issue Gitlab Issue 244345 it is not possible to create root group. As a workaround first you need to create root group thought browser and use import command to add that group in state.
Import command:
terraform import 'module.gitlab-group-module-dev.gitlab_group.group["dev"]' <group_id>
module "gitlab-group-module-components" {
source = "../modules/gitlab-group-module"
groups = {
frontend = {
name = "Frontend"
path = "frontend"
parent_id = module.gitlab-group-module-dev.created_groups["dev"].id
}
backend = {
name = "Backend"
path = "backend"
parent_id = module.gitlab-group-module-dev.created_groups["dev"].id
}
}
}
Use this submodule to create projects on you Gitlab instance or Gitlab.com.
module "gitlab-project-module" {
source = "../modules/gitlab-project-module"
projects = {
react_example_project = {
name = "React example project"
namespace_id = local.created_groups["frontend"].id
push_rules = {
commit_committer_check = true
}
}
django_example_project = {
name = "Django example project"
namespace_id = local.created_groups["backend"].id
}
}
}
Use this submodule to create users and asign membership to groups or projects.
module "gitlab-user-module" {
source = "../modules/gitlab-user-module"
groups = local.created_groups
projects = module.gitlab-project-module.created_projects
users = {
johnharper = {
create = false
username = "john.harper"
email = "[email protected]"
name = "John Harper"
groups = {
frontend = {
access_level = "maintainer"
expires_at = null
}
dev = {
access_level = "guest"
}
}
}
chrisharper = {
username = "chris.harper"
email = "[email protected]"
name = "Chris Harper"
groups = {
backend = {
access_level = "developer"
expires_at = "2030-12-31"
}
dev = {
access_level = "guest"
expires_at = "2030-12-31"
}
}
projects = {
react_example_project = {
access_level = "maintainer"
}
}
}
}
}
Apache 2 Licensed. See LICENSE for full details.
No requirements.
No providers.
No modules.
No resources.
No inputs.
No outputs.