1. Packages
  2. Gitlab Provider
  3. API Docs
  4. ProjectDeployToken
GitLab v9.3.0 published on Monday, Sep 29, 2025 by Pulumi

gitlab.ProjectDeployToken

Explore with Pulumi AI

gitlab logo
GitLab v9.3.0 published on Monday, Sep 29, 2025 by Pulumi

    The gitlab.ProjectDeployToken resource allows you to manage the lifecycle of deploy tokens on a project.

    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";
    
    // Example Usage
    const example = new gitlab.ProjectDeployToken("example", {
        project: "example/deploying",
        name: "Example project deploy token",
        username: "example-username",
        expiresAt: "2020-03-14T00:00:00.000Z",
        scopes: [
            "read_repository",
            "read_registry",
        ],
    });
    const example_two = new gitlab.ProjectDeployToken("example-two", {
        project: "12345678",
        name: "Example project deploy token expires in 24h",
        expiresAt: std.timestamp({}).then(invoke => std.timeadd({
            duration: invoke.result,
            timestamp: "24h",
        })).then(invoke => invoke.result),
        scopes: [
            "read_repository",
            "read_registry",
        ],
    });
    
    import pulumi
    import pulumi_gitlab as gitlab
    import pulumi_std as std
    
    # Example Usage
    example = gitlab.ProjectDeployToken("example",
        project="example/deploying",
        name="Example project deploy token",
        username="example-username",
        expires_at="2020-03-14T00:00:00.000Z",
        scopes=[
            "read_repository",
            "read_registry",
        ])
    example_two = gitlab.ProjectDeployToken("example-two",
        project="12345678",
        name="Example project deploy token expires in 24h",
        expires_at=std.timeadd(duration=std.timestamp().result,
            timestamp="24h").result,
        scopes=[
            "read_repository",
            "read_registry",
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gitlab/sdk/v9/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 {
    		// Example Usage
    		_, err := gitlab.NewProjectDeployToken(ctx, "example", &gitlab.ProjectDeployTokenArgs{
    			Project:   pulumi.String("example/deploying"),
    			Name:      pulumi.String("Example project deploy token"),
    			Username:  pulumi.String("example-username"),
    			ExpiresAt: pulumi.String("2020-03-14T00:00:00.000Z"),
    			Scopes: pulumi.StringArray{
    				pulumi.String("read_repository"),
    				pulumi.String("read_registry"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		invokeTimeadd, err := std.Timeadd(ctx, &std.TimeaddArgs{
    			Duration:  std.Timestamp(ctx, &std.TimestampArgs{}, nil).Result,
    			Timestamp: "24h",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = gitlab.NewProjectDeployToken(ctx, "example-two", &gitlab.ProjectDeployTokenArgs{
    			Project:   pulumi.String("12345678"),
    			Name:      pulumi.String("Example project deploy token expires in 24h"),
    			ExpiresAt: pulumi.String(invokeTimeadd.Result),
    			Scopes: pulumi.StringArray{
    				pulumi.String("read_repository"),
    				pulumi.String("read_registry"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using GitLab = Pulumi.GitLab;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(() => 
    {
        // Example Usage
        var example = new GitLab.ProjectDeployToken("example", new()
        {
            Project = "example/deploying",
            Name = "Example project deploy token",
            Username = "example-username",
            ExpiresAt = "2020-03-14T00:00:00.000Z",
            Scopes = new[]
            {
                "read_repository",
                "read_registry",
            },
        });
    
        var example_two = new GitLab.ProjectDeployToken("example-two", new()
        {
            Project = "12345678",
            Name = "Example project deploy token expires in 24h",
            ExpiresAt = Std.Timestamp.Invoke().Apply(invoke => Std.Timeadd.Invoke(new()
            {
                Duration = invoke.Result,
                Timestamp = "24h",
            })).Apply(invoke => invoke.Result),
            Scopes = new[]
            {
                "read_repository",
                "read_registry",
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gitlab.ProjectDeployToken;
    import com.pulumi.gitlab.ProjectDeployTokenArgs;
    import com.pulumi.std.StdFunctions;
    import com.pulumi.std.inputs.TimestampArgs;
    import com.pulumi.std.inputs.TimeaddArgs;
    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) {
            // Example Usage
            var example = new ProjectDeployToken("example", ProjectDeployTokenArgs.builder()
                .project("example/deploying")
                .name("Example project deploy token")
                .username("example-username")
                .expiresAt("2020-03-14T00:00:00.000Z")
                .scopes(            
                    "read_repository",
                    "read_registry")
                .build());
    
            var example_two = new ProjectDeployToken("example-two", ProjectDeployTokenArgs.builder()
                .project("12345678")
                .name("Example project deploy token expires in 24h")
                .expiresAt(StdFunctions.timeadd(TimeaddArgs.builder()
                    .duration(StdFunctions.timestamp(TimestampArgs.builder()
                        .build()).result())
                    .timestamp("24h")
                    .build()).result())
                .scopes(            
                    "read_repository",
                    "read_registry")
                .build());
    
        }
    }
    
    resources:
      # Example Usage
      example:
        type: gitlab:ProjectDeployToken
        properties:
          project: example/deploying
          name: Example project deploy token
          username: example-username
          expiresAt: 2020-03-14T00:00:00.000Z
          scopes:
            - read_repository
            - read_registry
      example-two:
        type: gitlab:ProjectDeployToken
        properties:
          project: '12345678'
          name: Example project deploy token expires in 24h
          expiresAt:
            fn::invoke:
              function: std:timeadd
              arguments:
                duration:
                  fn::invoke:
                    function: std:timestamp
                    arguments: {}
                    return: result
                timestamp: 24h
              return: result
          scopes:
            - read_repository
            - read_registry
    

    Create ProjectDeployToken Resource

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

    Constructor syntax

    new ProjectDeployToken(name: string, args: ProjectDeployTokenArgs, opts?: CustomResourceOptions);
    @overload
    def ProjectDeployToken(resource_name: str,
                           args: ProjectDeployTokenArgs,
                           opts: Optional[ResourceOptions] = None)
    
    @overload
    def ProjectDeployToken(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           project: Optional[str] = None,
                           scopes: Optional[Sequence[str]] = None,
                           expires_at: Optional[str] = None,
                           name: Optional[str] = None,
                           username: Optional[str] = None)
    func NewProjectDeployToken(ctx *Context, name string, args ProjectDeployTokenArgs, opts ...ResourceOption) (*ProjectDeployToken, error)
    public ProjectDeployToken(string name, ProjectDeployTokenArgs args, CustomResourceOptions? opts = null)
    public ProjectDeployToken(String name, ProjectDeployTokenArgs args)
    public ProjectDeployToken(String name, ProjectDeployTokenArgs args, CustomResourceOptions options)
    
    type: gitlab:ProjectDeployToken
    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 ProjectDeployTokenArgs
    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 ProjectDeployTokenArgs
    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 ProjectDeployTokenArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ProjectDeployTokenArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ProjectDeployTokenArgs
    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 projectDeployTokenResource = new GitLab.ProjectDeployToken("projectDeployTokenResource", new()
    {
        Project = "string",
        Scopes = new[]
        {
            "string",
        },
        ExpiresAt = "string",
        Name = "string",
        Username = "string",
    });
    
    example, err := gitlab.NewProjectDeployToken(ctx, "projectDeployTokenResource", &gitlab.ProjectDeployTokenArgs{
    	Project: pulumi.String("string"),
    	Scopes: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	ExpiresAt: pulumi.String("string"),
    	Name:      pulumi.String("string"),
    	Username:  pulumi.String("string"),
    })
    
    var projectDeployTokenResource = new ProjectDeployToken("projectDeployTokenResource", ProjectDeployTokenArgs.builder()
        .project("string")
        .scopes("string")
        .expiresAt("string")
        .name("string")
        .username("string")
        .build());
    
    project_deploy_token_resource = gitlab.ProjectDeployToken("projectDeployTokenResource",
        project="string",
        scopes=["string"],
        expires_at="string",
        name="string",
        username="string")
    
    const projectDeployTokenResource = new gitlab.ProjectDeployToken("projectDeployTokenResource", {
        project: "string",
        scopes: ["string"],
        expiresAt: "string",
        name: "string",
        username: "string",
    });
    
    type: gitlab:ProjectDeployToken
    properties:
        expiresAt: string
        name: string
        project: string
        scopes:
            - string
        username: string
    

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

    Project string
    The Id or full path of the project.
    Scopes List<string>
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    ExpiresAt string
    Time the token expires in RFC3339 format. Not set by default.
    Name string
    A name to describe the deploy token with.
    Username string
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    Project string
    The Id or full path of the project.
    Scopes []string
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    ExpiresAt string
    Time the token expires in RFC3339 format. Not set by default.
    Name string
    A name to describe the deploy token with.
    Username string
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    project String
    The Id or full path of the project.
    scopes List<String>
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    expiresAt String
    Time the token expires in RFC3339 format. Not set by default.
    name String
    A name to describe the deploy token with.
    username String
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    project string
    The Id or full path of the project.
    scopes string[]
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    expiresAt string
    Time the token expires in RFC3339 format. Not set by default.
    name string
    A name to describe the deploy token with.
    username string
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    project str
    The Id or full path of the project.
    scopes Sequence[str]
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    expires_at str
    Time the token expires in RFC3339 format. Not set by default.
    name str
    A name to describe the deploy token with.
    username str
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    project String
    The Id or full path of the project.
    scopes List<String>
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    expiresAt String
    Time the token expires in RFC3339 format. Not set by default.
    name String
    A name to describe the deploy token with.
    username String
    A username for the deploy token. Default is gitlab+deploy-token-{n}.

    Outputs

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

    Expired bool
    True if the token is expired.
    Id string
    The provider-assigned unique ID for this managed resource.
    Revoked bool
    True if the token is revoked.
    Token string
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    Expired bool
    True if the token is expired.
    Id string
    The provider-assigned unique ID for this managed resource.
    Revoked bool
    True if the token is revoked.
    Token string
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    expired Boolean
    True if the token is expired.
    id String
    The provider-assigned unique ID for this managed resource.
    revoked Boolean
    True if the token is revoked.
    token String
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    expired boolean
    True if the token is expired.
    id string
    The provider-assigned unique ID for this managed resource.
    revoked boolean
    True if the token is revoked.
    token string
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    expired bool
    True if the token is expired.
    id str
    The provider-assigned unique ID for this managed resource.
    revoked bool
    True if the token is revoked.
    token str
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    expired Boolean
    True if the token is expired.
    id String
    The provider-assigned unique ID for this managed resource.
    revoked Boolean
    True if the token is revoked.
    token String
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.

    Look up Existing ProjectDeployToken Resource

    Get an existing ProjectDeployToken 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?: ProjectDeployTokenState, opts?: CustomResourceOptions): ProjectDeployToken
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            expired: Optional[bool] = None,
            expires_at: Optional[str] = None,
            name: Optional[str] = None,
            project: Optional[str] = None,
            revoked: Optional[bool] = None,
            scopes: Optional[Sequence[str]] = None,
            token: Optional[str] = None,
            username: Optional[str] = None) -> ProjectDeployToken
    func GetProjectDeployToken(ctx *Context, name string, id IDInput, state *ProjectDeployTokenState, opts ...ResourceOption) (*ProjectDeployToken, error)
    public static ProjectDeployToken Get(string name, Input<string> id, ProjectDeployTokenState? state, CustomResourceOptions? opts = null)
    public static ProjectDeployToken get(String name, Output<String> id, ProjectDeployTokenState state, CustomResourceOptions options)
    resources:  _:    type: gitlab:ProjectDeployToken    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.
    The following state arguments are supported:
    Expired bool
    True if the token is expired.
    ExpiresAt string
    Time the token expires in RFC3339 format. Not set by default.
    Name string
    A name to describe the deploy token with.
    Project string
    The Id or full path of the project.
    Revoked bool
    True if the token is revoked.
    Scopes List<string>
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    Token string
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    Username string
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    Expired bool
    True if the token is expired.
    ExpiresAt string
    Time the token expires in RFC3339 format. Not set by default.
    Name string
    A name to describe the deploy token with.
    Project string
    The Id or full path of the project.
    Revoked bool
    True if the token is revoked.
    Scopes []string
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    Token string
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    Username string
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    expired Boolean
    True if the token is expired.
    expiresAt String
    Time the token expires in RFC3339 format. Not set by default.
    name String
    A name to describe the deploy token with.
    project String
    The Id or full path of the project.
    revoked Boolean
    True if the token is revoked.
    scopes List<String>
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    token String
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    username String
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    expired boolean
    True if the token is expired.
    expiresAt string
    Time the token expires in RFC3339 format. Not set by default.
    name string
    A name to describe the deploy token with.
    project string
    The Id or full path of the project.
    revoked boolean
    True if the token is revoked.
    scopes string[]
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    token string
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    username string
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    expired bool
    True if the token is expired.
    expires_at str
    Time the token expires in RFC3339 format. Not set by default.
    name str
    A name to describe the deploy token with.
    project str
    The Id or full path of the project.
    revoked bool
    True if the token is revoked.
    scopes Sequence[str]
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    token str
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    username str
    A username for the deploy token. Default is gitlab+deploy-token-{n}.
    expired Boolean
    True if the token is expired.
    expiresAt String
    Time the token expires in RFC3339 format. Not set by default.
    name String
    A name to describe the deploy token with.
    project String
    The Id or full path of the project.
    revoked Boolean
    True if the token is revoked.
    scopes List<String>
    The scopes of the project deploy token. Valid values are: read_repository, read_registry, write_registry, read_virtual_registry, write_virtual_registry, read_package_registry, write_package_registry
    token String
    The secret token. This is only populated when creating a new deploy token. Note: The token is not available for imported resources.
    username String
    A username for the deploy token. Default is gitlab+deploy-token-{n}.

    Import

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

    terraform

    import {

    to = gitlab_project_deploy_token.example

    id = “see CLI command below for ID”

    }

    Importing using the CLI is supported with the following syntax:

    GitLab project deploy tokens can be imported using an id made up of {project_id}:{deploy_token_id}.

    $ pulumi import gitlab:index/projectDeployToken:ProjectDeployToken project_token 1:4
    

    Note: the token resource attribute is not available for imported resources as this information cannot be read from the GitLab API.

    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
    GitLab v9.3.0 published on Monday, Sep 29, 2025 by Pulumi
      AI Agentic Workflows: Register now