1. Packages
  2. dbt Cloud Provider
  3. API Docs
  4. EnvironmentVariable
dbt Cloud v0.1.30 published on Thursday, Mar 20, 2025 by Pulumi

dbtcloud.EnvironmentVariable

Explore with Pulumi AI

Note: Some upstream resources can be slow to create, so if creating a project or environment at the same time as the environment variables, it’s recommended to use the depends_on meta argument.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as dbtcloud from "@pulumi/dbtcloud";

const dbtMyEnvVar = new dbtcloud.EnvironmentVariable("dbt_my_env_var", {
    name: "DBT_MY_ENV_VAR",
    projectId: dbtProject.id,
    environmentValues: {
        project: "my_project_level_value",
        Dev: "my_env_level_value",
        CI: "my_ci_override_value",
        Prod: "my_prod_override_value",
    },
}, {
    dependsOn: [
        dbtProject,
        devEnv,
        ciEnv,
        prodEnv,
    ],
});
Copy
import pulumi
import pulumi_dbtcloud as dbtcloud

dbt_my_env_var = dbtcloud.EnvironmentVariable("dbt_my_env_var",
    name="DBT_MY_ENV_VAR",
    project_id=dbt_project["id"],
    environment_values={
        "project": "my_project_level_value",
        "Dev": "my_env_level_value",
        "CI": "my_ci_override_value",
        "Prod": "my_prod_override_value",
    },
    opts = pulumi.ResourceOptions(depends_on=[
            dbt_project,
            dev_env,
            ci_env,
            prod_env,
        ]))
Copy
package main

import (
	"github.com/pulumi/pulumi-dbtcloud/sdk/go/dbtcloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := dbtcloud.NewEnvironmentVariable(ctx, "dbt_my_env_var", &dbtcloud.EnvironmentVariableArgs{
			Name:      pulumi.String("DBT_MY_ENV_VAR"),
			ProjectId: pulumi.Any(dbtProject.Id),
			EnvironmentValues: pulumi.StringMap{
				"project": pulumi.String("my_project_level_value"),
				"Dev":     pulumi.String("my_env_level_value"),
				"CI":      pulumi.String("my_ci_override_value"),
				"Prod":    pulumi.String("my_prod_override_value"),
			},
		}, pulumi.DependsOn([]pulumi.Resource{
			dbtProject,
			devEnv,
			ciEnv,
			prodEnv,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DbtCloud = Pulumi.DbtCloud;

return await Deployment.RunAsync(() => 
{
    var dbtMyEnvVar = new DbtCloud.EnvironmentVariable("dbt_my_env_var", new()
    {
        Name = "DBT_MY_ENV_VAR",
        ProjectId = dbtProject.Id,
        EnvironmentValues = 
        {
            { "project", "my_project_level_value" },
            { "Dev", "my_env_level_value" },
            { "CI", "my_ci_override_value" },
            { "Prod", "my_prod_override_value" },
        },
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            dbtProject,
            devEnv,
            ciEnv,
            prodEnv,
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.dbtcloud.EnvironmentVariable;
import com.pulumi.dbtcloud.EnvironmentVariableArgs;
import com.pulumi.resources.CustomResourceOptions;
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 dbtMyEnvVar = new EnvironmentVariable("dbtMyEnvVar", EnvironmentVariableArgs.builder()
            .name("DBT_MY_ENV_VAR")
            .projectId(dbtProject.id())
            .environmentValues(Map.ofEntries(
                Map.entry("project", "my_project_level_value"),
                Map.entry("Dev", "my_env_level_value"),
                Map.entry("CI", "my_ci_override_value"),
                Map.entry("Prod", "my_prod_override_value")
            ))
            .build(), CustomResourceOptions.builder()
                .dependsOn(                
                    dbtProject,
                    devEnv,
                    ciEnv,
                    prodEnv)
                .build());

    }
}
Copy
resources:
  dbtMyEnvVar:
    type: dbtcloud:EnvironmentVariable
    name: dbt_my_env_var
    properties:
      name: DBT_MY_ENV_VAR
      projectId: ${dbtProject.id}
      environmentValues:
        project: my_project_level_value
        Dev: my_env_level_value
        CI: my_ci_override_value
        Prod: my_prod_override_value
    options:
      dependsOn:
        - ${dbtProject}
        - ${devEnv}
        - ${ciEnv}
        - ${prodEnv}
Copy

Create EnvironmentVariable Resource

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

Constructor syntax

new EnvironmentVariable(name: string, args: EnvironmentVariableArgs, opts?: CustomResourceOptions);
@overload
def EnvironmentVariable(resource_name: str,
                        args: EnvironmentVariableArgs,
                        opts: Optional[ResourceOptions] = None)

@overload
def EnvironmentVariable(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        environment_values: Optional[Mapping[str, str]] = None,
                        project_id: Optional[int] = None,
                        name: Optional[str] = None)
func NewEnvironmentVariable(ctx *Context, name string, args EnvironmentVariableArgs, opts ...ResourceOption) (*EnvironmentVariable, error)
public EnvironmentVariable(string name, EnvironmentVariableArgs args, CustomResourceOptions? opts = null)
public EnvironmentVariable(String name, EnvironmentVariableArgs args)
public EnvironmentVariable(String name, EnvironmentVariableArgs args, CustomResourceOptions options)
type: dbtcloud:EnvironmentVariable
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. EnvironmentVariableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. EnvironmentVariableArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. EnvironmentVariableArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. EnvironmentVariableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. EnvironmentVariableArgs
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 environmentVariableResource = new DbtCloud.EnvironmentVariable("environmentVariableResource", new()
{
    EnvironmentValues = 
    {
        { "string", "string" },
    },
    ProjectId = 0,
    Name = "string",
});
Copy
example, err := dbtcloud.NewEnvironmentVariable(ctx, "environmentVariableResource", &dbtcloud.EnvironmentVariableArgs{
	EnvironmentValues: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	ProjectId: pulumi.Int(0),
	Name:      pulumi.String("string"),
})
Copy
var environmentVariableResource = new EnvironmentVariable("environmentVariableResource", EnvironmentVariableArgs.builder()
    .environmentValues(Map.of("string", "string"))
    .projectId(0)
    .name("string")
    .build());
Copy
environment_variable_resource = dbtcloud.EnvironmentVariable("environmentVariableResource",
    environment_values={
        "string": "string",
    },
    project_id=0,
    name="string")
Copy
const environmentVariableResource = new dbtcloud.EnvironmentVariable("environmentVariableResource", {
    environmentValues: {
        string: "string",
    },
    projectId: 0,
    name: "string",
});
Copy
type: dbtcloud:EnvironmentVariable
properties:
    environmentValues:
        string: string
    name: string
    projectId: 0
Copy

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

EnvironmentValues
This property is required.
Changes to this property will trigger replacement.
Dictionary<string, string>
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
ProjectId
This property is required.
Changes to this property will trigger replacement.
int
Project for the variable to be created in
Name Changes to this property will trigger replacement. string
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
EnvironmentValues
This property is required.
Changes to this property will trigger replacement.
map[string]string
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
ProjectId
This property is required.
Changes to this property will trigger replacement.
int
Project for the variable to be created in
Name Changes to this property will trigger replacement. string
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
environmentValues
This property is required.
Changes to this property will trigger replacement.
Map<String,String>
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
projectId
This property is required.
Changes to this property will trigger replacement.
Integer
Project for the variable to be created in
name Changes to this property will trigger replacement. String
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
environmentValues
This property is required.
Changes to this property will trigger replacement.
{[key: string]: string}
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
projectId
This property is required.
Changes to this property will trigger replacement.
number
Project for the variable to be created in
name Changes to this property will trigger replacement. string
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
environment_values
This property is required.
Changes to this property will trigger replacement.
Mapping[str, str]
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
project_id
This property is required.
Changes to this property will trigger replacement.
int
Project for the variable to be created in
name Changes to this property will trigger replacement. str
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
environmentValues
This property is required.
Changes to this property will trigger replacement.
Map<String>
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
projectId
This property is required.
Changes to this property will trigger replacement.
Number
Project for the variable to be created in
name Changes to this property will trigger replacement. String
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'

Outputs

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

Get an existing EnvironmentVariable 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?: EnvironmentVariableState, opts?: CustomResourceOptions): EnvironmentVariable
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        environment_values: Optional[Mapping[str, str]] = None,
        name: Optional[str] = None,
        project_id: Optional[int] = None) -> EnvironmentVariable
func GetEnvironmentVariable(ctx *Context, name string, id IDInput, state *EnvironmentVariableState, opts ...ResourceOption) (*EnvironmentVariable, error)
public static EnvironmentVariable Get(string name, Input<string> id, EnvironmentVariableState? state, CustomResourceOptions? opts = null)
public static EnvironmentVariable get(String name, Output<String> id, EnvironmentVariableState state, CustomResourceOptions options)
resources:  _:    type: dbtcloud:EnvironmentVariable    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
EnvironmentValues Changes to this property will trigger replacement. Dictionary<string, string>
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
Name Changes to this property will trigger replacement. string
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
ProjectId Changes to this property will trigger replacement. int
Project for the variable to be created in
EnvironmentValues Changes to this property will trigger replacement. map[string]string
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
Name Changes to this property will trigger replacement. string
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
ProjectId Changes to this property will trigger replacement. int
Project for the variable to be created in
environmentValues Changes to this property will trigger replacement. Map<String,String>
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
name Changes to this property will trigger replacement. String
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
projectId Changes to this property will trigger replacement. Integer
Project for the variable to be created in
environmentValues Changes to this property will trigger replacement. {[key: string]: string}
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
name Changes to this property will trigger replacement. string
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
projectId Changes to this property will trigger replacement. number
Project for the variable to be created in
environment_values Changes to this property will trigger replacement. Mapping[str, str]
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
name Changes to this property will trigger replacement. str
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
project_id Changes to this property will trigger replacement. int
Project for the variable to be created in
environmentValues Changes to this property will trigger replacement. Map<String>
Map from environment names to respective variable value, a special key project should be set for the project default variable value. This field is not set as sensitive so take precautions when using secret environment variables.
name Changes to this property will trigger replacement. String
Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
projectId Changes to this property will trigger replacement. Number
Project for the variable to be created in

Import

using import blocks (requires Terraform >= 1.5)

import {

to = dbtcloud_environment_variable.test_environment_variable

id = “project_id:environment_variable_name”

}

import {

to = dbtcloud_environment_variable.test_environment_variable

id = “12345:DBT_ENV_VAR”

}

using the older import command

$ pulumi import dbtcloud:index/environmentVariable:EnvironmentVariable test_environment_variable "project_id:environment_variable_name"
Copy
$ pulumi import dbtcloud:index/environmentVariable:EnvironmentVariable test_environment_variable 12345:DBT_ENV_VAR
Copy

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

Package Details

Repository
dbtcloud pulumi/pulumi-dbtcloud
License
Apache-2.0
Notes
This Pulumi package is based on the dbtcloud Terraform Provider.