1. Packages
  2. dbt Cloud
  3. API Docs
  4. EnvironmentVariable
dbt Cloud v0.1.8 published on Tuesday, Jun 11, 2024 by Pulumi

dbtcloud.EnvironmentVariable

Explore with Pulumi AI

dbtcloud logo
dbt Cloud v0.1.8 published on Tuesday, Jun 11, 2024 by Pulumi

    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,
        ],
    });
    
    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,
            ]))
    
    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.Map{
    				"project": pulumi.Any("my_project_level_value"),
    				"Dev":     pulumi.Any("my_env_level_value"),
    				"CI":      pulumi.Any("my_ci_override_value"),
    				"Prod":    pulumi.Any("my_prod_override_value"),
    			},
    		}, pulumi.DependsOn([]pulumi.Resource{
    			dbtProject,
    			devEnv,
    			ciEnv,
    			prodEnv,
    		}))
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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,
            },
        });
    
    });
    
    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());
    
        }
    }
    
    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}
    

    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, Any]] = 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 string
    The unique name of the resource.
    args EnvironmentVariableArgs
    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 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 string
    The unique name of the resource.
    args EnvironmentVariableArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args EnvironmentVariableArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args EnvironmentVariableArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var environmentVariableResource = new DbtCloud.EnvironmentVariable("environmentVariableResource", new()
    {
        EnvironmentValues = 
        {
            { "string", "any" },
        },
        ProjectId = 0,
        Name = "string",
    });
    
    example, err := dbtcloud.NewEnvironmentVariable(ctx, "environmentVariableResource", &dbtcloud.EnvironmentVariableArgs{
    	EnvironmentValues: pulumi.Map{
    		"string": pulumi.Any("any"),
    	},
    	ProjectId: pulumi.Int(0),
    	Name:      pulumi.String("string"),
    })
    
    var environmentVariableResource = new EnvironmentVariable("environmentVariableResource", EnvironmentVariableArgs.builder()
        .environmentValues(Map.of("string", "any"))
        .projectId(0)
        .name("string")
        .build());
    
    environment_variable_resource = dbtcloud.EnvironmentVariable("environmentVariableResource",
        environment_values={
            "string": "any",
        },
        project_id=0,
        name="string")
    
    const environmentVariableResource = new dbtcloud.EnvironmentVariable("environmentVariableResource", {
        environmentValues: {
            string: "any",
        },
        projectId: 0,
        name: "string",
    });
    
    type: dbtcloud:EnvironmentVariable
    properties:
        environmentValues:
            string: any
        name: string
        projectId: 0
    

    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

    The EnvironmentVariable resource accepts the following input properties:

    EnvironmentValues Dictionary<string, object>
    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 int
    Project for the variable to be created in
    Name string
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    EnvironmentValues map[string]interface{}
    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 int
    Project for the variable to be created in
    Name string
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    environmentValues Map<String,Object>
    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 Integer
    Project for the variable to be created in
    name String
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    environmentValues {[key: string]: any}
    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 number
    Project for the variable to be created in
    name string
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    environment_values Mapping[str, Any]
    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 int
    Project for the variable to be created in
    name str
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    environmentValues Map<Any>
    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 Number
    Project for the variable to be created in
    name 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, Any]] = 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)
    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:
    EnvironmentValues Dictionary<string, object>
    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 string
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    ProjectId int
    Project for the variable to be created in
    EnvironmentValues map[string]interface{}
    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 string
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    ProjectId int
    Project for the variable to be created in
    environmentValues Map<String,Object>
    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 String
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    projectId Integer
    Project for the variable to be created in
    environmentValues {[key: string]: any}
    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 string
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    projectId number
    Project for the variable to be created in
    environment_values Mapping[str, Any]
    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 str
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    project_id int
    Project for the variable to be created in
    environmentValues Map<Any>
    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 String
    Name for the variable, must be unique within a project, must be prefixed with 'DBT_'
    projectId 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"
    
    $ pulumi import dbtcloud:index/environmentVariable:EnvironmentVariable test_environment_variable 12345:DBT_ENV_VAR
    

    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.
    dbtcloud logo
    dbt Cloud v0.1.8 published on Tuesday, Jun 11, 2024 by Pulumi