gitlab.ProjectVariable
Explore with Pulumi AI
The gitlab.ProjectVariable
resource allows to manage the lifecycle of a CI/CD variable for a project.
Important: If your GitLab version is older than 13.4, you may see nondeterministic behavior when updating or deleting gitlab.ProjectVariable resources with non-unique keys, for example if there is another variable with the same key and different environment scope. See this GitLab issue.
Upstream API: GitLab REST API docs
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
const example = new gitlab.ProjectVariable("example", {
project: "12345",
key: "project_variable_key",
value: "project_variable_value",
"protected": false,
});
import pulumi
import pulumi_gitlab as gitlab
example = gitlab.ProjectVariable("example",
project="12345",
key="project_variable_key",
value="project_variable_value",
protected=False)
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 {
_, err := gitlab.NewProjectVariable(ctx, "example", &gitlab.ProjectVariableArgs{
Project: pulumi.String("12345"),
Key: pulumi.String("project_variable_key"),
Value: pulumi.String("project_variable_value"),
Protected: pulumi.Bool(false),
})
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 example = new GitLab.ProjectVariable("example", new()
{
Project = "12345",
Key = "project_variable_key",
Value = "project_variable_value",
Protected = false,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
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 ProjectVariable("example", ProjectVariableArgs.builder()
.project("12345")
.key("project_variable_key")
.value("project_variable_value")
.protected_(false)
.build());
}
}
resources:
example:
type: gitlab:ProjectVariable
properties:
project: '12345'
key: project_variable_key
value: project_variable_value
protected: false
Create ProjectVariable Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ProjectVariable(name: string, args: ProjectVariableArgs, opts?: CustomResourceOptions);
@overload
def ProjectVariable(resource_name: str,
args: ProjectVariableArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ProjectVariable(resource_name: str,
opts: Optional[ResourceOptions] = None,
key: Optional[str] = None,
project: Optional[str] = None,
value: Optional[str] = None,
description: Optional[str] = None,
environment_scope: Optional[str] = None,
masked: Optional[bool] = None,
protected: Optional[bool] = None,
raw: Optional[bool] = None,
variable_type: Optional[str] = None)
func NewProjectVariable(ctx *Context, name string, args ProjectVariableArgs, opts ...ResourceOption) (*ProjectVariable, error)
public ProjectVariable(string name, ProjectVariableArgs args, CustomResourceOptions? opts = null)
public ProjectVariable(String name, ProjectVariableArgs args)
public ProjectVariable(String name, ProjectVariableArgs args, CustomResourceOptions options)
type: gitlab:ProjectVariable
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 ProjectVariableArgs
- 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 ProjectVariableArgs
- 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 ProjectVariableArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ProjectVariableArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ProjectVariableArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var projectVariableResource = new GitLab.ProjectVariable("projectVariableResource", new()
{
Key = "string",
Project = "string",
Value = "string",
Description = "string",
EnvironmentScope = "string",
Masked = false,
Protected = false,
Raw = false,
VariableType = "string",
});
example, err := gitlab.NewProjectVariable(ctx, "projectVariableResource", &gitlab.ProjectVariableArgs{
Key: pulumi.String("string"),
Project: pulumi.String("string"),
Value: pulumi.String("string"),
Description: pulumi.String("string"),
EnvironmentScope: pulumi.String("string"),
Masked: pulumi.Bool(false),
Protected: pulumi.Bool(false),
Raw: pulumi.Bool(false),
VariableType: pulumi.String("string"),
})
var projectVariableResource = new ProjectVariable("projectVariableResource", ProjectVariableArgs.builder()
.key("string")
.project("string")
.value("string")
.description("string")
.environmentScope("string")
.masked(false)
.protected_(false)
.raw(false)
.variableType("string")
.build());
project_variable_resource = gitlab.ProjectVariable("projectVariableResource",
key="string",
project="string",
value="string",
description="string",
environment_scope="string",
masked=False,
protected=False,
raw=False,
variable_type="string")
const projectVariableResource = new gitlab.ProjectVariable("projectVariableResource", {
key: "string",
project: "string",
value: "string",
description: "string",
environmentScope: "string",
masked: false,
"protected": false,
raw: false,
variableType: "string",
});
type: gitlab:ProjectVariable
properties:
description: string
environmentScope: string
key: string
masked: false
project: string
protected: false
raw: false
value: string
variableType: string
ProjectVariable Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The ProjectVariable resource accepts the following input properties:
- Key string
- The name of the variable.
- Project string
- The name or id of the project.
- Value string
- The value of the variable.
- Description string
- The description of the variable.
- Environment
Scope string - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - Masked bool
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - Protected bool
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - Raw bool
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- Variable
Type string - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- Key string
- The name of the variable.
- Project string
- The name or id of the project.
- Value string
- The value of the variable.
- Description string
- The description of the variable.
- Environment
Scope string - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - Masked bool
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - Protected bool
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - Raw bool
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- Variable
Type string - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- key String
- The name of the variable.
- project String
- The name or id of the project.
- value String
- The value of the variable.
- description String
- The description of the variable.
- environment
Scope String - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - masked Boolean
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - protected_ Boolean
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - raw Boolean
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- variable
Type String - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- key string
- The name of the variable.
- project string
- The name or id of the project.
- value string
- The value of the variable.
- description string
- The description of the variable.
- environment
Scope string - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - masked boolean
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - protected boolean
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - raw boolean
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- variable
Type string - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- key str
- The name of the variable.
- project str
- The name or id of the project.
- value str
- The value of the variable.
- description str
- The description of the variable.
- environment_
scope str - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - masked bool
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - protected bool
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - raw bool
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- variable_
type str - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- key String
- The name of the variable.
- project String
- The name or id of the project.
- value String
- The value of the variable.
- description String
- The description of the variable.
- environment
Scope String - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - masked Boolean
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - protected Boolean
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - raw Boolean
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- variable
Type String - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
Outputs
All input properties are implicitly available as output properties. Additionally, the ProjectVariable resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing ProjectVariable Resource
Get an existing ProjectVariable 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?: ProjectVariableState, opts?: CustomResourceOptions): ProjectVariable
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
description: Optional[str] = None,
environment_scope: Optional[str] = None,
key: Optional[str] = None,
masked: Optional[bool] = None,
project: Optional[str] = None,
protected: Optional[bool] = None,
raw: Optional[bool] = None,
value: Optional[str] = None,
variable_type: Optional[str] = None) -> ProjectVariable
func GetProjectVariable(ctx *Context, name string, id IDInput, state *ProjectVariableState, opts ...ResourceOption) (*ProjectVariable, error)
public static ProjectVariable Get(string name, Input<string> id, ProjectVariableState? state, CustomResourceOptions? opts = null)
public static ProjectVariable get(String name, Output<String> id, ProjectVariableState 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.
- Description string
- The description of the variable.
- Environment
Scope string - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - Key string
- The name of the variable.
- Masked bool
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - Project string
- The name or id of the project.
- Protected bool
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - Raw bool
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- Value string
- The value of the variable.
- Variable
Type string - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- Description string
- The description of the variable.
- Environment
Scope string - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - Key string
- The name of the variable.
- Masked bool
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - Project string
- The name or id of the project.
- Protected bool
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - Raw bool
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- Value string
- The value of the variable.
- Variable
Type string - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- description String
- The description of the variable.
- environment
Scope String - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - key String
- The name of the variable.
- masked Boolean
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - project String
- The name or id of the project.
- protected_ Boolean
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - raw Boolean
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- value String
- The value of the variable.
- variable
Type String - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- description string
- The description of the variable.
- environment
Scope string - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - key string
- The name of the variable.
- masked boolean
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - project string
- The name or id of the project.
- protected boolean
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - raw boolean
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- value string
- The value of the variable.
- variable
Type string - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- description str
- The description of the variable.
- environment_
scope str - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - key str
- The name of the variable.
- masked bool
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - project str
- The name or id of the project.
- protected bool
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - raw bool
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- value str
- The value of the variable.
- variable_
type str - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
- description String
- The description of the variable.
- environment
Scope String - The environment scope of the variable. Defaults to all environment (
*
). Note that in Community Editions of Gitlab, values other than*
will cause inconsistent plans. - key String
- The name of the variable.
- masked Boolean
- If set to
true
, the value of the variable will be hidden in job logs. The value must meet the masking requirements. Defaults tofalse
. - project String
- The name or id of the project.
- protected Boolean
- If set to
true
, the variable will be passed only to pipelines running on protected branches and tags. Defaults tofalse
. - raw Boolean
- Whether the variable is treated as a raw string. Default: false. When true, variables in the value are not expanded.
- value String
- The value of the variable.
- variable
Type String - The type of a variable. Valid values are:
env_var
,file
. Default isenv_var
.
Import
GitLab project variables can be imported using an id made up of project:key:environment_scope
, e.g.
$ pulumi import gitlab:index/projectVariable:ProjectVariable example '12345:project_variable_key:*'
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.