Project Access Token
The gitlab.ProjectAccessToken
resource allows to manage the lifecycle of a project access token.
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 usingtimestamp()
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 Project 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 exampleProjectAccessToken = new gitlab.ProjectAccessToken("exampleProjectAccessToken", {
project: "25",
expiresAt: "2020-03-14",
accessLevel: "reporter",
scopes: ["api"],
});
const exampleProjectVariable = new gitlab.ProjectVariable("exampleProjectVariable", {
project: gitlab_project.example.id,
key: "pat",
value: exampleProjectAccessToken.token,
});
import pulumi
import pulumi_gitlab as gitlab
example_project_access_token = gitlab.ProjectAccessToken("exampleProjectAccessToken",
project="25",
expires_at="2020-03-14",
access_level="reporter",
scopes=["api"])
example_project_variable = gitlab.ProjectVariable("exampleProjectVariable",
project=gitlab_project["example"]["id"],
key="pat",
value=example_project_access_token.token)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using GitLab = Pulumi.GitLab;
return await Deployment.RunAsync(() =>
{
var exampleProjectAccessToken = new GitLab.ProjectAccessToken("exampleProjectAccessToken", new()
{
Project = "25",
ExpiresAt = "2020-03-14",
AccessLevel = "reporter",
Scopes = new[]
{
"api",
},
});
var exampleProjectVariable = new GitLab.ProjectVariable("exampleProjectVariable", new()
{
Project = gitlab_project.Example.Id,
Key = "pat",
Value = exampleProjectAccessToken.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 {
exampleProjectAccessToken, err := gitlab.NewProjectAccessToken(ctx, "exampleProjectAccessToken", &gitlab.ProjectAccessTokenArgs{
Project: pulumi.String("25"),
ExpiresAt: pulumi.String("2020-03-14"),
AccessLevel: pulumi.String("reporter"),
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: exampleProjectAccessToken.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.ProjectAccessToken;
import com.pulumi.gitlab.ProjectAccessTokenArgs;
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 exampleProjectAccessToken = new ProjectAccessToken("exampleProjectAccessToken", ProjectAccessTokenArgs.builder()
.project("25")
.expiresAt("2020-03-14")
.accessLevel("reporter")
.scopes("api")
.build());
var exampleProjectVariable = new ProjectVariable("exampleProjectVariable", ProjectVariableArgs.builder()
.project(gitlab_project.example().id())
.key("pat")
.value(exampleProjectAccessToken.token())
.build());
}
}
resources:
exampleProjectAccessToken:
type: gitlab:ProjectAccessToken
properties:
project: '25'
expiresAt: 2020-03-14
accessLevel: reporter
scopes:
- api
exampleProjectVariable:
type: gitlab:ProjectVariable
properties:
project: ${gitlab_project.example.id}
key: pat
value: ${exampleProjectAccessToken.token}
Import
A GitLab Project Access Token can be imported using a key composed of <project-id>:<token-id>
, e.g.
$ pulumi import gitlab:index/projectAccessToken:ProjectAccessToken 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
The access level for the project access token. Valid values are: no one
, minimal
, guest
, reporter
, developer
, maintainer
, owner
, master
. Default is maintainer
.
The configuration for when to rotate a token automatically. Will not rotate a token until pulumi up
is run.