This module creates a GitLab project with a default set of permissions.
Terraform module to manage GitLab projects with DWP default settings. This module is published on Terraform Registry and it should be referred to for usage documentation.
- See the
versions.tf
file for required Terraform and provider versions. - GitLab personal access token with the following permissions:
api
- A GitLub group
module "my_gitlab_project" {
source = "dwp/project/gitlab"
group_id = 123
name = "my-project"
}
variable "gitlab_token" {
type = string
description = "GitLab personal access token for managing projects"
}
provider "gitlab" {
token = var.gitlab_token
}
resource "gitlab_group" "my_group" {
name = "my-group"
path = "my-group"
description = "An example group"
}
module "my_gitlab_project" {
source = "dwp/project/gitlab"
group_id = gitlab_group.example.id
name = "my-project"
}
As per the engineering practice guidance:
Projects must be named in lowercase, using a-z, 0-9, and - symbols only. The name should reflect the contents and must not have any generic or repetitive prefixes or suffixes, or abbreviations, acronyms, or initialisms.
For example, the following would not be an acceptable project name:
module "project" {
source = "dwp/project/gitlab"
group_id = 123
name = "apply for pension credit citizen UI"
}
Instead, it should be something like this:
module "project" {
source = "dwp/project/gitlab"
group_id = 123
name = "citizen-frontend"
}
To avoid accidental destruction, particularly for modifications that require replacement, this module will not destroy the project resource. Unfortunately, Terraform only allows literal values for lifecycle rules, so this cannot be variable or conditional. As a result, the project should be manually deleted from GitLab and Terraform state.
- Delete project in GitLab
- Remove a resource from Terraform state
- e.g.
terraform state rm module.my_gitlab_project.gitlab_project.this
- e.g.