Skip to content

Latest commit

 

History

History
121 lines (97 loc) · 6.16 KB

File metadata and controls

121 lines (97 loc) · 6.16 KB
page_title subcategory description
coder_agent Resource - terraform-provider-coder
Use this resource to associate an agent.

coder_agent (Resource)

Use this resource to associate an agent.

Example Usage

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
      }
    }
  }
}

Schema

Required

  • 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".

Optional

  • 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.
  • login_before_ready (Boolean, Deprecated: Configure startup_script_behavior instead. This attribute will be removed in a future version of the provider.) This option defines whether or not the user can (by default) login to the workspace before it is ready. Ready means that e.g. the startup_script is done and has exited. When enabled, users may see an incomplete workspace when logging in.
  • metadata (Block List) Each "metadata" 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 a "coder_script" resource with "run_on_stop" set to true.
  • shutdown_script_timeout (Number, Deprecated: This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.) Time in seconds until the agent lifecycle status is marked as timed out during shutdown, this happens when the shutdown script has not completed (exited) in the given time.
  • 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 a "coder_script" resource with "run_on_start" set to true.
  • startup_script_behavior (String) This option sets the behavior of the "startup_script". When set to "blocking", the startup_script must exit before the workspace is ready. When set to "non-blocking", the startup_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 a "coder_script" resource with "start_blocks_login" set to true (blocking).
  • startup_script_timeout (Number, Deprecated: This feature is deprecated and has no effect. This attribute will be removed in a future version of the provider.) Time in seconds until the agent lifecycle status is marked as timed out during start, this happens when the startup script has not completed (exited) in the given time.
  • troubleshooting_url (String) A URL to a document with instructions for troubleshooting problems with the agent.

Read-Only

  • 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 variable "CODER_AGENT_TOKEN" with this token to authenticate an agent.

Nested Schema for display_apps

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.

Nested Schema for metadata

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.