Skip to content

schubergphilis/terraform-gitlab-mcaf-project

Repository files navigation

terraform-gitlab-mcaf-project

Terraform module to create and manage a GitLab project.

IMPORTANT: We do not pin modules to versions in our examples. We highly recommend that in your code you pin the version to the exact version you are using so that your infrastructure remains stable.

Requirements

Name Version
terraform >= 1.3.0
gitlab >= 16.0.0

Providers

Name Version
gitlab >= 16.0.0

Modules

No modules.

Resources

Name Type
gitlab_branch_protection.default resource
gitlab_pipeline_schedule.default resource
gitlab_project.default resource
gitlab_project_approval_rule.default resource
gitlab_project_level_mr_approvals.default resource
gitlab_project_variable.default resource
gitlab_group.default data source
gitlab_group.groups data source
gitlab_group.project_approval_rule_groups data source
gitlab_user.project_approval_rule_users data source
gitlab_user.users data source

Inputs

Name Description Type Default Required
name The name of the project string n/a yes
namespace The namespace (group or user) of the project string n/a yes
approvals_before_merge Number of merge request approvals required for merging number 1 no
branch_protection Branch protection settings
map(object({
allow_force_push = optional(bool, false)
code_owner_approval_required = optional(bool, false)
merge_access_level = optional(string, "developer")
push_access_level = optional(string, "no one")
unprotect_access_level = optional(string)

groups_allowed_to_merge = optional(list(string), [])
groups_allowed_to_push = optional(list(string), [])
groups_allowed_to_unprotect = optional(list(string), [])

users_allowed_to_merge = optional(list(string), [])
users_allowed_to_push = optional(list(string), [])
users_allowed_to_unprotect = optional(list(string), [])
}))
{} no
ci_config_path Custom Path to CI config file. string ".gitlab-ci.yml" no
ci_default_git_depth Default number of revisions for shallow cloning. number 3 no
cicd_variables CICD variables accessable during pipeline runs.
map(object({
value = string
protected = bool
masked = optional(bool, false)
raw = optional(bool, false)
variable_type = optional(string, "env_var")
}))
{} no
commit_message_regex A regex pattern that a commit message must match in order to be accepted. string null no
default_branch The default branch for the project string "main" no
description A description for the GitLab project string null no
initialize_with_readme Create default branch with first commit containing a README.md file bool true no
issues_enabled Enable issue tracking for the project bool false no
merge_request_approval_rule Allows to manage the lifecycle of a Merge Request-level approval rule.
object({
disable_overriding_approvers_per_merge_request = optional(bool, false)
merge_requests_author_approval = optional(bool, false)
merge_requests_disable_committers_approval = optional(bool, false)
reset_approvals_on_push = optional(bool, true)
})
{} no
only_allow_merge_if_all_discussions_are_resolved Set to true if you want allow merges only if all discussions are resolved. bool false no
only_allow_merge_if_pipeline_succeeds Set to true if you want allow merges only if a pipeline succeeds. bool false no
pipeline_schedule Pipeline scheduler parameter.
object({
active = optional(bool, true)
cron = string
cron_timezone = optional(string, "UTC")
description = string
ref = optional(string, "refs/heads/main")
take_ownership = optional(bool, false)
})
null no
prevent_secrets GitLab rejects any files that are likely to contain secrets. bool true no
project_approval_rule Allows to manage the lifecycle of a project-level approval rule.
object({
name = optional(string, "project approval rule")
applies_to_all_protected_branches = optional(bool, true)
approvals_required = optional(number, 1)
groups = optional(list(string), [])
protected_branches = optional(list(string), null)
users = optional(list(string), [])
})
{} no
reject_unsigned_commits GitLab rejects any unsigned commits. bool true no
remove_source_branch_after_merge Enable "Delete source branch" option by default for all new merge requests. bool true no
snippets_enabled Enable snippets for the project bool false no
squash_option Squash commits when merge request string "default_off" no
use_group_settings Ignore settings that can also be set on a group level to prevent conflicts bool false no
visibility Set the GitLab project as public, private or internal string "private" no
wiki_enabled Enable wiki for the project bool false no

Outputs

Name Description
id GitLab project id
path GitLab project path
path_with_namespace GitLab project path with namespace