gitlab.ProjectAccessToken
Explore with Pulumi AI
The gitlab.ProjectAccessToken
resource allows to manage the lifecycle of a project access token.
Use of the
timestamp()
function with expires_at will cause the resource to be re-created with every apply, it’s recommended to useplantimestamp()
or a static value instead.
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)
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
})
}
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 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}
Create ProjectAccessToken Resource
new ProjectAccessToken(name: string, args: ProjectAccessTokenArgs, opts?: CustomResourceOptions);
@overload
def ProjectAccessToken(resource_name: str,
opts: Optional[ResourceOptions] = None,
access_level: Optional[str] = None,
expires_at: Optional[str] = None,
name: Optional[str] = None,
project: Optional[str] = None,
scopes: Optional[Sequence[str]] = None)
@overload
def ProjectAccessToken(resource_name: str,
args: ProjectAccessTokenArgs,
opts: Optional[ResourceOptions] = None)
func NewProjectAccessToken(ctx *Context, name string, args ProjectAccessTokenArgs, opts ...ResourceOption) (*ProjectAccessToken, error)
public ProjectAccessToken(string name, ProjectAccessTokenArgs args, CustomResourceOptions? opts = null)
public ProjectAccessToken(String name, ProjectAccessTokenArgs args)
public ProjectAccessToken(String name, ProjectAccessTokenArgs args, CustomResourceOptions options)
type: gitlab:ProjectAccessToken
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ProjectAccessTokenArgs
- 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 ProjectAccessTokenArgs
- 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 ProjectAccessTokenArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ProjectAccessTokenArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ProjectAccessTokenArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
ProjectAccessToken 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 ProjectAccessToken resource accepts the following input properties:
- Expires
At string - Time the token will expire it, YYYY-MM-DD format.
- Project string
- The id of the project to add the project access token to.
- Scopes List<string>
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - Access
Level string - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - Name string
- A name to describe the project access token.
- Expires
At string - Time the token will expire it, YYYY-MM-DD format.
- Project string
- The id of the project to add the project access token to.
- Scopes []string
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - Access
Level string - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - Name string
- A name to describe the project access token.
- expires
At String - Time the token will expire it, YYYY-MM-DD format.
- project String
- The id of the project to add the project access token to.
- scopes List<String>
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - access
Level String - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - name String
- A name to describe the project access token.
- expires
At string - Time the token will expire it, YYYY-MM-DD format.
- project string
- The id of the project to add the project access token to.
- scopes string[]
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - access
Level string - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - name string
- A name to describe the project access token.
- expires_
at str - Time the token will expire it, YYYY-MM-DD format.
- project str
- The id of the project to add the project access token to.
- scopes Sequence[str]
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - access_
level str - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - name str
- A name to describe the project access token.
- expires
At String - Time the token will expire it, YYYY-MM-DD format.
- project String
- The id of the project to add the project access token to.
- scopes List<String>
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - access
Level String - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - name String
- A name to describe the project access token.
Outputs
All input properties are implicitly available as output properties. Additionally, the ProjectAccessToken resource produces the following output properties:
- Active bool
- True if the token is active.
- Created
At 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 secret token. Note: the token is not available for imported resources.
- User
Id int - The user_id associated to the token.
- Active bool
- True if the token is active.
- Created
At 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 secret token. Note: the token is not available for imported resources.
- User
Id int - The user_id associated to the token.
- active Boolean
- True if the token is active.
- created
At 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 secret token. Note: the token is not available for imported resources.
- user
Id Integer - The user_id associated to the token.
- active boolean
- True if the token is active.
- created
At 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 secret token. Note: the token is not available for imported resources.
- user
Id number - The user_id associated to the token.
- 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 secret token. Note: the token is not available for imported resources.
- user_
id int - The user_id associated to the token.
- active Boolean
- True if the token is active.
- created
At 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 secret token. Note: the token is not available for imported resources.
- user
Id Number - The user_id associated to the token.
Look up Existing ProjectAccessToken Resource
Get an existing ProjectAccessToken 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?: ProjectAccessTokenState, opts?: CustomResourceOptions): ProjectAccessToken
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
access_level: Optional[str] = None,
active: Optional[bool] = None,
created_at: Optional[str] = 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,
user_id: Optional[int] = None) -> ProjectAccessToken
func GetProjectAccessToken(ctx *Context, name string, id IDInput, state *ProjectAccessTokenState, opts ...ResourceOption) (*ProjectAccessToken, error)
public static ProjectAccessToken Get(string name, Input<string> id, ProjectAccessTokenState? state, CustomResourceOptions? opts = null)
public static ProjectAccessToken get(String name, Output<String> id, ProjectAccessTokenState 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.
- Access
Level string - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - Active bool
- True if the token is active.
- Created
At string - Time the token has been created, RFC3339 format.
- Expires
At string - Time the token will expire it, YYYY-MM-DD format.
- Name string
- A name to describe the project access token.
- Project string
- The id of the project to add the project access token to.
- Revoked bool
- True if the token is revoked.
- Scopes List<string>
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - Token string
- The secret token. Note: the token is not available for imported resources.
- User
Id int - The user_id associated to the token.
- Access
Level string - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - Active bool
- True if the token is active.
- Created
At string - Time the token has been created, RFC3339 format.
- Expires
At string - Time the token will expire it, YYYY-MM-DD format.
- Name string
- A name to describe the project access token.
- Project string
- The id of the project to add the project access token to.
- Revoked bool
- True if the token is revoked.
- Scopes []string
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - Token string
- The secret token. Note: the token is not available for imported resources.
- User
Id int - The user_id associated to the token.
- access
Level String - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - active Boolean
- True if the token is active.
- created
At String - Time the token has been created, RFC3339 format.
- expires
At String - Time the token will expire it, YYYY-MM-DD format.
- name String
- A name to describe the project access token.
- project String
- The id of the project to add the project access token to.
- revoked Boolean
- True if the token is revoked.
- scopes List<String>
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - token String
- The secret token. Note: the token is not available for imported resources.
- user
Id Integer - The user_id associated to the token.
- access
Level string - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - active boolean
- True if the token is active.
- created
At string - Time the token has been created, RFC3339 format.
- expires
At string - Time the token will expire it, YYYY-MM-DD format.
- name string
- A name to describe the project access token.
- project string
- The id of the project to add the project access token to.
- revoked boolean
- True if the token is revoked.
- scopes string[]
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - token string
- The secret token. Note: the token is not available for imported resources.
- user
Id number - The user_id associated to the token.
- access_
level str - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - active bool
- True if the token is active.
- created_
at str - Time the token has been created, RFC3339 format.
- expires_
at str - Time the token will expire it, YYYY-MM-DD format.
- name str
- A name to describe the project access token.
- project str
- The id of the project to add the project access token to.
- revoked bool
- True if the token is revoked.
- scopes Sequence[str]
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - token str
- The secret token. Note: the token is not available for imported resources.
- user_
id int - The user_id associated to the token.
- access
Level String - The access level for the project access token. Valid values are:
no one
,minimal
,guest
,reporter
,developer
,maintainer
,owner
,master
. Default ismaintainer
. - active Boolean
- True if the token is active.
- created
At String - Time the token has been created, RFC3339 format.
- expires
At String - Time the token will expire it, YYYY-MM-DD format.
- name String
- A name to describe the project access token.
- project String
- The id of the project to add the project access token to.
- revoked Boolean
- True if the token is revoked.
- scopes List<String>
- The scope for the project access token. It determines the actions which can be performed when authenticating with this token. Valid values are:
api
,read_api
,read_registry
,write_registry
,read_repository
,write_repository
,create_runner
. - token String
- The secret token. Note: the token is not available for imported resources.
- user
Id Number - The user_id associated to the 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.
Package Details
- Repository
- GitLab pulumi/pulumi-gitlab
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
gitlab
Terraform Provider.