1. Packages
  2. Vercel
  3. API Docs
  4. ProjectEnvironmentVariable
Vercel v1.11.0 published on Thursday, May 23, 2024 by Pulumiverse

vercel.ProjectEnvironmentVariable

Explore with Pulumi AI

vercel logo
Vercel v1.11.0 published on Thursday, May 23, 2024 by Pulumiverse

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as vercel from "@pulumiverse/vercel";
    
    const exampleProject = new vercel.Project("exampleProject", {gitRepository: {
        type: "github",
        repo: "vercel/some-repo",
    }});
    // An environment variable that will be created
    // for this project for the "production" environment.
    const exampleProjectEnvironmentVariable = new vercel.ProjectEnvironmentVariable("exampleProjectEnvironmentVariable", {
        projectId: exampleProject.id,
        key: "foo",
        value: "bar",
        targets: ["production"],
    });
    // An environment variable that will be created
    // for this project for the "preview" environment when the branch is "staging".
    const exampleGitBranch = new vercel.ProjectEnvironmentVariable("exampleGitBranch", {
        projectId: exampleProject.id,
        key: "foo",
        value: "bar-staging",
        targets: ["preview"],
        gitBranch: "staging",
    });
    // A sensitive environment variable that will be created
    // for this project for the "production" environment.
    const exampleSensitive = new vercel.ProjectEnvironmentVariable("exampleSensitive", {
        projectId: exampleProject.id,
        key: "foo",
        value: "bar-production",
        targets: ["production"],
        sensitive: true,
    });
    
    import pulumi
    import pulumiverse_vercel as vercel
    
    example_project = vercel.Project("exampleProject", git_repository=vercel.ProjectGitRepositoryArgs(
        type="github",
        repo="vercel/some-repo",
    ))
    # An environment variable that will be created
    # for this project for the "production" environment.
    example_project_environment_variable = vercel.ProjectEnvironmentVariable("exampleProjectEnvironmentVariable",
        project_id=example_project.id,
        key="foo",
        value="bar",
        targets=["production"])
    # An environment variable that will be created
    # for this project for the "preview" environment when the branch is "staging".
    example_git_branch = vercel.ProjectEnvironmentVariable("exampleGitBranch",
        project_id=example_project.id,
        key="foo",
        value="bar-staging",
        targets=["preview"],
        git_branch="staging")
    # A sensitive environment variable that will be created
    # for this project for the "production" environment.
    example_sensitive = vercel.ProjectEnvironmentVariable("exampleSensitive",
        project_id=example_project.id,
        key="foo",
        value="bar-production",
        targets=["production"],
        sensitive=True)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-vercel/sdk/go/vercel"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleProject, err := vercel.NewProject(ctx, "exampleProject", &vercel.ProjectArgs{
    			GitRepository: &vercel.ProjectGitRepositoryArgs{
    				Type: pulumi.String("github"),
    				Repo: pulumi.String("vercel/some-repo"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// An environment variable that will be created
    		// for this project for the "production" environment.
    		_, err = vercel.NewProjectEnvironmentVariable(ctx, "exampleProjectEnvironmentVariable", &vercel.ProjectEnvironmentVariableArgs{
    			ProjectId: exampleProject.ID(),
    			Key:       pulumi.String("foo"),
    			Value:     pulumi.String("bar"),
    			Targets: pulumi.StringArray{
    				pulumi.String("production"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// An environment variable that will be created
    		// for this project for the "preview" environment when the branch is "staging".
    		_, err = vercel.NewProjectEnvironmentVariable(ctx, "exampleGitBranch", &vercel.ProjectEnvironmentVariableArgs{
    			ProjectId: exampleProject.ID(),
    			Key:       pulumi.String("foo"),
    			Value:     pulumi.String("bar-staging"),
    			Targets: pulumi.StringArray{
    				pulumi.String("preview"),
    			},
    			GitBranch: pulumi.String("staging"),
    		})
    		if err != nil {
    			return err
    		}
    		// A sensitive environment variable that will be created
    		// for this project for the "production" environment.
    		_, err = vercel.NewProjectEnvironmentVariable(ctx, "exampleSensitive", &vercel.ProjectEnvironmentVariableArgs{
    			ProjectId: exampleProject.ID(),
    			Key:       pulumi.String("foo"),
    			Value:     pulumi.String("bar-production"),
    			Targets: pulumi.StringArray{
    				pulumi.String("production"),
    			},
    			Sensitive: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Vercel = Pulumiverse.Vercel;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleProject = new Vercel.Project("exampleProject", new()
        {
            GitRepository = new Vercel.Inputs.ProjectGitRepositoryArgs
            {
                Type = "github",
                Repo = "vercel/some-repo",
            },
        });
    
        // An environment variable that will be created
        // for this project for the "production" environment.
        var exampleProjectEnvironmentVariable = new Vercel.ProjectEnvironmentVariable("exampleProjectEnvironmentVariable", new()
        {
            ProjectId = exampleProject.Id,
            Key = "foo",
            Value = "bar",
            Targets = new[]
            {
                "production",
            },
        });
    
        // An environment variable that will be created
        // for this project for the "preview" environment when the branch is "staging".
        var exampleGitBranch = new Vercel.ProjectEnvironmentVariable("exampleGitBranch", new()
        {
            ProjectId = exampleProject.Id,
            Key = "foo",
            Value = "bar-staging",
            Targets = new[]
            {
                "preview",
            },
            GitBranch = "staging",
        });
    
        // A sensitive environment variable that will be created
        // for this project for the "production" environment.
        var exampleSensitive = new Vercel.ProjectEnvironmentVariable("exampleSensitive", new()
        {
            ProjectId = exampleProject.Id,
            Key = "foo",
            Value = "bar-production",
            Targets = new[]
            {
                "production",
            },
            Sensitive = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.vercel.Project;
    import com.pulumi.vercel.ProjectArgs;
    import com.pulumi.vercel.inputs.ProjectGitRepositoryArgs;
    import com.pulumi.vercel.ProjectEnvironmentVariable;
    import com.pulumi.vercel.ProjectEnvironmentVariableArgs;
    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 exampleProject = new Project("exampleProject", ProjectArgs.builder()        
                .gitRepository(ProjectGitRepositoryArgs.builder()
                    .type("github")
                    .repo("vercel/some-repo")
                    .build())
                .build());
    
            // An environment variable that will be created
            // for this project for the "production" environment.
            var exampleProjectEnvironmentVariable = new ProjectEnvironmentVariable("exampleProjectEnvironmentVariable", ProjectEnvironmentVariableArgs.builder()        
                .projectId(exampleProject.id())
                .key("foo")
                .value("bar")
                .targets("production")
                .build());
    
            // An environment variable that will be created
            // for this project for the "preview" environment when the branch is "staging".
            var exampleGitBranch = new ProjectEnvironmentVariable("exampleGitBranch", ProjectEnvironmentVariableArgs.builder()        
                .projectId(exampleProject.id())
                .key("foo")
                .value("bar-staging")
                .targets("preview")
                .gitBranch("staging")
                .build());
    
            // A sensitive environment variable that will be created
            // for this project for the "production" environment.
            var exampleSensitive = new ProjectEnvironmentVariable("exampleSensitive", ProjectEnvironmentVariableArgs.builder()        
                .projectId(exampleProject.id())
                .key("foo")
                .value("bar-production")
                .targets("production")
                .sensitive(true)
                .build());
    
        }
    }
    
    resources:
      exampleProject:
        type: vercel:Project
        properties:
          gitRepository:
            type: github
            repo: vercel/some-repo
      # An environment variable that will be created
      # for this project for the "production" environment.
      exampleProjectEnvironmentVariable:
        type: vercel:ProjectEnvironmentVariable
        properties:
          projectId: ${exampleProject.id}
          key: foo
          value: bar
          targets:
            - production
      # An environment variable that will be created
      # for this project for the "preview" environment when the branch is "staging".
      exampleGitBranch:
        type: vercel:ProjectEnvironmentVariable
        properties:
          projectId: ${exampleProject.id}
          key: foo
          value: bar-staging
          targets:
            - preview
          gitBranch: staging
      # A sensitive environment variable that will be created
      # for this project for the "production" environment.
      exampleSensitive:
        type: vercel:ProjectEnvironmentVariable
        properties:
          projectId: ${exampleProject.id}
          key: foo
          value: bar-production
          targets:
            - production
          sensitive: true
    

    Create ProjectEnvironmentVariable Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ProjectEnvironmentVariable(name: string, args: ProjectEnvironmentVariableArgs, opts?: CustomResourceOptions);
    @overload
    def ProjectEnvironmentVariable(resource_name: str,
                                   args: ProjectEnvironmentVariableArgs,
                                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def ProjectEnvironmentVariable(resource_name: str,
                                   opts: Optional[ResourceOptions] = None,
                                   key: Optional[str] = None,
                                   project_id: Optional[str] = None,
                                   targets: Optional[Sequence[str]] = None,
                                   value: Optional[str] = None,
                                   git_branch: Optional[str] = None,
                                   sensitive: Optional[bool] = None,
                                   team_id: Optional[str] = None)
    func NewProjectEnvironmentVariable(ctx *Context, name string, args ProjectEnvironmentVariableArgs, opts ...ResourceOption) (*ProjectEnvironmentVariable, error)
    public ProjectEnvironmentVariable(string name, ProjectEnvironmentVariableArgs args, CustomResourceOptions? opts = null)
    public ProjectEnvironmentVariable(String name, ProjectEnvironmentVariableArgs args)
    public ProjectEnvironmentVariable(String name, ProjectEnvironmentVariableArgs args, CustomResourceOptions options)
    
    type: vercel:ProjectEnvironmentVariable
    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 ProjectEnvironmentVariableArgs
    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 ProjectEnvironmentVariableArgs
    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 ProjectEnvironmentVariableArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ProjectEnvironmentVariableArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ProjectEnvironmentVariableArgs
    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 projectEnvironmentVariableResource = new Vercel.ProjectEnvironmentVariable("projectEnvironmentVariableResource", new()
    {
        Key = "string",
        ProjectId = "string",
        Targets = new[]
        {
            "string",
        },
        Value = "string",
        GitBranch = "string",
        Sensitive = false,
        TeamId = "string",
    });
    
    example, err := vercel.NewProjectEnvironmentVariable(ctx, "projectEnvironmentVariableResource", &vercel.ProjectEnvironmentVariableArgs{
    	Key:       pulumi.String("string"),
    	ProjectId: pulumi.String("string"),
    	Targets: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Value:     pulumi.String("string"),
    	GitBranch: pulumi.String("string"),
    	Sensitive: pulumi.Bool(false),
    	TeamId:    pulumi.String("string"),
    })
    
    var projectEnvironmentVariableResource = new ProjectEnvironmentVariable("projectEnvironmentVariableResource", ProjectEnvironmentVariableArgs.builder()
        .key("string")
        .projectId("string")
        .targets("string")
        .value("string")
        .gitBranch("string")
        .sensitive(false)
        .teamId("string")
        .build());
    
    project_environment_variable_resource = vercel.ProjectEnvironmentVariable("projectEnvironmentVariableResource",
        key="string",
        project_id="string",
        targets=["string"],
        value="string",
        git_branch="string",
        sensitive=False,
        team_id="string")
    
    const projectEnvironmentVariableResource = new vercel.ProjectEnvironmentVariable("projectEnvironmentVariableResource", {
        key: "string",
        projectId: "string",
        targets: ["string"],
        value: "string",
        gitBranch: "string",
        sensitive: false,
        teamId: "string",
    });
    
    type: vercel:ProjectEnvironmentVariable
    properties:
        gitBranch: string
        key: string
        projectId: string
        sensitive: false
        targets:
            - string
        teamId: string
        value: string
    

    ProjectEnvironmentVariable 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 ProjectEnvironmentVariable resource accepts the following input properties:

    Key string
    The name of the Environment Variable.
    ProjectId string
    The ID of the Vercel project.
    Targets List<string>
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    Value string
    The value of the Environment Variable.
    GitBranch string
    The git branch of the Environment Variable.
    Sensitive bool
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    TeamId string
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    Key string
    The name of the Environment Variable.
    ProjectId string
    The ID of the Vercel project.
    Targets []string
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    Value string
    The value of the Environment Variable.
    GitBranch string
    The git branch of the Environment Variable.
    Sensitive bool
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    TeamId string
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    key String
    The name of the Environment Variable.
    projectId String
    The ID of the Vercel project.
    targets List<String>
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    value String
    The value of the Environment Variable.
    gitBranch String
    The git branch of the Environment Variable.
    sensitive Boolean
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    teamId String
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    key string
    The name of the Environment Variable.
    projectId string
    The ID of the Vercel project.
    targets string[]
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    value string
    The value of the Environment Variable.
    gitBranch string
    The git branch of the Environment Variable.
    sensitive boolean
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    teamId string
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    key str
    The name of the Environment Variable.
    project_id str
    The ID of the Vercel project.
    targets Sequence[str]
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    value str
    The value of the Environment Variable.
    git_branch str
    The git branch of the Environment Variable.
    sensitive bool
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    team_id str
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    key String
    The name of the Environment Variable.
    projectId String
    The ID of the Vercel project.
    targets List<String>
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    value String
    The value of the Environment Variable.
    gitBranch String
    The git branch of the Environment Variable.
    sensitive Boolean
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    teamId String
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ProjectEnvironmentVariable 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 ProjectEnvironmentVariable Resource

    Get an existing ProjectEnvironmentVariable 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?: ProjectEnvironmentVariableState, opts?: CustomResourceOptions): ProjectEnvironmentVariable
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            git_branch: Optional[str] = None,
            key: Optional[str] = None,
            project_id: Optional[str] = None,
            sensitive: Optional[bool] = None,
            targets: Optional[Sequence[str]] = None,
            team_id: Optional[str] = None,
            value: Optional[str] = None) -> ProjectEnvironmentVariable
    func GetProjectEnvironmentVariable(ctx *Context, name string, id IDInput, state *ProjectEnvironmentVariableState, opts ...ResourceOption) (*ProjectEnvironmentVariable, error)
    public static ProjectEnvironmentVariable Get(string name, Input<string> id, ProjectEnvironmentVariableState? state, CustomResourceOptions? opts = null)
    public static ProjectEnvironmentVariable get(String name, Output<String> id, ProjectEnvironmentVariableState 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.
    The following state arguments are supported:
    GitBranch string
    The git branch of the Environment Variable.
    Key string
    The name of the Environment Variable.
    ProjectId string
    The ID of the Vercel project.
    Sensitive bool
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    Targets List<string>
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    TeamId string
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    Value string
    The value of the Environment Variable.
    GitBranch string
    The git branch of the Environment Variable.
    Key string
    The name of the Environment Variable.
    ProjectId string
    The ID of the Vercel project.
    Sensitive bool
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    Targets []string
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    TeamId string
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    Value string
    The value of the Environment Variable.
    gitBranch String
    The git branch of the Environment Variable.
    key String
    The name of the Environment Variable.
    projectId String
    The ID of the Vercel project.
    sensitive Boolean
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    targets List<String>
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    teamId String
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    value String
    The value of the Environment Variable.
    gitBranch string
    The git branch of the Environment Variable.
    key string
    The name of the Environment Variable.
    projectId string
    The ID of the Vercel project.
    sensitive boolean
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    targets string[]
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    teamId string
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    value string
    The value of the Environment Variable.
    git_branch str
    The git branch of the Environment Variable.
    key str
    The name of the Environment Variable.
    project_id str
    The ID of the Vercel project.
    sensitive bool
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    targets Sequence[str]
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    team_id str
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    value str
    The value of the Environment Variable.
    gitBranch String
    The git branch of the Environment Variable.
    key String
    The name of the Environment Variable.
    projectId String
    The ID of the Vercel project.
    sensitive Boolean
    Whether the Environment Variable is sensitive or not. (May be affected by a team-wide environment variable policy)
    targets List<String>
    The environments that the Environment Variable should be present on. Valid targets are either production, preview, or development.
    teamId String
    The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider.
    value String
    The value of the Environment Variable.

    Import

    If importing into a personal account, or with a team configured on

    the provider, simply use the project_id and environment variable id.

    • project_id can be found in the project settings tab in the Vercel UI.

    • environment variable id can be taken from the network tab inside developer tools, while you are on the project page,

    or can be queried from Vercel API directly (https://vercel.com/docs/rest-api/endpoints/projects#retrieve-the-environment-variables-of-a-project-by-id-or-name)

    Note also, that the value field for sensitive environment variables will be imported as null.

    $ pulumi import vercel:index/projectEnvironmentVariable:ProjectEnvironmentVariable example prj_xxxxxxxxxxxxxxxxxxxxxxxxxxxx/FdT2e1E5Of6Cihmt
    

    Alternatively, you can import via the team_id, project_id and

    environment variable id.

    • team_id can be found in the team settings tab in the Vercel UI.

    • project_id can be found in the project settings tab in the Vercel UI.

    • environment variable id can be taken from the network tab inside developer tools, while you are on the project page,

    or can be queried from Vercel API directly (https://vercel.com/docs/rest-api/endpoints/projects#retrieve-the-environment-variables-of-a-project-by-id-or-name)

    Note also, that the value field for sensitive environment variables will be imported as null.

    $ pulumi import vercel:index/projectEnvironmentVariable:ProjectEnvironmentVariable example team_xxxxxxxxxxxxxxxxxxxxxxxx/prj_xxxxxxxxxxxxxxxxxxxxxxxxxxxx/FdT2e1E5Of6Cihmt
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    vercel pulumiverse/pulumi-vercel
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the vercel Terraform Provider.
    vercel logo
    Vercel v1.11.0 published on Thursday, May 23, 2024 by Pulumiverse