coder.Env
Explore with Pulumi AI
Use this resource to set an environment variable in a workspace. Note that this resource cannot be used to overwrite existing environment variables set on the coder.Agent
resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as coder from "@pulumi/coder";
const me = coder.getWorkspace({});
const dev = new coder.Agent("dev", {
os: "linux",
arch: "amd64",
dir: "/workspace",
});
const welcomeMessage = new coder.Env("welcomeMessage", {
agentId: dev.agentId,
value: "Welcome to your Coder workspace!",
});
const internalApiUrl = new coder.Env("internalApiUrl", {
agentId: dev.agentId,
value: "https://api.internal.company.com/v1",
});
import pulumi
import pulumi_coder as coder
me = coder.get_workspace()
dev = coder.Agent("dev",
os="linux",
arch="amd64",
dir="/workspace")
welcome_message = coder.Env("welcomeMessage",
agent_id=dev.agent_id,
value="Welcome to your Coder workspace!")
internal_api_url = coder.Env("internalApiUrl",
agent_id=dev.agent_id,
value="https://api.internal.company.com/v1")
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/coder/v2/coder"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := coder.GetWorkspace(ctx, map[string]interface{}{}, nil)
if err != nil {
return err
}
dev, err := coder.NewAgent(ctx, "dev", &coder.AgentArgs{
Os: pulumi.String("linux"),
Arch: pulumi.String("amd64"),
Dir: pulumi.String("/workspace"),
})
if err != nil {
return err
}
_, err = coder.NewEnv(ctx, "welcomeMessage", &coder.EnvArgs{
AgentId: dev.AgentId,
Value: pulumi.String("Welcome to your Coder workspace!"),
})
if err != nil {
return err
}
_, err = coder.NewEnv(ctx, "internalApiUrl", &coder.EnvArgs{
AgentId: dev.AgentId,
Value: pulumi.String("https://api.internal.company.com/v1"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Coder = Pulumi.Coder;
return await Deployment.RunAsync(() =>
{
var me = Coder.GetWorkspace.Invoke();
var dev = new Coder.Agent("dev", new()
{
Os = "linux",
Arch = "amd64",
Dir = "/workspace",
});
var welcomeMessage = new Coder.Env("welcomeMessage", new()
{
AgentId = dev.AgentId,
Value = "Welcome to your Coder workspace!",
});
var internalApiUrl = new Coder.Env("internalApiUrl", new()
{
AgentId = dev.AgentId,
Value = "https://api.internal.company.com/v1",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.coder.CoderFunctions;
import com.pulumi.coder.Agent;
import com.pulumi.coder.AgentArgs;
import com.pulumi.coder.Env;
import com.pulumi.coder.EnvArgs;
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) {
final var me = CoderFunctions.getWorkspace();
var dev = new Agent("dev", AgentArgs.builder()
.os("linux")
.arch("amd64")
.dir("/workspace")
.build());
var welcomeMessage = new Env("welcomeMessage", EnvArgs.builder()
.agentId(dev.agentId())
.value("Welcome to your Coder workspace!")
.build());
var internalApiUrl = new Env("internalApiUrl", EnvArgs.builder()
.agentId(dev.agentId())
.value("https://api.internal.company.com/v1")
.build());
}
}
resources:
dev:
type: coder:Agent
properties:
os: linux
arch: amd64
dir: /workspace
welcomeMessage:
type: coder:Env
properties:
agentId: ${dev.agentId}
value: Welcome to your Coder workspace!
internalApiUrl:
type: coder:Env
properties:
agentId: ${dev.agentId}
value: https://api.internal.company.com/v1
variables:
me:
fn::invoke:
function: coder:getWorkspace
arguments: {}
Create Env Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Env(name: string, args: EnvArgs, opts?: CustomResourceOptions);
@overload
def Env(resource_name: str,
args: EnvArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Env(resource_name: str,
opts: Optional[ResourceOptions] = None,
agent_id: Optional[str] = None,
env_id: Optional[str] = None,
name: Optional[str] = None,
value: Optional[str] = None)
func NewEnv(ctx *Context, name string, args EnvArgs, opts ...ResourceOption) (*Env, error)
public Env(string name, EnvArgs args, CustomResourceOptions? opts = null)
type: coder:Env
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 EnvArgs
- 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 EnvArgs
- 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 EnvArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args EnvArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args EnvArgs
- 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 envResource = new Coder.Env("envResource", new()
{
AgentId = "string",
EnvId = "string",
Name = "string",
Value = "string",
});
example, err := coder.NewEnv(ctx, "envResource", &coder.EnvArgs{
AgentId: pulumi.String("string"),
EnvId: pulumi.String("string"),
Name: pulumi.String("string"),
Value: pulumi.String("string"),
})
var envResource = new Env("envResource", EnvArgs.builder()
.agentId("string")
.envId("string")
.name("string")
.value("string")
.build());
env_resource = coder.Env("envResource",
agent_id="string",
env_id="string",
name="string",
value="string")
const envResource = new coder.Env("envResource", {
agentId: "string",
envId: "string",
name: "string",
value: "string",
});
type: coder:Env
properties:
agentId: string
envId: string
name: string
value: string
Env 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 Env resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the Env 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 Env Resource
Get an existing Env 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?: EnvState, opts?: CustomResourceOptions): Env
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
agent_id: Optional[str] = None,
env_id: Optional[str] = None,
name: Optional[str] = None,
value: Optional[str] = None) -> Env
func GetEnv(ctx *Context, name string, id IDInput, state *EnvState, opts ...ResourceOption) (*Env, error)
public static Env Get(string name, Input<string> id, EnvState? state, CustomResourceOptions? opts = null)
public static Env get(String name, Output<String> id, EnvState state, CustomResourceOptions options)
resources: _: type: coder:Env 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.
Package Details
- Repository
- coder coder/terraform-provider-coder
- License
- Notes
- This Pulumi package is based on the
coder
Terraform Provider.