1. Packages
  2. Circleci Provider
  3. API Docs
  4. ContextEnvironmentVariable
circleci 0.6.1 published on Monday, Apr 14, 2025 by mrolla

circleci.ContextEnvironmentVariable

Explore with Pulumi AI

circleci logo
circleci 0.6.1 published on Monday, Apr 14, 2025 by mrolla

    Example Usage

    Basic usage:

    import * as pulumi from "@pulumi/pulumi";
    import * as circleci from "@pulumi/circleci";
    
    const buildContext = new circleci.Context("buildContext", {});
    const buildContextEnvironmentVariable = new circleci.ContextEnvironmentVariable("buildContextEnvironmentVariable", {
        variable: "TOKEN",
        value: "secret",
        contextId: buildContext.contextId,
    });
    
    import pulumi
    import pulumi_circleci as circleci
    
    build_context = circleci.Context("buildContext")
    build_context_environment_variable = circleci.ContextEnvironmentVariable("buildContextEnvironmentVariable",
        variable="TOKEN",
        value="secret",
        context_id=build_context.context_id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/circleci/circleci"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		buildContext, err := circleci.NewContext(ctx, "buildContext", nil)
    		if err != nil {
    			return err
    		}
    		_, err = circleci.NewContextEnvironmentVariable(ctx, "buildContextEnvironmentVariable", &circleci.ContextEnvironmentVariableArgs{
    			Variable:  pulumi.String("TOKEN"),
    			Value:     pulumi.String("secret"),
    			ContextId: buildContext.ContextId,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Circleci = Pulumi.Circleci;
    
    return await Deployment.RunAsync(() => 
    {
        var buildContext = new Circleci.Context("buildContext");
    
        var buildContextEnvironmentVariable = new Circleci.ContextEnvironmentVariable("buildContextEnvironmentVariable", new()
        {
            Variable = "TOKEN",
            Value = "secret",
            ContextId = buildContext.ContextId,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.circleci.Context;
    import com.pulumi.circleci.ContextEnvironmentVariable;
    import com.pulumi.circleci.ContextEnvironmentVariableArgs;
    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 buildContext = new Context("buildContext");
    
            var buildContextEnvironmentVariable = new ContextEnvironmentVariable("buildContextEnvironmentVariable", ContextEnvironmentVariableArgs.builder()
                .variable("TOKEN")
                .value("secret")
                .contextId(buildContext.contextId())
                .build());
    
        }
    }
    
    resources:
      buildContext:
        type: circleci:Context
      buildContextEnvironmentVariable:
        type: circleci:ContextEnvironmentVariable
        properties:
          variable: TOKEN
          value: secret
          contextId: ${buildContext.contextId}
    

    With for_each:

    import * as pulumi from "@pulumi/pulumi";
    import * as circleci from "@pulumi/circleci";
    
    const buildContext = new circleci.Context("buildContext", {});
    const buildContextEnvironmentVariable: circleci.ContextEnvironmentVariable[] = [];
    for (const range of Object.entries({
        TOKENA: "secret",
        TOKENB: "secret",
    }).map(([k, v]) => ({key: k, value: v}))) {
        buildContextEnvironmentVariable.push(new circleci.ContextEnvironmentVariable(`buildContextEnvironmentVariable-${range.key}`, {
            variable: range.key,
            value: range.value,
            contextId: buildContext.contextId,
        }));
    }
    
    import pulumi
    import pulumi_circleci as circleci
    
    build_context = circleci.Context("buildContext")
    build_context_environment_variable = []
    for range in [{"key": k, "value": v} for [k, v] in enumerate({
        TOKENA: secret,
        TOKENB: secret,
    })]:
        build_context_environment_variable.append(circleci.ContextEnvironmentVariable(f"buildContextEnvironmentVariable-{range['key']}",
            variable=range["key"],
            value=range["value"],
            context_id=build_context.context_id))
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/circleci/circleci"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		buildContext, err := circleci.NewContext(ctx, "buildContext", nil)
    		if err != nil {
    			return err
    		}
    		var buildContextEnvironmentVariable []*circleci.ContextEnvironmentVariable
    		for key0, val0 := range map[string]interface{}{
    			"TOKENA": "secret",
    			"TOKENB": "secret",
    		} {
    			__res, err := circleci.NewContextEnvironmentVariable(ctx, fmt.Sprintf("buildContextEnvironmentVariable-%v", key0), &circleci.ContextEnvironmentVariableArgs{
    				Variable:  pulumi.String(key0),
    				Value:     pulumi.String(val0),
    				ContextId: buildContext.ContextId,
    			})
    			if err != nil {
    				return err
    			}
    			buildContextEnvironmentVariable = append(buildContextEnvironmentVariable, __res)
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Circleci = Pulumi.Circleci;
    
    return await Deployment.RunAsync(() => 
    {
        var buildContext = new Circleci.Context("buildContext");
    
        var buildContextEnvironmentVariable = new List<Circleci.ContextEnvironmentVariable>();
        foreach (var range in 
        {
            { "TOKENA", "secret" },
            { "TOKENB", "secret" },
        }.Select(pair => new { pair.Key, pair.Value }))
        {
            buildContextEnvironmentVariable.Add(new Circleci.ContextEnvironmentVariable($"buildContextEnvironmentVariable-{range.Key}", new()
            {
                Variable = range.Key,
                Value = range.Value,
                ContextId = buildContext.ContextId,
            }));
        }
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.circleci.Context;
    import com.pulumi.circleci.ContextEnvironmentVariable;
    import com.pulumi.circleci.ContextEnvironmentVariableArgs;
    import com.pulumi.codegen.internal.KeyedValue;
    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 buildContext = new Context("buildContext");
    
            for (var range : KeyedValue.of(%!o(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))) {
                new ContextEnvironmentVariable("buildContextEnvironmentVariable-" + range.key(), ContextEnvironmentVariableArgs.builder()
                    .variable(range.key())
                    .value(range.value())
                    .contextId(buildContext.contextId())
                    .build());
            }
    
        }
    }
    
    resources:
      buildContext:
        type: circleci:Context
      buildContextEnvironmentVariable:
        type: circleci:ContextEnvironmentVariable
        properties:
          variable: ${range.key}
          value: ${range.value}
          contextId: ${buildContext.contextId}
        options: {}
    

    Create ContextEnvironmentVariable Resource

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

    Constructor syntax

    new ContextEnvironmentVariable(name: string, args: ContextEnvironmentVariableArgs, opts?: CustomResourceOptions);
    @overload
    def ContextEnvironmentVariable(resource_name: str,
                                   args: ContextEnvironmentVariableArgs,
                                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def ContextEnvironmentVariable(resource_name: str,
                                   opts: Optional[ResourceOptions] = None,
                                   context_id: Optional[str] = None,
                                   value: Optional[str] = None,
                                   variable: Optional[str] = None,
                                   context_environment_variable_id: Optional[str] = None,
                                   organization: Optional[str] = None)
    func NewContextEnvironmentVariable(ctx *Context, name string, args ContextEnvironmentVariableArgs, opts ...ResourceOption) (*ContextEnvironmentVariable, error)
    public ContextEnvironmentVariable(string name, ContextEnvironmentVariableArgs args, CustomResourceOptions? opts = null)
    public ContextEnvironmentVariable(String name, ContextEnvironmentVariableArgs args)
    public ContextEnvironmentVariable(String name, ContextEnvironmentVariableArgs args, CustomResourceOptions options)
    
    type: circleci:ContextEnvironmentVariable
    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 ContextEnvironmentVariableArgs
    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 ContextEnvironmentVariableArgs
    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 ContextEnvironmentVariableArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ContextEnvironmentVariableArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ContextEnvironmentVariableArgs
    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 contextEnvironmentVariableResource = new Circleci.ContextEnvironmentVariable("contextEnvironmentVariableResource", new()
    {
        ContextId = "string",
        Value = "string",
        Variable = "string",
        ContextEnvironmentVariableId = "string",
        Organization = "string",
    });
    
    example, err := circleci.NewContextEnvironmentVariable(ctx, "contextEnvironmentVariableResource", &circleci.ContextEnvironmentVariableArgs{
    	ContextId:                    pulumi.String("string"),
    	Value:                        pulumi.String("string"),
    	Variable:                     pulumi.String("string"),
    	ContextEnvironmentVariableId: pulumi.String("string"),
    	Organization:                 pulumi.String("string"),
    })
    
    var contextEnvironmentVariableResource = new ContextEnvironmentVariable("contextEnvironmentVariableResource", ContextEnvironmentVariableArgs.builder()
        .contextId("string")
        .value("string")
        .variable("string")
        .contextEnvironmentVariableId("string")
        .organization("string")
        .build());
    
    context_environment_variable_resource = circleci.ContextEnvironmentVariable("contextEnvironmentVariableResource",
        context_id="string",
        value="string",
        variable="string",
        context_environment_variable_id="string",
        organization="string")
    
    const contextEnvironmentVariableResource = new circleci.ContextEnvironmentVariable("contextEnvironmentVariableResource", {
        contextId: "string",
        value: "string",
        variable: "string",
        contextEnvironmentVariableId: "string",
        organization: "string",
    });
    
    type: circleci:ContextEnvironmentVariable
    properties:
        contextEnvironmentVariableId: string
        contextId: string
        organization: string
        value: string
        variable: string
    

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

    ContextId string
    The context that the environment variable will be added to.
    Value string
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    Variable string
    Name of the environment variable.
    ContextEnvironmentVariableId string
    Organization string
    Organization where the context is defined.
    ContextId string
    The context that the environment variable will be added to.
    Value string
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    Variable string
    Name of the environment variable.
    ContextEnvironmentVariableId string
    Organization string
    Organization where the context is defined.
    contextId String
    The context that the environment variable will be added to.
    value String
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    variable String
    Name of the environment variable.
    contextEnvironmentVariableId String
    organization String
    Organization where the context is defined.
    contextId string
    The context that the environment variable will be added to.
    value string
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    variable string
    Name of the environment variable.
    contextEnvironmentVariableId string
    organization string
    Organization where the context is defined.
    context_id str
    The context that the environment variable will be added to.
    value str
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    variable str
    Name of the environment variable.
    context_environment_variable_id str
    organization str
    Organization where the context is defined.
    contextId String
    The context that the environment variable will be added to.
    value String
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    variable String
    Name of the environment variable.
    contextEnvironmentVariableId String
    organization String
    Organization where the context is defined.

    Outputs

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

    Get an existing ContextEnvironmentVariable 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?: ContextEnvironmentVariableState, opts?: CustomResourceOptions): ContextEnvironmentVariable
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            context_environment_variable_id: Optional[str] = None,
            context_id: Optional[str] = None,
            organization: Optional[str] = None,
            value: Optional[str] = None,
            variable: Optional[str] = None) -> ContextEnvironmentVariable
    func GetContextEnvironmentVariable(ctx *Context, name string, id IDInput, state *ContextEnvironmentVariableState, opts ...ResourceOption) (*ContextEnvironmentVariable, error)
    public static ContextEnvironmentVariable Get(string name, Input<string> id, ContextEnvironmentVariableState? state, CustomResourceOptions? opts = null)
    public static ContextEnvironmentVariable get(String name, Output<String> id, ContextEnvironmentVariableState state, CustomResourceOptions options)
    resources:  _:    type: circleci:ContextEnvironmentVariable    get:      id: ${id}
    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:
    ContextEnvironmentVariableId string
    ContextId string
    The context that the environment variable will be added to.
    Organization string
    Organization where the context is defined.
    Value string
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    Variable string
    Name of the environment variable.
    ContextEnvironmentVariableId string
    ContextId string
    The context that the environment variable will be added to.
    Organization string
    Organization where the context is defined.
    Value string
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    Variable string
    Name of the environment variable.
    contextEnvironmentVariableId String
    contextId String
    The context that the environment variable will be added to.
    organization String
    Organization where the context is defined.
    value String
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    variable String
    Name of the environment variable.
    contextEnvironmentVariableId string
    contextId string
    The context that the environment variable will be added to.
    organization string
    Organization where the context is defined.
    value string
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    variable string
    Name of the environment variable.
    context_environment_variable_id str
    context_id str
    The context that the environment variable will be added to.
    organization str
    Organization where the context is defined.
    value str
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    variable str
    Name of the environment variable.
    contextEnvironmentVariableId String
    contextId String
    The context that the environment variable will be added to.
    organization String
    Organization where the context is defined.
    value String
    The value of the environment variable. A hash of this value will be stored in state in order to detect changes, but the plain text value will not be stored.
    variable String
    Name of the environment variable.

    Import

    Context environment variables can be imported as $organization/$context/$variable, where “context” can be either a context name or ID.

    Additionally, you must specify an existing value as CIRCLECI_ENV_VALUE so that Terraform can detect whether it needs to update the variable.

    For example:

    $ pulumi import circleci:index/contextEnvironmentVariable:ContextEnvironmentVariable CIRCLECI_ENV_VALUE=secret circleci_context_environment_variable.token hashicorp/build/TOKEN
    

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

    Package Details

    Repository
    circleci mrolla/terraform-provider-circleci
    License
    Notes
    This Pulumi package is based on the circleci Terraform Provider.
    circleci logo
    circleci 0.6.1 published on Monday, Apr 14, 2025 by mrolla