1. Packages
  2. GitLab
  3. API Docs
  4. PersonalAccessToken
GitLab v6.11.0 published on Friday, Apr 19, 2024 by Pulumi

gitlab.PersonalAccessToken

Explore with Pulumi AI

gitlab logo
GitLab v6.11.0 published on Friday, Apr 19, 2024 by Pulumi

    The gitlab.PersonalAccessToken resource allows to manage the lifecycle of a personal access token for a specified user.

    This resource requires administration privileges.

    Upstream API: GitLab REST API docs

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gitlab from "@pulumi/gitlab";
    
    const examplePersonalAccessToken = new gitlab.PersonalAccessToken("examplePersonalAccessToken", {
        userId: 25,
        expiresAt: "2020-03-14",
        scopes: ["api"],
    });
    const exampleProjectVariable = new gitlab.ProjectVariable("exampleProjectVariable", {
        project: gitlab_project.example.id,
        key: "pat",
        value: examplePersonalAccessToken.token,
    });
    
    import pulumi
    import pulumi_gitlab as gitlab
    
    example_personal_access_token = gitlab.PersonalAccessToken("examplePersonalAccessToken",
        user_id=25,
        expires_at="2020-03-14",
        scopes=["api"])
    example_project_variable = gitlab.ProjectVariable("exampleProjectVariable",
        project=gitlab_project["example"]["id"],
        key="pat",
        value=example_personal_access_token.token)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gitlab/sdk/v6/go/gitlab"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		examplePersonalAccessToken, err := gitlab.NewPersonalAccessToken(ctx, "examplePersonalAccessToken", &gitlab.PersonalAccessTokenArgs{
    			UserId:    pulumi.Int(25),
    			ExpiresAt: pulumi.String("2020-03-14"),
    			Scopes: pulumi.StringArray{
    				pulumi.String("api"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = gitlab.NewProjectVariable(ctx, "exampleProjectVariable", &gitlab.ProjectVariableArgs{
    			Project: pulumi.Any(gitlab_project.Example.Id),
    			Key:     pulumi.String("pat"),
    			Value:   examplePersonalAccessToken.Token,
    		})
    		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 examplePersonalAccessToken = new GitLab.PersonalAccessToken("examplePersonalAccessToken", new()
        {
            UserId = 25,
            ExpiresAt = "2020-03-14",
            Scopes = new[]
            {
                "api",
            },
        });
    
        var exampleProjectVariable = new GitLab.ProjectVariable("exampleProjectVariable", new()
        {
            Project = gitlab_project.Example.Id,
            Key = "pat",
            Value = examplePersonalAccessToken.Token,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gitlab.PersonalAccessToken;
    import com.pulumi.gitlab.PersonalAccessTokenArgs;
    import com.pulumi.gitlab.ProjectVariable;
    import com.pulumi.gitlab.ProjectVariableArgs;
    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 examplePersonalAccessToken = new PersonalAccessToken("examplePersonalAccessToken", PersonalAccessTokenArgs.builder()        
                .userId("25")
                .expiresAt("2020-03-14")
                .scopes("api")
                .build());
    
            var exampleProjectVariable = new ProjectVariable("exampleProjectVariable", ProjectVariableArgs.builder()        
                .project(gitlab_project.example().id())
                .key("pat")
                .value(examplePersonalAccessToken.token())
                .build());
    
        }
    }
    
    resources:
      examplePersonalAccessToken:
        type: gitlab:PersonalAccessToken
        properties:
          userId: '25'
          expiresAt: 2020-03-14
          scopes:
            - api
      exampleProjectVariable:
        type: gitlab:ProjectVariable
        properties:
          project: ${gitlab_project.example.id}
          key: pat
          value: ${examplePersonalAccessToken.token}
    

    Create PersonalAccessToken Resource

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

    Constructor syntax

    new PersonalAccessToken(name: string, args: PersonalAccessTokenArgs, opts?: CustomResourceOptions);
    @overload
    def PersonalAccessToken(resource_name: str,
                            args: PersonalAccessTokenArgs,
                            opts: Optional[ResourceOptions] = None)
    
    @overload
    def PersonalAccessToken(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            expires_at: Optional[str] = None,
                            scopes: Optional[Sequence[str]] = None,
                            user_id: Optional[int] = None,
                            name: Optional[str] = None)
    func NewPersonalAccessToken(ctx *Context, name string, args PersonalAccessTokenArgs, opts ...ResourceOption) (*PersonalAccessToken, error)
    public PersonalAccessToken(string name, PersonalAccessTokenArgs args, CustomResourceOptions? opts = null)
    public PersonalAccessToken(String name, PersonalAccessTokenArgs args)
    public PersonalAccessToken(String name, PersonalAccessTokenArgs args, CustomResourceOptions options)
    
    type: gitlab:PersonalAccessToken
    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 PersonalAccessTokenArgs
    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 PersonalAccessTokenArgs
    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 PersonalAccessTokenArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PersonalAccessTokenArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args PersonalAccessTokenArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

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

    var personalAccessTokenResource = new GitLab.PersonalAccessToken("personalAccessTokenResource", new()
    {
        ExpiresAt = "string",
        Scopes = new[]
        {
            "string",
        },
        UserId = 0,
        Name = "string",
    });
    
    example, err := gitlab.NewPersonalAccessToken(ctx, "personalAccessTokenResource", &gitlab.PersonalAccessTokenArgs{
    	ExpiresAt: pulumi.String("string"),
    	Scopes: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	UserId: pulumi.Int(0),
    	Name:   pulumi.String("string"),
    })
    
    var personalAccessTokenResource = new PersonalAccessToken("personalAccessTokenResource", PersonalAccessTokenArgs.builder()        
        .expiresAt("string")
        .scopes("string")
        .userId(0)
        .name("string")
        .build());
    
    personal_access_token_resource = gitlab.PersonalAccessToken("personalAccessTokenResource",
        expires_at="string",
        scopes=["string"],
        user_id=0,
        name="string")
    
    const personalAccessTokenResource = new gitlab.PersonalAccessToken("personalAccessTokenResource", {
        expiresAt: "string",
        scopes: ["string"],
        userId: 0,
        name: "string",
    });
    
    type: gitlab:PersonalAccessToken
    properties:
        expiresAt: string
        name: string
        scopes:
            - string
        userId: 0
    

    PersonalAccessToken Resource Properties

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

    Inputs

    The PersonalAccessToken resource accepts the following input properties:

    ExpiresAt string
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    Scopes List<string>
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    UserId int
    The id of the user.
    Name string
    The name of the personal access token.
    ExpiresAt string
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    Scopes []string
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    UserId int
    The id of the user.
    Name string
    The name of the personal access token.
    expiresAt String
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    scopes List<String>
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    userId Integer
    The id of the user.
    name String
    The name of the personal access token.
    expiresAt string
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    scopes string[]
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    userId number
    The id of the user.
    name string
    The name of the personal access token.
    expires_at str
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    scopes Sequence[str]
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    user_id int
    The id of the user.
    name str
    The name of the personal access token.
    expiresAt String
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    scopes List<String>
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    userId Number
    The id of the user.
    name String
    The name of the personal access token.

    Outputs

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

    Active bool
    True if the token is active.
    CreatedAt string
    Time the token has been created, RFC3339 format.
    Id string
    The provider-assigned unique ID for this managed resource.
    Revoked bool
    True if the token is revoked.
    Token string
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    Active bool
    True if the token is active.
    CreatedAt string
    Time the token has been created, RFC3339 format.
    Id string
    The provider-assigned unique ID for this managed resource.
    Revoked bool
    True if the token is revoked.
    Token string
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    active Boolean
    True if the token is active.
    createdAt String
    Time the token has been created, RFC3339 format.
    id String
    The provider-assigned unique ID for this managed resource.
    revoked Boolean
    True if the token is revoked.
    token String
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    active boolean
    True if the token is active.
    createdAt string
    Time the token has been created, RFC3339 format.
    id string
    The provider-assigned unique ID for this managed resource.
    revoked boolean
    True if the token is revoked.
    token string
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    active bool
    True if the token is active.
    created_at str
    Time the token has been created, RFC3339 format.
    id str
    The provider-assigned unique ID for this managed resource.
    revoked bool
    True if the token is revoked.
    token str
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    active Boolean
    True if the token is active.
    createdAt String
    Time the token has been created, RFC3339 format.
    id String
    The provider-assigned unique ID for this managed resource.
    revoked Boolean
    True if the token is revoked.
    token String
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.

    Look up Existing PersonalAccessToken Resource

    Get an existing PersonalAccessToken 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?: PersonalAccessTokenState, opts?: CustomResourceOptions): PersonalAccessToken
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            active: Optional[bool] = None,
            created_at: Optional[str] = None,
            expires_at: Optional[str] = None,
            name: Optional[str] = None,
            revoked: Optional[bool] = None,
            scopes: Optional[Sequence[str]] = None,
            token: Optional[str] = None,
            user_id: Optional[int] = None) -> PersonalAccessToken
    func GetPersonalAccessToken(ctx *Context, name string, id IDInput, state *PersonalAccessTokenState, opts ...ResourceOption) (*PersonalAccessToken, error)
    public static PersonalAccessToken Get(string name, Input<string> id, PersonalAccessTokenState? state, CustomResourceOptions? opts = null)
    public static PersonalAccessToken get(String name, Output<String> id, PersonalAccessTokenState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    Active bool
    True if the token is active.
    CreatedAt string
    Time the token has been created, RFC3339 format.
    ExpiresAt string
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    Name string
    The name of the personal access token.
    Revoked bool
    True if the token is revoked.
    Scopes List<string>
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    Token string
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    UserId int
    The id of the user.
    Active bool
    True if the token is active.
    CreatedAt string
    Time the token has been created, RFC3339 format.
    ExpiresAt string
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    Name string
    The name of the personal access token.
    Revoked bool
    True if the token is revoked.
    Scopes []string
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    Token string
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    UserId int
    The id of the user.
    active Boolean
    True if the token is active.
    createdAt String
    Time the token has been created, RFC3339 format.
    expiresAt String
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    name String
    The name of the personal access token.
    revoked Boolean
    True if the token is revoked.
    scopes List<String>
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    token String
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    userId Integer
    The id of the user.
    active boolean
    True if the token is active.
    createdAt string
    Time the token has been created, RFC3339 format.
    expiresAt string
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    name string
    The name of the personal access token.
    revoked boolean
    True if the token is revoked.
    scopes string[]
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    token string
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    userId number
    The id of the user.
    active bool
    True if the token is active.
    created_at str
    Time the token has been created, RFC3339 format.
    expires_at str
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    name str
    The name of the personal access token.
    revoked bool
    True if the token is revoked.
    scopes Sequence[str]
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    token str
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    user_id int
    The id of the user.
    active Boolean
    True if the token is active.
    createdAt String
    Time the token has been created, RFC3339 format.
    expiresAt String
    The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.
    name String
    The name of the personal access token.
    revoked Boolean
    True if the token is revoked.
    scopes List<String>
    The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner.
    token String
    The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.
    userId Number
    The id of the user.

    Import

    A GitLab Personal Access Token can be imported using a key composed of <user-id>:<token-id>, e.g.

    $ pulumi import gitlab:index/personalAccessToken:PersonalAccessToken example "12345:1"
    

    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 v6.11.0 published on Friday, Apr 19, 2024 by Pulumi