Coder.comC
Coder.com7mo ago
7 replies
Eron

How can a workspace's environment variable values be modified?

I am trying to setup the Coder Tasks w/ Docker template which has the following variables in the main.tf template file:
variable "anthropic_api_key" {
  type        = string
  description = "Generate one at: https://console.anthropic.com/settings/keys"
  sensitive   = true
}
resource "coder_env" "anthropic_api_key" {
  agent_id = coder_agent.main.id
  name     = "CODER_MCP_CLAUDE_API_KEY"
  value    = var.anthropic_api_key
}


I can't find documentation on how to modify the values of the "anthropic_api_key" and/or "CODER_MCP_CLAUDE_API_KEY" environment variable. Is there a way to do this?

I've tried to use the coder update --parameter command with no luck:
coder update CoderTasksTestWkspc --parameter CODER_MCP_CLAUDE_API_KEY="..."
Workspace is up-to-date.
eronsalling@amplify-dev coder % coder update CoderTasksTestWkspc --parameter anthropic_api_key="..."
Workspace is up-to-date.
eronsalling@amplify-dev coder % coder update CoderTasksTestWkspc --parameter coder_env.anthropic_api_key="..."

The key is unchanged when I run env | grep "CODER_MCP_CLAUDE_API_KEY" within the workspace terminal.

Thank you in advance for any help!
GitHub
Publish Coder modules and templates for other developers to use. - coder/registry
registry/registry/coder-labs/templates/tasks-docker/README.md at ma...
Solution
variables are shared by each workspace created from the template so you need to modify it in the Template settings
Was this page helpful?