1. Registry
  2. Packages
  3. Gitlab Provider
  4. API Docs
  5. ProjectJobTokenScope
Viewing docs for GitLab v10.4.1
published on Saturday, Oct 31, 2026 by Pulumi
gitlab logo
Viewing docs for GitLab v10.4.1
published on Saturday, Oct 31, 2026 by Pulumi

    The gitlab.ProjectJobTokenScope resource manages the CI/CD Job Token scope in a project. Any projects added to the CI/CD Job Token scope outside of TF will be untouched by the resource.

    Conflicts with the use of gitlab.ProjectJobTokenScopes when used on the same project. Use one or the other to ensure the desired state.

    Upstream API: GitLab REST API docs

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gitlab from "@pulumi/gitlab";
    import * as std from "@pulumi/std";
    
    export = async () => {
        const allowedSingleProject = new gitlab.ProjectJobTokenScope("allowed_single_project", {
            project: "gitlab-org/gitlab",
            targetProjectId: 123,
        });
        const allowedProjectIds = [
            123,
            456,
            789,
        ];
        const allowedGroupIds = [
            123,
            456,
            789,
        ];
        const deploymentProject = await gitlab.getProject({
            name: "example-project",
        });
        const allowedProject: gitlab.ProjectJobTokenScope[] = [];
        for (const range of std.toset({
            input: allowedProjectIds,
        }).result.map((v, k) => ({key: k, value: v}))) {
            allowedProject.push(new gitlab.ProjectJobTokenScope(`allowed_project-${range.key}`, {
                project: deploymentProject.id,
                targetProjectId: range.key,
            }));
        }
        const allowedGroup: gitlab.ProjectJobTokenScope[] = [];
        for (const range of std.toset({
            input: allowedGroupIds,
        }).result.map((v, k) => ({key: k, value: v}))) {
            allowedGroup.push(new gitlab.ProjectJobTokenScope(`allowed_group-${range.key}`, {
                project: deploymentProject.id,
                targetGroupId: range.key,
            }));
        }
    }
    
    import pulumi
    from typing import Any
    import pulumi_gitlab as gitlab
    import pulumi_std as std
    
    allowed_single_project = gitlab.ProjectJobTokenScope("allowed_single_project",
        project="gitlab-org/gitlab",
        target_project_id=123)
    allowed_project_ids = [
        123,
        456,
        789,
    ]
    allowed_group_ids = [
        123,
        456,
        789,
    ]
    deployment_project = gitlab.get_project(name="example-project")
    allowed_project: list[gitlab.ProjectJobTokenScope] = []
    for allowed_project_range in [{"key": k, "value": v} for [k, v] in enumerate(std.toset(input=allowed_project_ids).result)]:
        allowed_project.append(gitlab.ProjectJobTokenScope(f"allowed_project-{allowed_project_range['key']}",
            project=deployment_project.id,
            target_project_id=allowed_project_range["key"]))
    allowed_group: list[gitlab.ProjectJobTokenScope] = []
    for allowed_group_range in [{"key": k, "value": v} for [k, v] in enumerate(std.toset(input=allowed_group_ids).result)]:
        allowed_group.append(gitlab.ProjectJobTokenScope(f"allowed_group-{allowed_group_range['key']}",
            project=deployment_project.id,
            target_group_id=allowed_group_range["key"]))
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-gitlab/sdk/v10/go/gitlab"
    	"github.com/pulumi/pulumi-std/sdk/go/std"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := gitlab.NewProjectJobTokenScope(ctx, "allowed_single_project", &gitlab.ProjectJobTokenScopeArgs{
    			Project:         pulumi.String("gitlab-org/gitlab"),
    			TargetProjectId: pulumi.Int(123),
    		})
    		if err != nil {
    			return err
    		}
    		allowedProjectIds := []int{
    			123,
    			456,
    			789,
    		}
    		allowedGroupIds := []int{
    			123,
    			456,
    			789,
    		}
    		deploymentProject, err := gitlab.GetProject(ctx, &gitlab.LookupProjectArgs{
    			Name: "example-project",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		var allowedProject []*gitlab.ProjectJobTokenScope
    		for key0, _ := range []interface{}(std.Toset(ctx, &std.TosetArgs{
    			Input: allowedProjectIds,
    		}, nil).Result) {
    			__res, err := gitlab.NewProjectJobTokenScope(ctx, fmt.Sprintf("allowed_project-%v", key0), &gitlab.ProjectJobTokenScopeArgs{
    				Project:         pulumi.String(deploymentProject.Id),
    				TargetProjectId: pulumi.Int(key0),
    			})
    			if err != nil {
    				return err
    			}
    			allowedProject = append(allowedProject, __res)
    		}
    		var allowedGroup []*gitlab.ProjectJobTokenScope
    		for key0, _ := range []interface{}(std.Toset(ctx, &std.TosetArgs{
    			Input: allowedGroupIds,
    		}, nil).Result) {
    			__res, err := gitlab.NewProjectJobTokenScope(ctx, fmt.Sprintf("allowed_group-%v", key0), &gitlab.ProjectJobTokenScopeArgs{
    				Project:       pulumi.String(deploymentProject.Id),
    				TargetGroupId: pulumi.Int(key0),
    			})
    			if err != nil {
    				return err
    			}
    			allowedGroup = append(allowedGroup, __res)
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Pulumi;
    using GitLab = Pulumi.GitLab;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(async() => 
    {
        var allowedSingleProject = new GitLab.ProjectJobTokenScope("allowed_single_project", new()
        {
            Project = "gitlab-org/gitlab",
            TargetProjectId = 123,
        });
    
        var allowedProjectIds = new[]
        {
            123,
            456,
            789,
        };
    
        var allowedGroupIds = new[]
        {
            123,
            456,
            789,
        };
    
        var deploymentProject = await GitLab.GetProject.InvokeAsync(new()
        {
            Name = "example-project",
        });
    
        var allowedProject = new List<GitLab.ProjectJobTokenScope>();
        foreach (var range in )
        {
            allowedProject.Add(new GitLab.ProjectJobTokenScope($"allowed_project-{range.Key}", new()
            {
                Project = deploymentProject.Id,
                TargetProjectId = range.Key,
            }));
        }
        var allowedGroup = new List<GitLab.ProjectJobTokenScope>();
        foreach (var range in )
        {
            allowedGroup.Add(new GitLab.ProjectJobTokenScope($"allowed_group-{range.Key}", new()
            {
                Project = deploymentProject.Id,
                TargetGroupId = range.Key,
            }));
        }
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gitlab.ProjectJobTokenScope;
    import com.pulumi.gitlab.ProjectJobTokenScopeArgs;
    import com.pulumi.gitlab.GitlabFunctions;
    import com.pulumi.gitlab.inputs.GetProjectArgs;
    import com.pulumi.codegen.internal.KeyedValue;
    import java.util.ArrayList;
    import java.util.Arrays;
    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 allowedSingleProject = new ProjectJobTokenScope("allowedSingleProject", ProjectJobTokenScopeArgs.builder()
                .project("gitlab-org/gitlab")
                .targetProjectId(123)
                .build());
    
            final var allowedProjectIds =         
                123,
                456,
                789;
    
            final var allowedGroupIds =         
                123,
                456,
                789;
    
            final var deploymentProject = GitlabFunctions.getProject(GetProjectArgs.builder()
                .name("example-project")
                .build());
    
            for (var range : KeyedValue.of(com.pulumi.std.StdFunctions(com.pulumi.std.inputs.TosetArgs.builder()
                .input(allowedProjectIds)
                .build()).result())) {
                new ProjectJobTokenScope("allowedProject-" + range.key(), ProjectJobTokenScopeArgs.builder()
                    .project(deploymentProject.id())
                    .targetProjectId(range.key())
                    .build());
            }
    
            for (var range : KeyedValue.of(com.pulumi.std.StdFunctions(com.pulumi.std.inputs.TosetArgs.builder()
                .input(allowedGroupIds)
                .build()).result())) {
                new ProjectJobTokenScope("allowedGroup-" + range.key(), ProjectJobTokenScopeArgs.builder()
                    .project(deploymentProject.id())
                    .targetGroupId(range.key())
                    .build());
            }
    
        }
    }
    
    resources:
      allowedSingleProject:
        type: gitlab:ProjectJobTokenScope
        name: allowed_single_project
        properties:
          project: gitlab-org/gitlab
          targetProjectId: 123
      allowedProject:
        type: gitlab:ProjectJobTokenScope
        name: allowed_project
        properties:
          project: ${deploymentProject.id}
          targetProjectId: ${range.key}
        options: {}
      allowedGroup:
        type: gitlab:ProjectJobTokenScope
        name: allowed_group
        properties:
          project: ${deploymentProject.id}
          targetGroupId: ${range.key}
        options: {}
    variables:
      allowedProjectIds:
        - 123
        - 456
        - 789
      allowedGroupIds:
        - 123
        - 456
        - 789
      deploymentProject:
        fn::invoke:
          function: gitlab:getProject
          arguments:
            name: example-project
    
    terraform {
      required_providers {
        gitlab = {
          source = "pulumi/gitlab"
        }
        std = {
          source = "pulumi/std"
        }
      }
    }
    
    data "gitlab_project" "deploymentProject" {
      name = "example-project"
    }
    
    resource "gitlab_project_job_token_scope" "allowed_single_project" {
      lifecycle {
        create_before_destroy = true
      }
      project           = "gitlab-org/gitlab"
      target_project_id = 123
    }
    resource "gitlab_project_job_token_scope" "allowed_project" {
      for_each = toset(local.allowedProjectIds)
      pulumi {
        name ="allowed_project-${each.key}"
      }
      lifecycle {
        create_before_destroy = true
      }
      project           = data.gitlab_project.deploymentProject.id
      target_project_id = each.key
    }
    resource "gitlab_project_job_token_scope" "allowed_group" {
      for_each = toset(local.allowedGroupIds)
      pulumi {
        name ="allowed_group-${each.key}"
      }
      lifecycle {
        create_before_destroy = true
      }
      project         = data.gitlab_project.deploymentProject.id
      target_group_id = each.key
    }
    locals {
      allowedProjectIds = [123, 456, 789]
    }
    locals {
      allowedGroupIds = [123, 456, 789]
    }
    

    Create ProjectJobTokenScope Resource

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

    Constructor syntax

    new ProjectJobTokenScope(name: string, args: ProjectJobTokenScopeArgs, opts?: CustomResourceOptions);
    @overload
    def ProjectJobTokenScope(resource_name: str,
                             args: ProjectJobTokenScopeArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def ProjectJobTokenScope(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             project: Optional[str] = None,
                             target_group_id: Optional[int] = None,
                             target_project_id: Optional[int] = None)
    func NewProjectJobTokenScope(ctx *Context, name string, args ProjectJobTokenScopeArgs, opts ...ResourceOption) (*ProjectJobTokenScope, error)
    public ProjectJobTokenScope(string name, ProjectJobTokenScopeArgs args, CustomResourceOptions? opts = null)
    public ProjectJobTokenScope(String name, ProjectJobTokenScopeArgs args)
    public ProjectJobTokenScope(String name, ProjectJobTokenScopeArgs args, CustomResourceOptions options)
    
    type: gitlab:ProjectJobTokenScope
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "gitlab_project_job_token_scope" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args ProjectJobTokenScopeArgs
    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 ProjectJobTokenScopeArgs
    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 ProjectJobTokenScopeArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ProjectJobTokenScopeArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ProjectJobTokenScopeArgs
    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 projectJobTokenScopeResource = new GitLab.ProjectJobTokenScope("projectJobTokenScopeResource", new()
    {
        Project = "string",
        TargetGroupId = 0,
        TargetProjectId = 0,
    });
    
    example, err := gitlab.NewProjectJobTokenScope(ctx, "projectJobTokenScopeResource", &gitlab.ProjectJobTokenScopeArgs{
    	Project:         pulumi.String("string"),
    	TargetGroupId:   pulumi.Int(0),
    	TargetProjectId: pulumi.Int(0),
    })
    
    resource "gitlab_project_job_token_scope" "projectJobTokenScopeResource" {
      lifecycle {
        create_before_destroy = true
      }
      project           = "string"
      target_group_id   = 0
      target_project_id = 0
    }
    
    var projectJobTokenScopeResource = new ProjectJobTokenScope("projectJobTokenScopeResource", ProjectJobTokenScopeArgs.builder()
        .project("string")
        .targetGroupId(0)
        .targetProjectId(0)
        .build());
    
    project_job_token_scope_resource = gitlab.ProjectJobTokenScope("projectJobTokenScopeResource",
        project="string",
        target_group_id=0,
        target_project_id=0)
    
    const projectJobTokenScopeResource = new gitlab.ProjectJobTokenScope("projectJobTokenScopeResource", {
        project: "string",
        targetGroupId: 0,
        targetProjectId: 0,
    });
    
    type: gitlab:ProjectJobTokenScope
    properties:
        project: string
        targetGroupId: 0
        targetProjectId: 0
    

    ProjectJobTokenScope 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 ProjectJobTokenScope resource accepts the following input properties:

    Project string
    The ID or full path of the project.
    TargetGroupId int
    The ID of the group that is in the CI/CD job token inbound allowlist.
    TargetProjectId int
    The ID of the project that is in the CI/CD job token inbound allowlist.
    Project string
    The ID or full path of the project.
    TargetGroupId int
    The ID of the group that is in the CI/CD job token inbound allowlist.
    TargetProjectId int
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project string
    The ID or full path of the project.
    target_group_id number
    The ID of the group that is in the CI/CD job token inbound allowlist.
    target_project_id number
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project String
    The ID or full path of the project.
    targetGroupId Integer
    The ID of the group that is in the CI/CD job token inbound allowlist.
    targetProjectId Integer
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project string
    The ID or full path of the project.
    targetGroupId number
    The ID of the group that is in the CI/CD job token inbound allowlist.
    targetProjectId number
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project str
    The ID or full path of the project.
    target_group_id int
    The ID of the group that is in the CI/CD job token inbound allowlist.
    target_project_id int
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project String
    The ID or full path of the project.
    targetGroupId Number
    The ID of the group that is in the CI/CD job token inbound allowlist.
    targetProjectId Number
    The ID of the project that is in the CI/CD job token inbound allowlist.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ProjectJobTokenScope 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 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 ProjectJobTokenScope Resource

    Get an existing ProjectJobTokenScope 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?: ProjectJobTokenScopeState, opts?: CustomResourceOptions): ProjectJobTokenScope
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            project: Optional[str] = None,
            target_group_id: Optional[int] = None,
            target_project_id: Optional[int] = None) -> ProjectJobTokenScope
    func GetProjectJobTokenScope(ctx *Context, name string, id IDInput, state *ProjectJobTokenScopeState, opts ...ResourceOption) (*ProjectJobTokenScope, error)
    public static ProjectJobTokenScope Get(string name, Input<string> id, ProjectJobTokenScopeState? state, CustomResourceOptions? opts = null)
    public static ProjectJobTokenScope get(String name, Output<String> id, ProjectJobTokenScopeState state, CustomResourceOptions options)
    resources:  _:    type: gitlab:ProjectJobTokenScope    get:      id: ${id}
    import {
      to = gitlab_project_job_token_scope.example
      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.
    The following state arguments are supported:
    Project string
    The ID or full path of the project.
    TargetGroupId int
    The ID of the group that is in the CI/CD job token inbound allowlist.
    TargetProjectId int
    The ID of the project that is in the CI/CD job token inbound allowlist.
    Project string
    The ID or full path of the project.
    TargetGroupId int
    The ID of the group that is in the CI/CD job token inbound allowlist.
    TargetProjectId int
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project string
    The ID or full path of the project.
    target_group_id number
    The ID of the group that is in the CI/CD job token inbound allowlist.
    target_project_id number
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project String
    The ID or full path of the project.
    targetGroupId Integer
    The ID of the group that is in the CI/CD job token inbound allowlist.
    targetProjectId Integer
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project string
    The ID or full path of the project.
    targetGroupId number
    The ID of the group that is in the CI/CD job token inbound allowlist.
    targetProjectId number
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project str
    The ID or full path of the project.
    target_group_id int
    The ID of the group that is in the CI/CD job token inbound allowlist.
    target_project_id int
    The ID of the project that is in the CI/CD job token inbound allowlist.
    project String
    The ID or full path of the project.
    targetGroupId Number
    The ID of the group that is in the CI/CD job token inbound allowlist.
    targetProjectId Number
    The ID of the project that is in the CI/CD job token inbound allowlist.

    Import

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

    Importing using the CLI is supported with the following syntax:

    GitLab project job token scopes can be imported using an id made up of projectId:type:targetId, for example:

    For target_project_id:

    $ pulumi import gitlab:index/projectJobTokenScope:ProjectJobTokenScope bar 123:project:321
    

    For target_group_id:

    $ pulumi import gitlab:index/projectJobTokenScope:ProjectJobTokenScope bar 123:group: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 gitlab Terraform Provider.
    gitlab logo
    Viewing docs for GitLab v10.4.1
    published on Saturday, Oct 31, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial