C
Coder.com3mo ago
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
}
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="..."
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
registry/registry/coder-labs/templates/tasks-docker/README.md at ma...
Publish Coder modules and templates for other developers to use. - coder/registry
Solution:
variables are shared by each workspace created from the template so you need to modify it in the Template settings
Jump to solution
6 Replies
Codercord
Codercord3mo ago
Codercord
Codercord3mo ago
<#1394435722068623462>
Category
Help needed
Product
Coder (v2)
Platform
N/A
Logs
Please post any relevant logs/error messages.
What operating system are you running Coder (v2) on?
Solution
matifali
matifali3mo ago
variables are shared by each workspace created from the template so you need to modify it in the Template settings
matifali
matifali3mo ago
You can do so from the UI and also from CLi by pushing a new template version and changing the value if the variable with coder templates push --var
Eron
EronOP3mo ago
Thank you!
Codercord
Codercord3mo ago
@Phorcys closed the thread.

Did you find this page helpful?