1. Packages
  2. Gitlab Provider
  3. API Docs
  4. ProjectApprovalRule
GitLab v8.10.0 published on Friday, Mar 21, 2025 by Pulumi

gitlab.ProjectApprovalRule

Explore with Pulumi AI

Example Usage

Create ProjectApprovalRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new ProjectApprovalRule(name: string, args: ProjectApprovalRuleArgs, opts?: CustomResourceOptions);
@overload
def ProjectApprovalRule(resource_name: str,
                        args: ProjectApprovalRuleArgs,
                        opts: Optional[ResourceOptions] = None)

@overload
def ProjectApprovalRule(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        approvals_required: Optional[int] = None,
                        project: Optional[str] = None,
                        applies_to_all_protected_branches: Optional[bool] = None,
                        disable_importing_default_any_approver_rule_on_create: Optional[bool] = None,
                        group_ids: Optional[Sequence[int]] = None,
                        name: Optional[str] = None,
                        protected_branch_ids: Optional[Sequence[int]] = None,
                        report_type: Optional[str] = None,
                        rule_type: Optional[str] = None,
                        user_ids: Optional[Sequence[int]] = None)
func NewProjectApprovalRule(ctx *Context, name string, args ProjectApprovalRuleArgs, opts ...ResourceOption) (*ProjectApprovalRule, error)
public ProjectApprovalRule(string name, ProjectApprovalRuleArgs args, CustomResourceOptions? opts = null)
public ProjectApprovalRule(String name, ProjectApprovalRuleArgs args)
public ProjectApprovalRule(String name, ProjectApprovalRuleArgs args, CustomResourceOptions options)
type: gitlab:ProjectApprovalRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ProjectApprovalRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ProjectApprovalRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ProjectApprovalRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ProjectApprovalRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ProjectApprovalRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var projectApprovalRuleResource = new GitLab.ProjectApprovalRule("projectApprovalRuleResource", new()
{
    ApprovalsRequired = 0,
    Project = "string",
    AppliesToAllProtectedBranches = false,
    DisableImportingDefaultAnyApproverRuleOnCreate = false,
    GroupIds = new[]
    {
        0,
    },
    Name = "string",
    ProtectedBranchIds = new[]
    {
        0,
    },
    ReportType = "string",
    RuleType = "string",
    UserIds = new[]
    {
        0,
    },
});
Copy
example, err := gitlab.NewProjectApprovalRule(ctx, "projectApprovalRuleResource", &gitlab.ProjectApprovalRuleArgs{
	ApprovalsRequired:             pulumi.Int(0),
	Project:                       pulumi.String("string"),
	AppliesToAllProtectedBranches: pulumi.Bool(false),
	DisableImportingDefaultAnyApproverRuleOnCreate: pulumi.Bool(false),
	GroupIds: pulumi.IntArray{
		pulumi.Int(0),
	},
	Name: pulumi.String("string"),
	ProtectedBranchIds: pulumi.IntArray{
		pulumi.Int(0),
	},
	ReportType: pulumi.String("string"),
	RuleType:   pulumi.String("string"),
	UserIds: pulumi.IntArray{
		pulumi.Int(0),
	},
})
Copy
var projectApprovalRuleResource = new ProjectApprovalRule("projectApprovalRuleResource", ProjectApprovalRuleArgs.builder()
    .approvalsRequired(0)
    .project("string")
    .appliesToAllProtectedBranches(false)
    .disableImportingDefaultAnyApproverRuleOnCreate(false)
    .groupIds(0)
    .name("string")
    .protectedBranchIds(0)
    .reportType("string")
    .ruleType("string")
    .userIds(0)
    .build());
Copy
project_approval_rule_resource = gitlab.ProjectApprovalRule("projectApprovalRuleResource",
    approvals_required=0,
    project="string",
    applies_to_all_protected_branches=False,
    disable_importing_default_any_approver_rule_on_create=False,
    group_ids=[0],
    name="string",
    protected_branch_ids=[0],
    report_type="string",
    rule_type="string",
    user_ids=[0])
Copy
const projectApprovalRuleResource = new gitlab.ProjectApprovalRule("projectApprovalRuleResource", {
    approvalsRequired: 0,
    project: "string",
    appliesToAllProtectedBranches: false,
    disableImportingDefaultAnyApproverRuleOnCreate: false,
    groupIds: [0],
    name: "string",
    protectedBranchIds: [0],
    reportType: "string",
    ruleType: "string",
    userIds: [0],
});
Copy
type: gitlab:ProjectApprovalRule
properties:
    appliesToAllProtectedBranches: false
    approvalsRequired: 0
    disableImportingDefaultAnyApproverRuleOnCreate: false
    groupIds:
        - 0
    name: string
    project: string
    protectedBranchIds:
        - 0
    reportType: string
    ruleType: string
    userIds:
        - 0
Copy

ProjectApprovalRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The ProjectApprovalRule resource accepts the following input properties:

ApprovalsRequired This property is required. int
The number of approvals required for this rule.
Project
This property is required.
Changes to this property will trigger replacement.
string
The name or id of the project to add the approval rules.
AppliesToAllProtectedBranches bool
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
DisableImportingDefaultAnyApproverRuleOnCreate bool
When this flag is set, the default any_approver rule will not be imported if present.
GroupIds List<int>
A list of group IDs whose members can approve of the merge request.
Name string
The name of the approval rule.
ProtectedBranchIds List<int>
A list of protected branch IDs (not branch names) for which the rule applies.
ReportType Changes to this property will trigger replacement. string
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
RuleType Changes to this property will trigger replacement. string
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
UserIds List<int>
A list of specific User IDs to add to the list of approvers.
ApprovalsRequired This property is required. int
The number of approvals required for this rule.
Project
This property is required.
Changes to this property will trigger replacement.
string
The name or id of the project to add the approval rules.
AppliesToAllProtectedBranches bool
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
DisableImportingDefaultAnyApproverRuleOnCreate bool
When this flag is set, the default any_approver rule will not be imported if present.
GroupIds []int
A list of group IDs whose members can approve of the merge request.
Name string
The name of the approval rule.
ProtectedBranchIds []int
A list of protected branch IDs (not branch names) for which the rule applies.
ReportType Changes to this property will trigger replacement. string
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
RuleType Changes to this property will trigger replacement. string
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
UserIds []int
A list of specific User IDs to add to the list of approvers.
approvalsRequired This property is required. Integer
The number of approvals required for this rule.
project
This property is required.
Changes to this property will trigger replacement.
String
The name or id of the project to add the approval rules.
appliesToAllProtectedBranches Boolean
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
disableImportingDefaultAnyApproverRuleOnCreate Boolean
When this flag is set, the default any_approver rule will not be imported if present.
groupIds List<Integer>
A list of group IDs whose members can approve of the merge request.
name String
The name of the approval rule.
protectedBranchIds List<Integer>
A list of protected branch IDs (not branch names) for which the rule applies.
reportType Changes to this property will trigger replacement. String
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
ruleType Changes to this property will trigger replacement. String
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
userIds List<Integer>
A list of specific User IDs to add to the list of approvers.
approvalsRequired This property is required. number
The number of approvals required for this rule.
project
This property is required.
Changes to this property will trigger replacement.
string
The name or id of the project to add the approval rules.
appliesToAllProtectedBranches boolean
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
disableImportingDefaultAnyApproverRuleOnCreate boolean
When this flag is set, the default any_approver rule will not be imported if present.
groupIds number[]
A list of group IDs whose members can approve of the merge request.
name string
The name of the approval rule.
protectedBranchIds number[]
A list of protected branch IDs (not branch names) for which the rule applies.
reportType Changes to this property will trigger replacement. string
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
ruleType Changes to this property will trigger replacement. string
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
userIds number[]
A list of specific User IDs to add to the list of approvers.
approvals_required This property is required. int
The number of approvals required for this rule.
project
This property is required.
Changes to this property will trigger replacement.
str
The name or id of the project to add the approval rules.
applies_to_all_protected_branches bool
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
disable_importing_default_any_approver_rule_on_create bool
When this flag is set, the default any_approver rule will not be imported if present.
group_ids Sequence[int]
A list of group IDs whose members can approve of the merge request.
name str
The name of the approval rule.
protected_branch_ids Sequence[int]
A list of protected branch IDs (not branch names) for which the rule applies.
report_type Changes to this property will trigger replacement. str
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
rule_type Changes to this property will trigger replacement. str
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
user_ids Sequence[int]
A list of specific User IDs to add to the list of approvers.
approvalsRequired This property is required. Number
The number of approvals required for this rule.
project
This property is required.
Changes to this property will trigger replacement.
String
The name or id of the project to add the approval rules.
appliesToAllProtectedBranches Boolean
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
disableImportingDefaultAnyApproverRuleOnCreate Boolean
When this flag is set, the default any_approver rule will not be imported if present.
groupIds List<Number>
A list of group IDs whose members can approve of the merge request.
name String
The name of the approval rule.
protectedBranchIds List<Number>
A list of protected branch IDs (not branch names) for which the rule applies.
reportType Changes to this property will trigger replacement. String
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
ruleType Changes to this property will trigger replacement. String
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
userIds List<Number>
A list of specific User IDs to add to the list of approvers.

Outputs

All input properties are implicitly available as output properties. Additionally, the ProjectApprovalRule resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing ProjectApprovalRule Resource

Get an existing ProjectApprovalRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ProjectApprovalRuleState, opts?: CustomResourceOptions): ProjectApprovalRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        applies_to_all_protected_branches: Optional[bool] = None,
        approvals_required: Optional[int] = None,
        disable_importing_default_any_approver_rule_on_create: Optional[bool] = None,
        group_ids: Optional[Sequence[int]] = None,
        name: Optional[str] = None,
        project: Optional[str] = None,
        protected_branch_ids: Optional[Sequence[int]] = None,
        report_type: Optional[str] = None,
        rule_type: Optional[str] = None,
        user_ids: Optional[Sequence[int]] = None) -> ProjectApprovalRule
func GetProjectApprovalRule(ctx *Context, name string, id IDInput, state *ProjectApprovalRuleState, opts ...ResourceOption) (*ProjectApprovalRule, error)
public static ProjectApprovalRule Get(string name, Input<string> id, ProjectApprovalRuleState? state, CustomResourceOptions? opts = null)
public static ProjectApprovalRule get(String name, Output<String> id, ProjectApprovalRuleState state, CustomResourceOptions options)
resources:  _:    type: gitlab:ProjectApprovalRule    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
AppliesToAllProtectedBranches bool
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
ApprovalsRequired int
The number of approvals required for this rule.
DisableImportingDefaultAnyApproverRuleOnCreate bool
When this flag is set, the default any_approver rule will not be imported if present.
GroupIds List<int>
A list of group IDs whose members can approve of the merge request.
Name string
The name of the approval rule.
Project Changes to this property will trigger replacement. string
The name or id of the project to add the approval rules.
ProtectedBranchIds List<int>
A list of protected branch IDs (not branch names) for which the rule applies.
ReportType Changes to this property will trigger replacement. string
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
RuleType Changes to this property will trigger replacement. string
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
UserIds List<int>
A list of specific User IDs to add to the list of approvers.
AppliesToAllProtectedBranches bool
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
ApprovalsRequired int
The number of approvals required for this rule.
DisableImportingDefaultAnyApproverRuleOnCreate bool
When this flag is set, the default any_approver rule will not be imported if present.
GroupIds []int
A list of group IDs whose members can approve of the merge request.
Name string
The name of the approval rule.
Project Changes to this property will trigger replacement. string
The name or id of the project to add the approval rules.
ProtectedBranchIds []int
A list of protected branch IDs (not branch names) for which the rule applies.
ReportType Changes to this property will trigger replacement. string
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
RuleType Changes to this property will trigger replacement. string
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
UserIds []int
A list of specific User IDs to add to the list of approvers.
appliesToAllProtectedBranches Boolean
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
approvalsRequired Integer
The number of approvals required for this rule.
disableImportingDefaultAnyApproverRuleOnCreate Boolean
When this flag is set, the default any_approver rule will not be imported if present.
groupIds List<Integer>
A list of group IDs whose members can approve of the merge request.
name String
The name of the approval rule.
project Changes to this property will trigger replacement. String
The name or id of the project to add the approval rules.
protectedBranchIds List<Integer>
A list of protected branch IDs (not branch names) for which the rule applies.
reportType Changes to this property will trigger replacement. String
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
ruleType Changes to this property will trigger replacement. String
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
userIds List<Integer>
A list of specific User IDs to add to the list of approvers.
appliesToAllProtectedBranches boolean
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
approvalsRequired number
The number of approvals required for this rule.
disableImportingDefaultAnyApproverRuleOnCreate boolean
When this flag is set, the default any_approver rule will not be imported if present.
groupIds number[]
A list of group IDs whose members can approve of the merge request.
name string
The name of the approval rule.
project Changes to this property will trigger replacement. string
The name or id of the project to add the approval rules.
protectedBranchIds number[]
A list of protected branch IDs (not branch names) for which the rule applies.
reportType Changes to this property will trigger replacement. string
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
ruleType Changes to this property will trigger replacement. string
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
userIds number[]
A list of specific User IDs to add to the list of approvers.
applies_to_all_protected_branches bool
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
approvals_required int
The number of approvals required for this rule.
disable_importing_default_any_approver_rule_on_create bool
When this flag is set, the default any_approver rule will not be imported if present.
group_ids Sequence[int]
A list of group IDs whose members can approve of the merge request.
name str
The name of the approval rule.
project Changes to this property will trigger replacement. str
The name or id of the project to add the approval rules.
protected_branch_ids Sequence[int]
A list of protected branch IDs (not branch names) for which the rule applies.
report_type Changes to this property will trigger replacement. str
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
rule_type Changes to this property will trigger replacement. str
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
user_ids Sequence[int]
A list of specific User IDs to add to the list of approvers.
appliesToAllProtectedBranches Boolean
Whether the rule is applied to all protected branches. If set to 'true', the value of protected_branch_ids is ignored. Default is 'false'.
approvalsRequired Number
The number of approvals required for this rule.
disableImportingDefaultAnyApproverRuleOnCreate Boolean
When this flag is set, the default any_approver rule will not be imported if present.
groupIds List<Number>
A list of group IDs whose members can approve of the merge request.
name String
The name of the approval rule.
project Changes to this property will trigger replacement. String
The name or id of the project to add the approval rules.
protectedBranchIds List<Number>
A list of protected branch IDs (not branch names) for which the rule applies.
reportType Changes to this property will trigger replacement. String
Report type is required when the rule_type is report_approver. Valid values are code_coverage.
ruleType Changes to this property will trigger replacement. String
String, defaults to 'regular'. The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Valid values are regular, any_approver, report_approver.
userIds List<Number>
A list of specific User IDs to add to the list of approvers.

Import

Starting in Terraform v1.5.0 you can use an import block to import gitlab_project_approval_rule. For example:

terraform

import {

to = gitlab_project_approval_rule.example

id = “see CLI command below for ID”

}

Import using the CLI is supported using the following syntax:

GitLab project approval rules can be imported using a key composed of <project-id>:<rule-id>, e.g.

$ pulumi import gitlab:index/projectApprovalRule:ProjectApprovalRule example "12345:6"
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
GitLab pulumi/pulumi-gitlab
License
Apache-2.0
Notes
This Pulumi package is based on the gitlab Terraform Provider.