published on Tuesday, Apr 21, 2026 by Pulumi
published on Tuesday, Apr 21, 2026 by Pulumi
The gitlab.ProjectPackageProtectionRule resource allows managing the lifecycle of a package protection rule.
You can use a wildcard (*) to protect multiple packages with the same package protection rule. You can apply several protection rules to the same package. A package is protected if at least one protection rule matches.
Upstream API: GitLab API docs
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
const _this = new gitlab.ProjectPackageProtectionRule("this", {
project: "123",
packageNamePattern: "@scope/package-*",
packageType: "npm",
minimumAccessLevelForPush: "owner",
minimumAccessLevelForDelete: "admin",
});
import pulumi
import pulumi_gitlab as gitlab
this = gitlab.ProjectPackageProtectionRule("this",
project="123",
package_name_pattern="@scope/package-*",
package_type="npm",
minimum_access_level_for_push="owner",
minimum_access_level_for_delete="admin")
package main
import (
"github.com/pulumi/pulumi-gitlab/sdk/v9/go/gitlab"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := gitlab.NewProjectPackageProtectionRule(ctx, "this", &gitlab.ProjectPackageProtectionRuleArgs{
Project: pulumi.String("123"),
PackageNamePattern: pulumi.String("@scope/package-*"),
PackageType: pulumi.String("npm"),
MinimumAccessLevelForPush: pulumi.String("owner"),
MinimumAccessLevelForDelete: pulumi.String("admin"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using GitLab = Pulumi.GitLab;
return await Deployment.RunAsync(() =>
{
var @this = new GitLab.Index.ProjectPackageProtectionRule("this", new()
{
Project = "123",
PackageNamePattern = "@scope/package-*",
PackageType = "npm",
MinimumAccessLevelForPush = "owner",
MinimumAccessLevelForDelete = "admin",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gitlab.ProjectPackageProtectionRule;
import com.pulumi.gitlab.ProjectPackageProtectionRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var this_ = new ProjectPackageProtectionRule("this", ProjectPackageProtectionRuleArgs.builder()
.project("123")
.packageNamePattern("@scope/package-*")
.packageType("npm")
.minimumAccessLevelForPush("owner")
.minimumAccessLevelForDelete("admin")
.build());
}
}
resources:
this:
type: gitlab:ProjectPackageProtectionRule
properties:
project: 123
packageNamePattern: '@scope/package-*'
packageType: npm
minimumAccessLevelForPush: owner
minimumAccessLevelForDelete: admin
Create ProjectPackageProtectionRule Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ProjectPackageProtectionRule(name: string, args: ProjectPackageProtectionRuleArgs, opts?: CustomResourceOptions);@overload
def ProjectPackageProtectionRule(resource_name: str,
args: ProjectPackageProtectionRuleArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ProjectPackageProtectionRule(resource_name: str,
opts: Optional[ResourceOptions] = None,
package_name_pattern: Optional[str] = None,
package_type: Optional[str] = None,
project: Optional[str] = None,
minimum_access_level_for_delete: Optional[str] = None,
minimum_access_level_for_push: Optional[str] = None)func NewProjectPackageProtectionRule(ctx *Context, name string, args ProjectPackageProtectionRuleArgs, opts ...ResourceOption) (*ProjectPackageProtectionRule, error)public ProjectPackageProtectionRule(string name, ProjectPackageProtectionRuleArgs args, CustomResourceOptions? opts = null)
public ProjectPackageProtectionRule(String name, ProjectPackageProtectionRuleArgs args)
public ProjectPackageProtectionRule(String name, ProjectPackageProtectionRuleArgs args, CustomResourceOptions options)
type: gitlab:ProjectPackageProtectionRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args ProjectPackageProtectionRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args ProjectPackageProtectionRuleArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args ProjectPackageProtectionRuleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ProjectPackageProtectionRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ProjectPackageProtectionRuleArgs
- 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 projectPackageProtectionRuleResource = new GitLab.ProjectPackageProtectionRule("projectPackageProtectionRuleResource", new()
{
PackageNamePattern = "string",
PackageType = "string",
Project = "string",
MinimumAccessLevelForDelete = "string",
MinimumAccessLevelForPush = "string",
});
example, err := gitlab.NewProjectPackageProtectionRule(ctx, "projectPackageProtectionRuleResource", &gitlab.ProjectPackageProtectionRuleArgs{
PackageNamePattern: pulumi.String("string"),
PackageType: pulumi.String("string"),
Project: pulumi.String("string"),
MinimumAccessLevelForDelete: pulumi.String("string"),
MinimumAccessLevelForPush: pulumi.String("string"),
})
var projectPackageProtectionRuleResource = new ProjectPackageProtectionRule("projectPackageProtectionRuleResource", ProjectPackageProtectionRuleArgs.builder()
.packageNamePattern("string")
.packageType("string")
.project("string")
.minimumAccessLevelForDelete("string")
.minimumAccessLevelForPush("string")
.build());
project_package_protection_rule_resource = gitlab.ProjectPackageProtectionRule("projectPackageProtectionRuleResource",
package_name_pattern="string",
package_type="string",
project="string",
minimum_access_level_for_delete="string",
minimum_access_level_for_push="string")
const projectPackageProtectionRuleResource = new gitlab.ProjectPackageProtectionRule("projectPackageProtectionRuleResource", {
packageNamePattern: "string",
packageType: "string",
project: "string",
minimumAccessLevelForDelete: "string",
minimumAccessLevelForPush: "string",
});
type: gitlab:ProjectPackageProtectionRule
properties:
minimumAccessLevelForDelete: string
minimumAccessLevelForPush: string
packageNamePattern: string
packageType: string
project: string
ProjectPackageProtectionRule 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 ProjectPackageProtectionRule resource accepts the following input properties:
- Package
Name stringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - Package
Type string - Package type protected by the protection rule. For example npm.
- Project string
- ID or URL-encoded path of the project.
- Minimum
Access stringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - Minimum
Access stringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set.
- Package
Name stringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - Package
Type string - Package type protected by the protection rule. For example npm.
- Project string
- ID or URL-encoded path of the project.
- Minimum
Access stringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - Minimum
Access stringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set.
- package
Name StringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - package
Type String - Package type protected by the protection rule. For example npm.
- project String
- ID or URL-encoded path of the project.
- minimum
Access StringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - minimum
Access StringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set.
- package
Name stringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - package
Type string - Package type protected by the protection rule. For example npm.
- project string
- ID or URL-encoded path of the project.
- minimum
Access stringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - minimum
Access stringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set.
- package_
name_ strpattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - package_
type str - Package type protected by the protection rule. For example npm.
- project str
- ID or URL-encoded path of the project.
- minimum_
access_ strlevel_ for_ delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - minimum_
access_ strlevel_ for_ push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set.
- package
Name StringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - package
Type String - Package type protected by the protection rule. For example npm.
- project String
- ID or URL-encoded path of the project.
- minimum
Access StringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - minimum
Access StringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set.
Outputs
All input properties are implicitly available as output properties. Additionally, the ProjectPackageProtectionRule resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Package
Protection intRule Id - Unique ID of the protection rule.
- Id string
- The provider-assigned unique ID for this managed resource.
- Package
Protection intRule Id - Unique ID of the protection rule.
- id String
- The provider-assigned unique ID for this managed resource.
- package
Protection IntegerRule Id - Unique ID of the protection rule.
- id string
- The provider-assigned unique ID for this managed resource.
- package
Protection numberRule Id - Unique ID of the protection rule.
- id str
- The provider-assigned unique ID for this managed resource.
- package_
protection_ intrule_ id - Unique ID of the protection rule.
- id String
- The provider-assigned unique ID for this managed resource.
- package
Protection NumberRule Id - Unique ID of the protection rule.
Look up Existing ProjectPackageProtectionRule Resource
Get an existing ProjectPackageProtectionRule 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?: ProjectPackageProtectionRuleState, opts?: CustomResourceOptions): ProjectPackageProtectionRule@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
minimum_access_level_for_delete: Optional[str] = None,
minimum_access_level_for_push: Optional[str] = None,
package_name_pattern: Optional[str] = None,
package_protection_rule_id: Optional[int] = None,
package_type: Optional[str] = None,
project: Optional[str] = None) -> ProjectPackageProtectionRulefunc GetProjectPackageProtectionRule(ctx *Context, name string, id IDInput, state *ProjectPackageProtectionRuleState, opts ...ResourceOption) (*ProjectPackageProtectionRule, error)public static ProjectPackageProtectionRule Get(string name, Input<string> id, ProjectPackageProtectionRuleState? state, CustomResourceOptions? opts = null)public static ProjectPackageProtectionRule get(String name, Output<String> id, ProjectPackageProtectionRuleState state, CustomResourceOptions options)resources: _: type: gitlab:ProjectPackageProtectionRule get: id: ${id}- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Minimum
Access stringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - Minimum
Access stringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set. - Package
Name stringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - Package
Protection intRule Id - Unique ID of the protection rule.
- Package
Type string - Package type protected by the protection rule. For example npm.
- Project string
- ID or URL-encoded path of the project.
- Minimum
Access stringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - Minimum
Access stringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set. - Package
Name stringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - Package
Protection intRule Id - Unique ID of the protection rule.
- Package
Type string - Package type protected by the protection rule. For example npm.
- Project string
- ID or URL-encoded path of the project.
- minimum
Access StringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - minimum
Access StringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set. - package
Name StringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - package
Protection IntegerRule Id - Unique ID of the protection rule.
- package
Type String - Package type protected by the protection rule. For example npm.
- project String
- ID or URL-encoded path of the project.
- minimum
Access stringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - minimum
Access stringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set. - package
Name stringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - package
Protection numberRule Id - Unique ID of the protection rule.
- package
Type string - Package type protected by the protection rule. For example npm.
- project string
- ID or URL-encoded path of the project.
- minimum_
access_ strlevel_ for_ delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - minimum_
access_ strlevel_ for_ push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set. - package_
name_ strpattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - package_
protection_ intrule_ id - Unique ID of the protection rule.
- package_
type str - Package type protected by the protection rule. For example npm.
- project str
- ID or URL-encoded path of the project.
- minimum
Access StringLevel For Delete - Minimum GitLab access level required to delete packages from the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForPushis not set. - minimum
Access StringLevel For Push - Minimum GitLab access level required to push packages to the package registry. Valid values are:
maintainer,owner,admin. Must be provided whenminimumAccessLevelForDeleteis not set. - package
Name StringPattern - Package name pattern protected by the protection rule. For example
@scope/package-*. Wildcard character*allowed. - package
Protection NumberRule Id - Unique ID of the protection rule.
- package
Type String - Package type protected by the protection rule. For example npm.
- project String
- ID or URL-encoded path of the project.
Import
Starting in Terraform v1.5.0, you can use an import block to import gitlab.ProjectPackageProtectionRule. For example:
Importing using the CLI is supported with the following syntax:
GitLab project package protection rules can be imported using an id made up of <project_id>:<package_protection_rule_id>, e.g.
$ pulumi import gitlab:index/projectPackageProtectionRule:ProjectPackageProtectionRule this 123:321
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
gitlabTerraform Provider.
published on Tuesday, Apr 21, 2026 by Pulumi
