Skip to content

Feature Request: Add coder_env Resource for Injecting Environment Variables into Workspaces #170

@matifali

Description

@matifali

Resource Name

coder_env

Description

This feature would introduce a new resource, coder_env, to the Coder Terraform provider, allowing users to inject environment variables dynamically into workspaces at creation and update.

Expected Behavior

  • Enable defining environment variables in the Terraform configuration file using coder_env.
  • Inject environment variables into the workspace specified by the agent_id.

Use Case

Automating workspace setups to include necessary environment variables is essential for preparing development environments with all the configurations needed for applications and services to function correctly. An example use case is configuring go to use Artifactory, which requires setting GOPROXY.

Example Configuration

Single variable

resource "coder_env" "example" {
  agent_id = coder_agent.example.id
  name     = "VAR1"
  value    = "Value1"
}

Multiple variables

resource "coder_env" "example" {
  agent_id = coder_agent.example.id
  item {
    name     = "VAR1"
    value    = "Value1"
  }
  item {
    name     = "VAR2"
    value    = "Value2"
  }

or

resource "coder_env" "example" {
  agent_id = coder_agent.example.id
  env = {
	VAR1 = "value1"
	VAR2 = "value2"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions