Giter Site home page Giter Site logo

tanandy / terraform-gitlab-project Goto Github PK

View Code? Open in Web Editor NEW

This project forked from willianpaixao/terraform-gitlab-project

0.0 0.0 0.0 31 KB

Terraform module for Gitlab projects

Home Page: https://registry.terraform.io/modules/willianpaixao/project/gitlab/latest

License: Mozilla Public License 2.0

HCL 100.00%

terraform-gitlab-project's Introduction

GitLab Logo

Gitlab project Terraform module

This module is built upon the gitlabhq/gitlab provider, and is used to create a new Gitlab projects (aka Git repository) under an existing group. It reduces the boilerplate and has better security flags raised by default.

-> The group can be created or imported using gitlab_group

Default resources and features

Feature Default
CI/CD Pipelines true
Container Registry true
Git Large File Storage (LFS) false
Gitlab Pages false
Issues false
Package Registry false
Snippets false
Wiki false

Examples

Create one repository

Pretty simple, add the following block and replace the values accordingly.

module "project" {
  source  = "willianpaixao/project/gitlab"
  version = "~> 1.0.1"

  name         = "My New Pet project"
  description  = "Yet another project I will never finish"
  namespace_id = gitlab_group.some-group.id
  tags         = ["pet", "unfinished"]
}

Create many repositories under the same subgroup

The usage consists of two simple steps, first define your variable in variables.tf then add the module block to your code, referencing the source as following:

variable "project" {
  description = "list of attributes of a project"
  type        = map(any)
  default = {
    your-shiny-project = {
      name        = "your-shiny-project"
      description = "A descriptive description"
      tags        = ["tagA", "tagB"]
  }
}

module "subgroup_projects" {
  source  = "willianpaixao/project/gitlab"
  version = "~> 1.0.1"

  for_each = var.project

  name         = each.value.name
  description  = each.value.description
  namespace_id = gitlab_group.some-group.id
  tags         = setunion(["subgroup"], each.value.tags)
}

Setting a list of project owners

data "gitlab_user" "owners" {
  for_each = toset(["user1", "user2", "user3"])
  username = each.value
}

module "api" {
  source  = "willianpaixao/project/gitlab"
  version = "~> 1.0.1"

  name               = "api"
  description        = "REST API"
  namespace_id       = gitlab_group.some-group.id
  approvals_required = 3
  owners             = [for user in data.owners.users : user.id]
  tags               = "api"
}

resource "gitlab_project_membership" "owners" {
  for_each     = [for user in data.owners.users : user.id]

  project_id   = module.api.id
  user_id      = each.key
  access_level = "owners"
}

That's it! Run terraform plan and check the output to see if matches your recent changes.

Providers

Name Version
gitlab >= 3.7.0

Resources

Name Type
gitlab_branch_protection.default resource
gitlab_pipeline_trigger.default resource
gitlab_project.default resource
gitlab_project_approval_rule.default resource
gitlab_project_level_mr_approvals.default resource
gitlab_tag_protection.default resource

Inputs

Name Description Type Default Required
description A short description of the project string n/a yes
name Name of the project string n/a yes
namespace_id The group where the project belongs to string n/a yes
approvals_required The minimum number of approvals required for MRs number 1 no
author_email_regex All commit author emails must match this regex. As part of Push Rules, it's only available for GitLab Premium string null no
container_registry_enabled Enable container registry for the project bool true no
default_branch The default branch for the project string "main" no
owners A list of specific User IDs allowed to approve Merge Requests. Please refer to Gitlab documentation for further information list(string) [] no
pipelines_enabled Enable pipelines for the project bool true no
shared_runners_enabled Enable shared runners for the project bool true no
tags The list of tags to be attached to the project list(string) [] no
template_project_id Project ID of a custom project template. Please refer to Gitlab documentation for further information number null no
use_custom_template Use either custom instance or group-level project template bool false no

Outputs

Name Description
id Integer that uniquely identifies the project within the gitlab install
path_with_namespace The path of the repository with namespace
web_url URL that can be used to find the project in a browser

Changelog

Please refer to our changelog for further information on versioning and upgrades.

Contributing

Checkout our contributing guide.

References

terraform-gitlab-project's People

Contributors

willianpaixao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.