PersonalAccessToken

class PersonalAccessToken : KotlinCustomResource

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

This resource requires administration privileges. Use of the timestamp() function with expires_at will cause the resource to be re-created with every apply, it's recommended to use plantimestamp() or a static value instead. Observability scopes are in beta and may not work on all instances. See more details in the documentation Use rotation_configuration to automatically rotate tokens instead of using timestamp() as timestamp will cause changes with every plan. pulumi up must still be run to rotate the token. Due to Automatic reuse detection it's possible that a new Personal Access Token will immediately be revoked. Check if an old process using the old token is running if this happens. Upstream API: GitLab API docs

Example Usage

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

Import

Starting in Terraform v1.5.0 you can use an import block to import gitlab_personal_access_token. For example: terraform import { to = gitlab_personal_access_token.example id = "see CLI command below for ID" } Import using the CLI is supported using the following syntax: 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.

Properties

Link copied to clipboard
val active: Output<Boolean>

True if the token is active.

Link copied to clipboard
val createdAt: Output<String>

Time the token has been created, RFC3339 format.

Link copied to clipboard
val expiresAt: Output<String>

When the token will expire, YYYY-MM-DD format. Is automatically set when rotation_configuration is used.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val name: Output<String>

The name of the personal access token.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val revoked: Output<Boolean>

True if the token is revoked.

Link copied to clipboard

The configuration for when to rotate a token automatically. Will not rotate a token until pulumi up is run.

Link copied to clipboard
val scopes: Output<List<String>>

The scopes of the personal access token. valid values are: api, read_user, read_api, read_repository, write_repository, read_registry, write_registry, sudo, admin_mode, create_runner, manage_runner, ai_features, k8s_proxy, read_service_ping

Link copied to clipboard
val token: Output<String>

The token of the personal access token. Note: the token is not available for imported resources.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val userId: Output<Int>

The ID of the user.