Personal Access Token Args
data class PersonalAccessTokenArgs(val expiresAt: Output<String>? = null, val name: Output<String>? = null, val scopes: Output<List<String>>? = null, val userId: Output<Int>? = null) : ConvertibleToJava<PersonalAccessTokenArgs>
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,
});
Content copied to clipboard
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)
Content copied to clipboard
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,
});
});
Content copied to clipboard
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
})
}
Content copied to clipboard
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());
}
}
Content copied to clipboard
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}
Content copied to clipboard
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"
Content copied to clipboard
NOTE: the token
resource attribute is not available for imported resources as this information cannot be read from the GitLab API.