page_title | subcategory | description |
---|---|---|
coder_agent Resource - terraform-provider-coder |
Use this resource to associate an agent. |
Use this resource to associate an agent.
data "coder_workspace" "me" {
}
resource "coder_agent" "dev" {
os = "linux"
arch = "amd64"
dir = "/workspace"
display_apps {
vscode = true
vscode_insiders = false
web_terminal = true
ssh_helper = false
}
metadata {
display_name = "CPU Usage"
key = "cpu_usage"
script = "coder stat cpu"
interval = 10
timeout = 1
order = 2
}
metadata {
display_name = "RAM Usage"
key = "ram_usage"
script = "coder stat mem"
interval = 10
timeout = 1
order = 1
}
order = 1
}
resource "kubernetes_pod" "dev" {
count = data.coder_workspace.me.start_count
spec {
container {
command = ["sh", "-c", coder_agent.dev.init_script]
env {
name = "CODER_AGENT_TOKEN"
value = coder_agent.dev.token
}
}
}
}
arch
(String) The architecture the agent will run on. Must be one of:"amd64"
,"armv7"
,"arm64"
.os
(String) The operating system the agent will run on. Must be one of:"linux"
,"darwin"
, or"windows"
.
auth
(String) The authentication type the agent will use. Must be one of:"token"
,"google-instance-identity"
,"aws-instance-identity"
,"azure-instance-identity"
.connection_timeout
(Number) Time in seconds until the agent is marked as timed out when a connection with the server cannot be established. A value of zero never marks the agent as timed out.dir
(String) The starting directory when a user creates a shell session. Defaults to"$HOME"
.display_apps
(Block Set, Max: 1) The list of built-in apps to display in the agent bar. (see below for nested schema)env
(Map of String) A mapping of environment variables to set inside the workspace.metadata
(Block List) Eachmetadata
block defines a single item consisting of a key/value pair. This feature is in alpha and may break in future releases. (see below for nested schema)motd_file
(String) The path to a file within the workspace containing a message to display to users when they login via SSH. A typical value would be"/etc/motd"
.order
(Number) The order determines the position of agents in the UI presentation. The lowest order is shown first and agents with equal order are sorted by name (ascending order).shutdown_script
(String) A script to run before the agent is stopped. The script should exit when it is done to signal that the workspace can be stopped. This option is an alias for defining acoder_script
resource withrun_on_stop
set totrue
.startup_script
(String) A script to run after the agent starts. The script should exit when it is done to signal that the agent is ready. This option is an alias for defining acoder_script
resource withrun_on_start
set totrue
.startup_script_behavior
(String) This option sets the behavior of thestartup_script
. When set to"blocking"
, thestartup_script
must exit before the workspace is ready. When set to"non-blocking"
, thestartup_script
may run in the background and the workspace will be ready immediately. Default is"non-blocking"
, although"blocking"
is recommended. This option is an alias for defining acoder_script
resource withstart_blocks_login
set totrue
(blocking).troubleshooting_url
(String) A URL to a document with instructions for troubleshooting problems with the agent.
id
(String) The ID of this resource.init_script
(String) Run this script on startup of an instance to initialize the agent.token
(String, Sensitive) Set the environment variableCODER_AGENT_TOKEN
with this token to authenticate an agent.
Optional:
port_forwarding_helper
(Boolean) Display the port-forwarding helper button in the agent bar.ssh_helper
(Boolean) Display the SSH helper button in the agent bar.vscode
(Boolean) Display the VSCode Desktop app in the agent bar.vscode_insiders
(Boolean) Display the VSCode Insiders app in the agent bar.web_terminal
(Boolean) Display the web terminal app in the agent bar.
Required:
interval
(Number) The interval in seconds at which to refresh this metadata item.key
(String) The key of this metadata item.script
(String) The script that retrieves the value of this metadata item.
Optional:
display_name
(String) The user-facing name of this value.order
(Number) The order determines the position of agent metadata in the UI presentation. The lowest order is shown first and metadata with equal order are sorted by key (ascending order).timeout
(Number) The maximum time the command is allowed to run in seconds.