From c1775106351936c4d593a776ac18329c7be66335 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 02:02:17 +0000 Subject: [PATCH 01/16] docs: add documentation for Coder modules and their usage --- docs/about/contributing/modules.md | 336 +++++++++++++++++++++++++++++ 1 file changed, 336 insertions(+) create mode 100644 docs/about/contributing/modules.md diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md new file mode 100644 index 0000000000000..870be30371c14 --- /dev/null +++ b/docs/about/contributing/modules.md @@ -0,0 +1,336 @@ +# Coder modules + +Coder modules are reusable Terraform configurations that extend workspace functionality. They provide pre-built integrations for development tools, services, and environments. + +## Quick start + +Add a module to your template: + +```tf +module "code-server" { + source = "registry.coder.com/modules/code-server/coder" + version = "1.0.18" + agent_id = coder_agent.example.id +} +``` + +Browse available modules at [registry.coder.com](https://registry.coder.com). + +## How modules work + +Modules use standard Terraform syntax with Coder-specific resources: + +- **`coder_script`**: Runs installation and configuration scripts +- **`coder_app`**: Creates accessible applications in the workspace UI +- **`coder_env`**: Sets environment variables + +Example module structure: + +```tf +# Install and configure the service +resource "coder_script" "install" { + agent_id = var.agent_id + script = file("${path.module}/install.sh") +} + +# Make it accessible in the UI +resource "coder_app" "app" { + agent_id = var.agent_id + slug = "myapp" + display_name = "My App" + url = "http://localhost:8080" + icon = "/icon/app.svg" +} +``` + +## Using modules in templates + +### Basic usage + +```tf +terraform { + required_providers { + coder = { + source = "coder/coder" + version = ">= 2.0" + } + } +} + +# Your infrastructure resources +resource "coder_agent" "main" { + # ... agent configuration +} + +# Add modules +module "code-server" { + source = "registry.coder.com/modules/code-server/coder" + version = "1.0.18" + agent_id = coder_agent.main.id +} + +module "docker" { + source = "registry.coder.com/modules/docker/coder" + version = "1.0.11" + agent_id = coder_agent.main.id +} +``` + +### Configuration options + +Most modules accept configuration variables: + +```tf +module "code-server" { + source = "registry.coder.com/modules/code-server/coder" + version = "1.0.18" + agent_id = coder_agent.main.id + + # Configuration + port = 13337 + extensions = ["ms-python.python", "golang.go"] + folder = "/home/coder/project" +} +``` + +### Template parameters + +Use template parameters to make modules configurable: + +```tf +data "coder_parameter" "ide" { + name = "ide" + display_name = "IDE" + description = "Select your preferred IDE" + default = "code-server" + + option { + name = "VS Code (Web)" + value = "code-server" + icon = "/icon/code.svg" + } + + option { + name = "JetBrains Gateway" + value = "jetbrains" + icon = "/icon/jetbrains.svg" + } +} + +module "code-server" { + count = data.coder_parameter.ide.value == "code-server" ? 1 : 0 + source = "registry.coder.com/modules/code-server/coder" + version = "1.0.18" + agent_id = coder_agent.main.id +} + +module "jetbrains" { + count = data.coder_parameter.ide.value == "jetbrains" ? 1 : 0 + source = "registry.coder.com/modules/jetbrains-gateway/coder" + version = "1.0.12" + agent_id = coder_agent.main.id +} +``` + +## Popular modules + +### Development environments + +- **[code-server](https://registry.coder.com/modules/code-server)**: VS Code in the browser +- **[cursor](https://registry.coder.com/modules/cursor)**: Cursor editor with AI assistance +- **[jetbrains-gateway](https://registry.coder.com/modules/jetbrains-gateway)**: JetBrains IDEs +- **[vscode-desktop](https://registry.coder.com/modules/vscode-desktop)**: Local VS Code connection + +### Development tools + +- **[docker](https://registry.coder.com/modules/docker)**: Docker engine and CLI +- **[git-clone](https://registry.coder.com/modules/git-clone)**: Automatic repository cloning +- **[nodejs](https://registry.coder.com/modules/nodejs)**: Node.js runtime and npm +- **[python](https://registry.coder.com/modules/python)**: Python runtime and pip + +### Services + +- **[postgres](https://registry.coder.com/modules/postgres)**: PostgreSQL database +- **[redis](https://registry.coder.com/modules/redis)**: Redis cache +- **[jupyter](https://registry.coder.com/modules/jupyter)**: Jupyter notebooks + +## Module registry + +### Official vs community modules + +- **Official modules**: `registry.coder.com/modules/{name}/coder` (maintained by Coder team) +- **Community modules**: `registry.coder.com/modules/{namespace}/{name}/coder` + +### Version pinning + +Always pin module versions for stability: + +```tf +module "code-server" { + source = "registry.coder.com/modules/code-server/coder" + version = "1.0.18" # Pin to specific version + # version = "~> 1.0" # Allow patch updates + agent_id = coder_agent.main.id +} +``` + +## Creating modules + +### Module structure + +``` +my-module/ +├── main.tf # Terraform configuration +├── README.md # Documentation with frontmatter +└── main.test.ts # Test suite +``` + +### Basic module template + +```tf +terraform { + required_version = ">= 1.0" + required_providers { + coder = { + source = "coder/coder" + version = ">= 2.0" + } + } +} + +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +variable "port" { + type = number + description = "Port to run the service on." + default = 8080 +} + +data "coder_workspace" "me" {} + +resource "coder_script" "install" { + agent_id = var.agent_id + script = "#!/bin/bash\necho 'Installing service...'" +} + +resource "coder_app" "service" { + agent_id = var.agent_id + slug = "service" + display_name = "My Service" + url = "http://localhost:${var.port}" + icon = "/icon/service.svg" +} +``` + +### Required README frontmatter + +```yaml +--- +display_name: Module Name +description: Brief description of what the module does +icon: ../../../../.icons/service.svg +maintainer_github: your-username +verified: false +tags: [development, service] +--- +``` + +### Testing modules + +Create `main.test.ts`: + +```typescript +import { describe, expect, it } from "bun:test"; +import { runTerraformApply, runTerraformInit, testRequiredVariables } from "~test"; + +describe("my-module", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, { + agent_id: "test-agent", + }); + + it("creates resources", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "test-agent", + port: 8080, + }); + + expect(state.resources).toBeDefined(); + }); +}); +``` + +## Development workflow + +### Contributing to the registry + +1. Fork the [registry repository](https://github.com/coder/registry) +2. Create your module in `registry/{namespace}/modules/{module-name}/` +3. Test your module: `bun test` +4. Format code: `bun run fmt` +5. Submit a pull request + +### Local testing + +Test modules locally in templates before publishing: + +```tf +module "local-module" { + source = "./path/to/local/module" + agent_id = coder_agent.main.id +} +``` + +## Offline installations + +For air-gapped environments, modules can be vendored locally: + +1. Download module source code +2. Place in your template directory +3. Reference with local path: + +```tf +module "code-server" { + source = "./modules/code-server" + agent_id = coder_agent.main.id +} +``` + +## Troubleshooting + +### Common issues + +**Module script failures**: Module installation or startup scripts fail during workspace creation. Check the workspace build logs and agent startup logs for specific error messages. + +**Registry connection errors**: Network issues preventing module downloads from `registry.coder.com`. Ensure your Coder deployment can reach the internet or use [offline installations](#offline-installations). + +**Version not found**: Specified module version doesn't exist. Check available versions at [registry.coder.com](https://registry.coder.com) or use `version = "~> 1.0"` for automatic minor updates. + +**Missing agent_id**: All modules require the `agent_id` variable to attach to a workspace agent. + +**Provider version conflicts**: Module requires a newer Coder provider version than your deployment. Update your Coder installation or use an older module version. + +### Debugging + +Check workspace build logs and startup script output: + +```console +# View build logs +coder show --build + +# View startup script logs (from inside workspace) +cat /tmp/coder-startup-script.log + +# View specific script logs +cat /tmp/coder-script-.log +``` + +## Next steps + +- Browse modules at [registry.coder.com](https://registry.coder.com) +- Read the [template creation guide](../../tutorials/template-from-scratch.md) +- Learn about [external authentication](../../admin/external-auth/index.md) for Git modules From 75dec504ac9682c8fcfc5a48e98ed5a2f2017b2d Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 02:02:27 +0000 Subject: [PATCH 02/16] docs: add guide for module development in manifest --- docs/manifest.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/manifest.json b/docs/manifest.json index 5fbb98f94b006..29c8620221d6c 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -64,6 +64,12 @@ "description": "Security vulnerability disclosure policy", "path": "./about/contributing/SECURITY.md", "icon_path": "./images/icons/lock.svg" + }, + { + "title": "Modules", + "description": "Our guide for module development", + "path": "./about/contributing/modules.md", + "icon_path": "./images/icons/puzzle.svg" } ] } From b102e69678697b2820b7a02b8aa5b6174d75e956 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 02:20:12 +0000 Subject: [PATCH 03/16] docs: update module structure formatting in contributing guide --- docs/about/contributing/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 870be30371c14..82ccf8f49d205 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -178,7 +178,7 @@ module "code-server" { ### Module structure -``` +```text my-module/ ├── main.tf # Terraform configuration ├── README.md # Documentation with frontmatter From 7a906b77cb315dd5c4ef04d27bf115f4e37c9245 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 02:32:48 +0000 Subject: [PATCH 04/16] docs: add optional installation script and enhance resource configuration in module guide --- docs/about/contributing/modules.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 82ccf8f49d205..6ffc202e774d5 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -181,6 +181,7 @@ module "code-server" { ```text my-module/ ├── main.tf # Terraform configuration +├── run.sh # Installation/setup script (optional but recommended) ├── README.md # Documentation with frontmatter └── main.test.ts # Test suite ``` @@ -212,8 +213,13 @@ variable "port" { data "coder_workspace" "me" {} resource "coder_script" "install" { - agent_id = var.agent_id - script = "#!/bin/bash\necho 'Installing service...'" + agent_id = var.agent_id + display_name = "Install Service" + icon = "/icon/service.svg" + script = templatefile("${path.module}/run.sh", { + PORT = var.port + }) + run_on_start = true } resource "coder_app" "service" { From ffd13b018669bc2f5598c73d8acfc47d28c0fa54 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 16:02:43 +0000 Subject: [PATCH 05/16] docs: enhance module contribution guide with architecture overview and detailed resource explanations --- docs/about/contributing/modules.md | 574 +++++++++++++++++------------ 1 file changed, 330 insertions(+), 244 deletions(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 6ffc202e774d5..b2f510856d8be 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -1,342 +1,428 @@ # Coder modules -Coder modules are reusable Terraform configurations that extend workspace functionality. They provide pre-built integrations for development tools, services, and environments. +Coder modules are reusable Terraform configurations that extend workspace functionality through the Coder Terraform provider. This guide focuses on understanding and creating effective modules. + +## Architecture Overview + +Understanding how modules fit into the Coder ecosystem: + +```mermaid +flowchart LR + subgraph Registry["🌐 Module Registry"] + ModuleCode["📦 Modules
Terraform configurations
with coder resources"] + StarterTemplates["📋 Starter Templates
Infrastructure-specific bases
(Docker, AWS, GCP, etc.)"] + end + + subgraph CoderInstance["🏢 Your Coder Instance"] + Template["📄 Template
References modules
from registry"] + + subgraph ModuleResources["🔧 Module Resources"] + Script["📜 coder_script
Installation scripts"] + App["🖥️ coder_app
UI applications"] + Env["🌍 coder_env
Environment variables"] + end + end + + subgraph Workspace["💻 Developer Workspace"] + Agent["🤖 Coder Agent"] + + subgraph Results["Results"] + Tools["🛠️ Installed Tools
IDEs, CLIs, Services"] + Apps["📱 Accessible Apps
Web interfaces"] + Environment["⚙️ Configured Environment
Variables, paths, settings"] + end + end + + %% Module flow + ModuleCode -->|"Referenced by"| Template + StarterTemplates -->|"Used as base for"| Template + + %% Template to resources + Template --> Script + Template --> App + Template --> Env + + %% Resources to agent + Script --> Agent + App --> Agent + Env --> Agent + + %% Agent to results + Agent --> Tools + Agent --> Apps + Agent --> Environment + + %% Styling + style Registry fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px,color:#000000 + style ModuleCode fill:#c8e6c9,stroke:#388e3c,stroke-width:2px,color:#000000 + style StarterTemplates fill:#c8e6c9,stroke:#388e3c,stroke-width:2px,color:#000000 + + style CoderInstance fill:#e3f2fd,stroke:#1976d2,stroke-width:2px,color:#000000 + style Template fill:#bbdefb,stroke:#1e88e5,stroke-width:2px,color:#000000 + style ModuleResources fill:#90caf9,stroke:#42a5f5,stroke-width:2px,color:#000000 + style Script fill:#90caf9,stroke:#42a5f5,stroke-width:1px,color:#000000 + style App fill:#90caf9,stroke:#42a5f5,stroke-width:1px,color:#000000 + style Env fill:#90caf9,stroke:#42a5f5,stroke-width:1px,color:#000000 + + style Workspace fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#000000 + style Agent fill:#ffcc02,stroke:#ff9800,stroke-width:2px,color:#000000 + style Results fill:#ffe0b2,stroke:#ffa726,stroke-width:2px,color:#000000 + style Tools fill:#ffe0b2,stroke:#ffa726,stroke-width:1px,color:#000000 + style Apps fill:#ffe0b2,stroke:#ffa726,stroke-width:1px,color:#000000 + style Environment fill:#ffe0b2,stroke:#ffa726,stroke-width:1px,color:#000000 +``` + +**How Modules Work in the Coder Ecosystem:** + +1. **Module Registry**: External registry hosts reusable modules and starter templates + - Modules are Terraform configurations using Coder-specific resources + - Starter templates provide infrastructure-specific bases (Docker, AWS, GCP, etc.) to start building your own templates + - Community and official modules available at [registry.coder.com](https://registry.coder.com) + +2. **Template Development**: Your Coder templates reference modules from the registry + - Use starter templates as infrastructure-specific starting points for your own templates + - Reference individual modules to add functionality to your templates + - Modules add `coder_script`, `coder_app`, and `coder_env` resources to templates -## Quick start +3. **Workspace Execution**: When workspaces are created, modules run through the Coder agent + - **Scripts** install and configure tools (IDEs, languages, services) + - **Apps** provide web interfaces accessible through Coder dashboard + - **Environment** sets up variables, paths, and development settings -Add a module to your template: +**Example Flow**: A template references the `code-server` module → Module adds a `coder_script` to install VS Code and a `coder_app` for browser access → Agent executes the script and serves the app → Developer gets VS Code in their workspace + +## Module Integration ```tf -module "code-server" { - source = "registry.coder.com/modules/code-server/coder" - version = "1.0.18" - agent_id = coder_agent.example.id +module "example" { + source = "registry.coder.com/modules/example/coder" + version = "1.0.0" + agent_id = coder_agent.main.id } ``` Browse available modules at [registry.coder.com](https://registry.coder.com). -## How modules work - -Modules use standard Terraform syntax with Coder-specific resources: +## Module Structure -- **`coder_script`**: Runs installation and configuration scripts -- **`coder_app`**: Creates accessible applications in the workspace UI -- **`coder_env`**: Sets environment variables +Every module consists of exactly four files: -Example module structure: - -```tf -# Install and configure the service -resource "coder_script" "install" { - agent_id = var.agent_id - script = file("${path.module}/install.sh") -} - -# Make it accessible in the UI -resource "coder_app" "app" { - agent_id = var.agent_id - slug = "myapp" - display_name = "My App" - url = "http://localhost:8080" - icon = "/icon/app.svg" -} +``` +module-name/ +├── main.tf # Terraform configuration with Coder resources +├── main.test.ts # Test suite +├── README.md # Documentation with frontmatter +└── run.sh # Installation script ``` -## Using modules in templates +### File Purposes -### Basic usage +- **`main.tf`**: Primary Terraform configuration defining Coder resources +- **`main.test.ts`**: Test suite validating module functionality +- **`README.md`**: Documentation with required frontmatter and usage examples +- **`run.sh`**: Shell script for software installation and configuration -```tf -terraform { - required_providers { - coder = { - source = "coder/coder" - version = ">= 2.0" - } - } -} +## Understanding Coder Resources -# Your infrastructure resources -resource "coder_agent" "main" { - # ... agent configuration -} +The Coder Terraform provider offers several resource types for different aspects of workspace functionality. Understanding when and how to use each resource is crucial for effective module development. -# Add modules -module "code-server" { - source = "registry.coder.com/modules/code-server/coder" - version = "1.0.18" - agent_id = coder_agent.main.id -} +### Coder Resources -module "docker" { - source = "registry.coder.com/modules/docker/coder" - version = "1.0.11" - agent_id = coder_agent.main.id -} -``` +#### coder_script - Command Execution -### Configuration options +Execute commands during workspace lifecycle events. This is the primary mechanism for software installation, service configuration, and environment setup. -Most modules accept configuration variables: +**When to use**: +- Installing software packages, binaries, or development tools +- Configuring services and generating configuration files +- Setting up directories, permissions, and initial workspace state +- Running background services or daemons -```tf -module "code-server" { - source = "registry.coder.com/modules/code-server/coder" - version = "1.0.18" - agent_id = coder_agent.main.id +**Key properties**: +- `agent_id`: The Coder agent to execute the script on +- `display_name`: Name shown in the Coder dashboard during execution +- `run_on_start`: Execute when workspace starts (most common) +- `run_on_stop`: Execute during workspace shutdown for cleanup +- `script`: The actual shell script content to execute +- `start_blocks_login`: Whether script completion is required before user access - # Configuration - port = 13337 - extensions = ["ms-python.python", "golang.go"] - folder = "/home/coder/project" +Example: +```tf +resource "coder_script" "install" { + agent_id = var.agent_id + display_name = "Install Tool" + script = templatefile("${path.module}/run.sh", { + VERSION = var.version + ARCH = data.coder_provisioner.me.arch + }) + run_on_start = true + start_blocks_login = true } ``` -### Template parameters +#### coder_app - User Interface -Use template parameters to make modules configurable: +Create accessible applications in the Coder workspace interface, providing users with one-click access to tools and services. -```tf -data "coder_parameter" "ide" { - name = "ide" - display_name = "IDE" - description = "Select your preferred IDE" - default = "code-server" - - option { - name = "VS Code (Web)" - value = "code-server" - icon = "/icon/code.svg" - } +**When to use**: +- Exposing web-based development tools (IDEs, dashboards) +- Creating links to desktop applications via custom protocols +- Providing access to running services - option { - name = "JetBrains Gateway" - value = "jetbrains" - icon = "/icon/jetbrains.svg" - } -} +**Key properties**: +- `agent_id`: The Coder agent +- `external`: `true` for protocol handlers, `false` for web apps +- `healthcheck`: Monitor service availability +- `subdomain`: Access method for web apps +- `url`: Service URL or protocol handler -module "code-server" { - count = data.coder_parameter.ide.value == "code-server" ? 1 : 0 - source = "registry.coder.com/modules/code-server/coder" - version = "1.0.18" - agent_id = coder_agent.main.id -} - -module "jetbrains" { - count = data.coder_parameter.ide.value == "jetbrains" ? 1 : 0 - source = "registry.coder.com/modules/jetbrains-gateway/coder" - version = "1.0.12" - agent_id = coder_agent.main.id +Example: +```tf +resource "coder_app" "service" { + agent_id = var.agent_id + slug = "service" + url = "http://localhost:${var.port}" + + healthcheck { + url = "http://localhost:${var.port}/health" + interval = 5 + threshold = 6 + } } ``` -## Popular modules - -### Development environments - -- **[code-server](https://registry.coder.com/modules/code-server)**: VS Code in the browser -- **[cursor](https://registry.coder.com/modules/cursor)**: Cursor editor with AI assistance -- **[jetbrains-gateway](https://registry.coder.com/modules/jetbrains-gateway)**: JetBrains IDEs -- **[vscode-desktop](https://registry.coder.com/modules/vscode-desktop)**: Local VS Code connection +#### coder_env - Environment Variables -### Development tools +Set environment variables in workspace sessions for tool configuration and authentication. -- **[docker](https://registry.coder.com/modules/docker)**: Docker engine and CLI -- **[git-clone](https://registry.coder.com/modules/git-clone)**: Automatic repository cloning -- **[nodejs](https://registry.coder.com/modules/nodejs)**: Node.js runtime and npm -- **[python](https://registry.coder.com/modules/python)**: Python runtime and pip +**When to use**: +- Configuring development tools and CLIs +- Providing authentication tokens +- Setting service endpoints -### Services +Example: +```tf +resource "coder_env" "config" { + agent_id = var.agent_id + name = "TOOL_CONFIG" + value = jsonencode(var.config) +} +``` -- **[postgres](https://registry.coder.com/modules/postgres)**: PostgreSQL database -- **[redis](https://registry.coder.com/modules/redis)**: Redis cache -- **[jupyter](https://registry.coder.com/modules/jupyter)**: Jupyter notebooks +#### Data Sources -## Module registry +Access workspace context through Coder data sources: -### Official vs community modules +```tf +data "coder_provisioner" "me" {} +# Provides: arch, os for platform-specific logic -- **Official modules**: `registry.coder.com/modules/{name}/coder` (maintained by Coder team) -- **Community modules**: `registry.coder.com/modules/{namespace}/{name}/coder` +data "coder_workspace" "me" {} +# Provides: name, id, access_url, start_count -### Version pinning +data "coder_workspace_owner" "me" {} +# Provides: name, email, full_name +``` -Always pin module versions for stability: +### Variable Design +**Required Variables**: ```tf -module "code-server" { - source = "registry.coder.com/modules/code-server/coder" - version = "1.0.18" # Pin to specific version - # version = "~> 1.0" # Allow patch updates - agent_id = coder_agent.main.id +variable "agent_id" { + type = string + description = "The ID of a Coder agent." + # No default - always required } ``` -## Creating modules - -### Module structure - -```text -my-module/ -├── main.tf # Terraform configuration -├── run.sh # Installation/setup script (optional but recommended) -├── README.md # Documentation with frontmatter -└── main.test.ts # Test suite -``` - -### Basic module template - +**Optional Variables with Validation**: ```tf -terraform { - required_version = ">= 1.0" - required_providers { - coder = { - source = "coder/coder" - version = ">= 2.0" - } +variable "version" { + type = string + description = "Software version to install." + default = "latest" + validation { + condition = can(regex("^(latest|[0-9]+\\.[0-9]+\\.[0-9]+)$", var.version)) + error_message = "Version must be 'latest' or semantic version (e.g., 1.2.3)." } } +``` -variable "agent_id" { - type = string - description = "The ID of a Coder agent." +**Complex Configuration Objects**: +```tf +variable "service_config" { + type = object({ + port = optional(number, 8080) + enable_ssl = optional(bool, false) + log_level = optional(string, "info") + features = optional(list(string), []) + }) + description = "Service configuration options." + default = {} } +``` -variable "port" { - type = number - description = "Port to run the service on." - default = 8080 +**Sensitive Variables**: +```tf +variable "api_key" { + type = string + description = "API key for service authentication." + default = "" + sensitive = true } +``` -data "coder_workspace" "me" {} +### Script Development +**Template-driven scripts** pass variables to your `run.sh`: +```tf resource "coder_script" "install" { - agent_id = var.agent_id - display_name = "Install Service" - icon = "/icon/service.svg" + agent_id = var.agent_id script = templatefile("${path.module}/run.sh", { - PORT = var.port + VERSION = var.version + ARCH = data.coder_provisioner.me.arch + CONFIG = jsonencode(var.config) + WORKSPACE = data.coder_workspace.me.name + USER_EMAIL = data.coder_workspace_owner.me.email }) - run_on_start = true } +``` + +**Error handling** in your shell scripts: +```bash +#!/bin/bash +set -euo pipefail + +# Platform detection +case "${ARCH}" in + "amd64") ARCH_SUFFIX="" ;; + "arm64") ARCH_SUFFIX="-arm64" ;; + *) echo "ERROR: Unsupported architecture: ${ARCH}"; exit 1 ;; +esac + +# Tool installation with error checking +if ! command -v tool &> /dev/null; then + echo "Installing tool..." + # Installation commands +fi +``` + +### Integration Patterns +**Conditional resources** using `start_count`: +```tf resource "coder_app" "service" { - agent_id = var.agent_id - slug = "service" - display_name = "My Service" - url = "http://localhost:${var.port}" - icon = "/icon/service.svg" + count = data.coder_workspace.me.start_count + agent_id = var.agent_id + # Only created when workspace is running } ``` -### Required README frontmatter - -```yaml ---- -display_name: Module Name -description: Brief description of what the module does -icon: ../../../../.icons/service.svg -maintainer_github: your-username -verified: false -tags: [development, service] ---- +**Multi-step installation** with dependencies: +```tf +resource "coder_script" "install_deps" { + agent_id = var.agent_id + script = "install_dependencies.sh" + order = 1 +} + +resource "coder_script" "configure_service" { + agent_id = var.agent_id + script = "configure_service.sh" + depends_on = [coder_script.install_deps] + order = 2 +} ``` -### Testing modules +**Health checks** for web services: +```tf +resource "coder_app" "service" { + agent_id = var.agent_id + url = "http://localhost:${var.port}" + + healthcheck { + url = "http://localhost:${var.port}/health" + interval = 5 + threshold = 6 + } +} +``` -Create `main.test.ts`: +## Testing and Documentation -```typescript -import { describe, expect, it } from "bun:test"; -import { runTerraformApply, runTerraformInit, testRequiredVariables } from "~test"; +### Module Testing -describe("my-module", async () => { - await runTerraformInit(import.meta.dir); +While not mandatory, **tests are recommended** for all modules. A `main.test.ts` file validates that the module works correctly. Tests use **Bun** as the test runner and verify that: - testRequiredVariables(import.meta.dir, { - agent_id: "test-agent", - }); +- **Custom configurations** work with different variable values +- **Default configuration** creates expected resources +- **Input validation** catches invalid parameters +- **Required variables** are properly validated - it("creates resources", async () => { - const state = await runTerraformApply(import.meta.dir, { - agent_id: "test-agent", - port: 8080, - }); +The test framework provides utilities from `~test` import to: +- Initialize Terraform in the module directory +- Apply Terraform with test variables +- Validate the resulting infrastructure state +- Test error conditions and edge cases - expect(state.resources).toBeDefined(); - }); -}); -``` +Tests run in Docker with `--network=host` capabilities and help ensure module quality and reliability. -## Development workflow +### Documentation Requirements -### Contributing to the registry +Every module requires a `README.md` with YAML frontmatter containing metadata like display name, description, icon, maintainer, and tags. The README must include: -1. Fork the [registry repository](https://github.com/coder/registry) -2. Create your module in `registry/{namespace}/modules/{module-name}/` -3. Test your module: `bun test` -4. Format code: `bun run fmt` -5. Submit a pull request +- **Purpose and functionality** - What the module does and when to use it +- **Variable documentation** - All input variables with types, defaults, and descriptions +- **Resource listing** - What Coder resources the module creates +- **Usage examples** - Basic and advanced configuration examples +- **Requirements** - Any prerequisites or dependencies -### Local testing +The documentation format is validated automatically and must pass validation before modules can be accepted. See the [Registry Contributing Guide](https://github.com/coder/registry/blob/main/CONTRIBUTING.md) for detailed formatting requirements and examples. -Test modules locally in templates before publishing: +## Common Use Case Patterns -```tf -module "local-module" { - source = "./path/to/local/module" - agent_id = coder_agent.main.id -} -``` +### External IDE Integration -## Offline installations +**Browser-based IDE Pattern**: Install web-based development environment with health monitoring and configuration management. -For air-gapped environments, modules can be vendored locally: +**Desktop IDE Pattern**: Provide protocol-based integration for native applications with backend service management. -1. Download module source code -2. Place in your template directory -3. Reference with local path: +**Editor Extension Pattern**: Configure existing editors with workspace-specific settings and extensions. -```tf -module "code-server" { - source = "./modules/code-server" - agent_id = coder_agent.main.id -} -``` +### Authentication and Secrets -## Troubleshooting +**OAuth Integration Pattern**: Handle external authentication flows with token management and service configuration. -### Common issues +**API Key Management Pattern**: Securely distribute credentials and configure authenticated tools. -**Module script failures**: Module installation or startup scripts fail during workspace creation. Check the workspace build logs and agent startup logs for specific error messages. +**Certificate Management Pattern**: Handle SSL certificates and secure communication setup. -**Registry connection errors**: Network issues preventing module downloads from `registry.coder.com`. Ensure your Coder deployment can reach the internet or use [offline installations](#offline-installations). +### Development Environment Setup -**Version not found**: Specified module version doesn't exist. Check available versions at [registry.coder.com](https://registry.coder.com) or use `version = "~> 1.0"` for automatic minor updates. +**Language Runtime Pattern**: Install and configure programming language environments with package managers. -**Missing agent_id**: All modules require the `agent_id` variable to attach to a workspace agent. +**Database Service Pattern**: Deploy and configure database services with connection management. -**Provider version conflicts**: Module requires a newer Coder provider version than your deployment. Update your Coder installation or use an older module version. +**Configuration Management Pattern**: Apply dotfiles, settings, and workspace personalization. -### Debugging +## Contributing to the Registry -Check workspace build logs and startup script output: +The [Coder Registry](https://github.com/coder/registry) hosts all community and official modules. For detailed contribution guidelines, code standards, and submission processes, refer to the [Registry Contributing Guide](https://github.com/coder/registry/blob/main/CONTRIBUTING.md). -```console -# View build logs -coder show --build +**Quick contribution steps**: -# View startup script logs (from inside workspace) -cat /tmp/coder-startup-script.log +1. Fork the [registry repository](https://github.com/coder/registry) +2. Follow the [registry contribution guidelines](https://github.com/coder/registry/blob/main/CONTRIBUTING.md) for module creation process +3. Implement tests: `bun test` +4. Format code: `bun run fmt` +5. Validate documentation: `bun run readme-validate` +6. Submit pull request with detailed description -# View specific script logs -cat /tmp/coder-script-.log -``` +**Important**: The registry repository contains specific requirements for module structure, testing, documentation format, and submission process. Always consult the [official contributing documentation](https://github.com/coder/registry/blob/main/CONTRIBUTING.md) for the most current guidelines. -## Next steps +## Next Steps -- Browse modules at [registry.coder.com](https://registry.coder.com) -- Read the [template creation guide](../../tutorials/template-from-scratch.md) -- Learn about [external authentication](../../admin/external-auth/index.md) for Git modules +- Explore [registry.coder.com](https://registry.coder.com) for existing modules +- Review [Coder Terraform provider documentation](https://registry.terraform.io/providers/coder/coder/latest/docs) +- Study [existing module implementations](https://github.com/coder/registry/tree/main/registry/coder/modules) +- Join the [Coder community](https://discord.gg/coder) for support and collaboration From ba1bba334c03eb439fe0979ce07099eb7e1d112c Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 16:08:59 +0000 Subject: [PATCH 06/16] docs: improve link visibility in architecture overview with styled arrows --- docs/about/contributing/modules.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index b2f510856d8be..990c9848f8a90 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -34,8 +34,8 @@ flowchart LR end %% Module flow - ModuleCode -->|"Referenced by"| Template - StarterTemplates -->|"Used as base for"| Template + ModuleCode -->|" Referenced by "| Template + StarterTemplates -->|" Used as base for "| Template %% Template to resources Template --> Script @@ -70,6 +70,9 @@ flowchart LR style Tools fill:#ffe0b2,stroke:#ffa726,stroke-width:1px,color:#000000 style Apps fill:#ffe0b2,stroke:#ffa726,stroke-width:1px,color:#000000 style Environment fill:#ffe0b2,stroke:#ffa726,stroke-width:1px,color:#000000 + + %% Link styling to make arrows visible + linkStyle default stroke:#333333,stroke-width:2px ``` **How Modules Work in the Coder Ecosystem:** From 33793473aa4825b52ac703e9d1e58d692e07e478 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 16:47:56 +0000 Subject: [PATCH 07/16] docs(modules): linting --- docs/about/contributing/modules.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 990c9848f8a90..d5c8beaf90c11 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -110,7 +110,7 @@ Browse available modules at [registry.coder.com](https://registry.coder.com). Every module consists of exactly four files: -``` +```text module-name/ ├── main.tf # Terraform configuration with Coder resources ├── main.test.ts # Test suite @@ -136,12 +136,14 @@ The Coder Terraform provider offers several resource types for different aspects Execute commands during workspace lifecycle events. This is the primary mechanism for software installation, service configuration, and environment setup. **When to use**: + - Installing software packages, binaries, or development tools - Configuring services and generating configuration files - Setting up directories, permissions, and initial workspace state - Running background services or daemons **Key properties**: + - `agent_id`: The Coder agent to execute the script on - `display_name`: Name shown in the Coder dashboard during execution - `run_on_start`: Execute when workspace starts (most common) @@ -150,6 +152,7 @@ Execute commands during workspace lifecycle events. This is the primary mechanis - `start_blocks_login`: Whether script completion is required before user access Example: + ```tf resource "coder_script" "install" { agent_id = var.agent_id @@ -168,11 +171,13 @@ resource "coder_script" "install" { Create accessible applications in the Coder workspace interface, providing users with one-click access to tools and services. **When to use**: + - Exposing web-based development tools (IDEs, dashboards) - Creating links to desktop applications via custom protocols - Providing access to running services **Key properties**: + - `agent_id`: The Coder agent - `external`: `true` for protocol handlers, `false` for web apps - `healthcheck`: Monitor service availability @@ -180,6 +185,7 @@ Create accessible applications in the Coder workspace interface, providing users - `url`: Service URL or protocol handler Example: + ```tf resource "coder_app" "service" { agent_id = var.agent_id @@ -199,11 +205,13 @@ resource "coder_app" "service" { Set environment variables in workspace sessions for tool configuration and authentication. **When to use**: + - Configuring development tools and CLIs - Providing authentication tokens - Setting service endpoints Example: + ```tf resource "coder_env" "config" { agent_id = var.agent_id @@ -230,6 +238,7 @@ data "coder_workspace_owner" "me" {} ### Variable Design **Required Variables**: + ```tf variable "agent_id" { type = string @@ -239,6 +248,7 @@ variable "agent_id" { ``` **Optional Variables with Validation**: + ```tf variable "version" { type = string @@ -252,6 +262,7 @@ variable "version" { ``` **Complex Configuration Objects**: + ```tf variable "service_config" { type = object({ @@ -266,6 +277,7 @@ variable "service_config" { ``` **Sensitive Variables**: + ```tf variable "api_key" { type = string @@ -278,6 +290,7 @@ variable "api_key" { ### Script Development **Template-driven scripts** pass variables to your `run.sh`: + ```tf resource "coder_script" "install" { agent_id = var.agent_id @@ -292,6 +305,7 @@ resource "coder_script" "install" { ``` **Error handling** in your shell scripts: + ```bash #!/bin/bash set -euo pipefail @@ -313,6 +327,7 @@ fi ### Integration Patterns **Conditional resources** using `start_count`: + ```tf resource "coder_app" "service" { count = data.coder_workspace.me.start_count @@ -322,6 +337,7 @@ resource "coder_app" "service" { ``` **Multi-step installation** with dependencies: + ```tf resource "coder_script" "install_deps" { agent_id = var.agent_id @@ -338,6 +354,7 @@ resource "coder_script" "configure_service" { ``` **Health checks** for web services: + ```tf resource "coder_app" "service" { agent_id = var.agent_id @@ -363,6 +380,7 @@ While not mandatory, **tests are recommended** for all modules. A `main.test.ts` - **Required variables** are properly validated The test framework provides utilities from `~test` import to: + - Initialize Terraform in the module directory - Apply Terraform with test variables - Validate the resulting infrastructure state From b531be1f975bd05f76d8fe82bc544947662fc70b Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 18:49:10 +0000 Subject: [PATCH 08/16] docs(modules): expand module types section with examples for IDE, Helper, Desktop, AI, Integration, and Web-based Tools and remove duplicate explanation from end of doc. --- docs/about/contributing/modules.md | 91 +++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 26 deletions(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index d5c8beaf90c11..7a7e9e3e640ea 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -94,6 +94,71 @@ flowchart LR **Example Flow**: A template references the `code-server` module → Module adds a `coder_script` to install VS Code and a `coder_app` for browser access → Agent executes the script and serves the app → Developer gets VS Code in their workspace +## Module Types and Examples + +The Coder Registry organizes modules into different categories based on their functionality. Here are the main types with examples of actual available modules: + +### [IDE Modules](https://registry.coder.com/modules?search=tag%3Aide) +Integrate development environments and code editors into workspaces. + +- **code-server**: VS Code in the browser +- **Cursor IDE**: Add a one-click button to launch Cursor IDE +- **JetBrains Gateway**: Add a one-click button to launch JetBrains Gateway IDEs in the dashboard +- **Jupyter Notebook**: A module that adds Jupyter Notebook in your Coder template +- **JupyterLab**: A module that adds JupyterLab in your Coder template +- **VS Code Desktop**: Add a one-click button to launch VS Code Desktop +- **VS Code Web**: VS Code Web - Visual Studio Code in the browser +- **Windsurf Editor**: Add a one-click button to launch Windsurf Editor + +### [Helper Modules](https://registry.coder.com/modules?search=tag%3Ahelper) +Simplify template creation and workspace configuration. + +- **AWS Region**: A parameter with human region names and icons +- **Azure Region**: A parameter with human region names and icons +- **Coder Login**: Automatically logs the user into Coder on their workspace +- **Dotfiles**: Allow developers to optionally bring their own dotfiles repository to customize their shell and IDE settings +- **Fly.io Region**: A parameter with human region names and icons +- **GCP Region**: Add Google Cloud Platform regions to your Coder template +- **Git Clone**: Clone a Git repository by URL and skip if it exists +- **Git commit signing**: Configures Git to sign commits using your Coder SSH key +- **Git Config**: Stores Git configuration from Coder credentials +- **Github Upload Public Key**: Automates uploading Coder public key to Github so users don't have to +- **Personalize**: Allow developers to customize their workspace on start +- **Slack Me**: Send a Slack message when a command finishes inside a workspace + +### [Desktop Modules](https://registry.coder.com/modules?search=tag%3Adesktop) +Provide graphical desktop environments for visual development workflows. + +- **Amazon DCV Windows**: Amazon DCV Server and Web Client for Windows +- **KasmVNC**: A modern open source VNC server +- **Windows RDP**: RDP Server and Web Client, powered by Devolutions Gateway +- **Windows RDP Desktop**: Enable RDP on Windows and add a one-click Coder Desktop button for seamless access + +### [AI Modules](https://registry.coder.com/modules?search=tag%3Aai) +Integrate AI-powered development tools and assistants. + +- **Aider**: Run Aider AI pair programming in your workspace +- **Amazon Q**: Run Amazon Q in your workspace to access Amazon's AI coding assistant +- **Claude Code**: Run Claude Code in your workspace +- **Goose**: Run Goose in your workspace + +### [Integration Modules](https://registry.coder.com/modules?search=tag%3Aintegration) +Connect with external services and platforms. + +- **Hashicorp Vault Integration (GitHub)**: Authenticates with Vault using GitHub +- **Hashicorp Vault Integration (JWT)**: Authenticates with Vault using a JWT from Coder's OIDC provider +- **Hashicorp Vault Integration (Token)**: Authenticates with Vault using Token +- **HCP Vault Secrets**: Fetch secrets from HCP Vault +- **JFrog (OAuth)**: Install the JF CLI and authenticate with Artifactory using OAuth +- **JFrog (Token)**: Install the JF CLI and authenticate with Artifactory using Artifactory terraform provider + +### [Web-based Tools](https://registry.coder.com/modules?search=tag%3Aweb) +Browser-accessible applications and interfaces. + +- **File Browser**: A file browser for your workspace + +Browse all available modules and explore specific categories at [registry.coder.com](https://registry.coder.com). + ## Module Integration ```tf @@ -400,32 +465,6 @@ Every module requires a `README.md` with YAML frontmatter containing metadata li The documentation format is validated automatically and must pass validation before modules can be accepted. See the [Registry Contributing Guide](https://github.com/coder/registry/blob/main/CONTRIBUTING.md) for detailed formatting requirements and examples. -## Common Use Case Patterns - -### External IDE Integration - -**Browser-based IDE Pattern**: Install web-based development environment with health monitoring and configuration management. - -**Desktop IDE Pattern**: Provide protocol-based integration for native applications with backend service management. - -**Editor Extension Pattern**: Configure existing editors with workspace-specific settings and extensions. - -### Authentication and Secrets - -**OAuth Integration Pattern**: Handle external authentication flows with token management and service configuration. - -**API Key Management Pattern**: Securely distribute credentials and configure authenticated tools. - -**Certificate Management Pattern**: Handle SSL certificates and secure communication setup. - -### Development Environment Setup - -**Language Runtime Pattern**: Install and configure programming language environments with package managers. - -**Database Service Pattern**: Deploy and configure database services with connection management. - -**Configuration Management Pattern**: Apply dotfiles, settings, and workspace personalization. - ## Contributing to the Registry The [Coder Registry](https://github.com/coder/registry) hosts all community and official modules. For detailed contribution guidelines, code standards, and submission processes, refer to the [Registry Contributing Guide](https://github.com/coder/registry/blob/main/CONTRIBUTING.md). From 252e34c85e9f449bd8fe9f6b222d69a9d336fb62 Mon Sep 17 00:00:00 2001 From: DevCats Date: Thu, 26 Jun 2025 13:50:43 -0500 Subject: [PATCH 09/16] Update docs/about/contributing/modules.md Co-authored-by: Atif Ali --- docs/about/contributing/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 7a7e9e3e640ea..05487aa1f84ba 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -297,7 +297,7 @@ data "coder_workspace" "me" {} # Provides: name, id, access_url, start_count data "coder_workspace_owner" "me" {} -# Provides: name, email, full_name +# Provides: name, email, full_name, groups of the workspace owner. ``` ### Variable Design From 8bb9050875f0f2d7abbee5e22f62e6d031bb4b53 Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 18:52:45 +0000 Subject: [PATCH 10/16] docs(modules): remove testing and documentation sections --- docs/about/contributing/modules.md | 32 ------------------------------ 1 file changed, 32 deletions(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 05487aa1f84ba..c9c125d4fdbc8 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -433,38 +433,6 @@ resource "coder_app" "service" { } ``` -## Testing and Documentation - -### Module Testing - -While not mandatory, **tests are recommended** for all modules. A `main.test.ts` file validates that the module works correctly. Tests use **Bun** as the test runner and verify that: - -- **Custom configurations** work with different variable values -- **Default configuration** creates expected resources -- **Input validation** catches invalid parameters -- **Required variables** are properly validated - -The test framework provides utilities from `~test` import to: - -- Initialize Terraform in the module directory -- Apply Terraform with test variables -- Validate the resulting infrastructure state -- Test error conditions and edge cases - -Tests run in Docker with `--network=host` capabilities and help ensure module quality and reliability. - -### Documentation Requirements - -Every module requires a `README.md` with YAML frontmatter containing metadata like display name, description, icon, maintainer, and tags. The README must include: - -- **Purpose and functionality** - What the module does and when to use it -- **Variable documentation** - All input variables with types, defaults, and descriptions -- **Resource listing** - What Coder resources the module creates -- **Usage examples** - Basic and advanced configuration examples -- **Requirements** - Any prerequisites or dependencies - -The documentation format is validated automatically and must pass validation before modules can be accepted. See the [Registry Contributing Guide](https://github.com/coder/registry/blob/main/CONTRIBUTING.md) for detailed formatting requirements and examples. - ## Contributing to the Registry The [Coder Registry](https://github.com/coder/registry) hosts all community and official modules. For detailed contribution guidelines, code standards, and submission processes, refer to the [Registry Contributing Guide](https://github.com/coder/registry/blob/main/CONTRIBUTING.md). From cc76ef15ee1432bd91e62eac99696315aac4a51d Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 18:55:39 +0000 Subject: [PATCH 11/16] docs(modules): remove contributing guide and lint --- docs/about/contributing/modules.md | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index c9c125d4fdbc8..9d6a07624c8e6 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -99,6 +99,7 @@ flowchart LR The Coder Registry organizes modules into different categories based on their functionality. Here are the main types with examples of actual available modules: ### [IDE Modules](https://registry.coder.com/modules?search=tag%3Aide) + Integrate development environments and code editors into workspaces. - **code-server**: VS Code in the browser @@ -111,6 +112,7 @@ Integrate development environments and code editors into workspaces. - **Windsurf Editor**: Add a one-click button to launch Windsurf Editor ### [Helper Modules](https://registry.coder.com/modules?search=tag%3Ahelper) + Simplify template creation and workspace configuration. - **AWS Region**: A parameter with human region names and icons @@ -127,6 +129,7 @@ Simplify template creation and workspace configuration. - **Slack Me**: Send a Slack message when a command finishes inside a workspace ### [Desktop Modules](https://registry.coder.com/modules?search=tag%3Adesktop) + Provide graphical desktop environments for visual development workflows. - **Amazon DCV Windows**: Amazon DCV Server and Web Client for Windows @@ -135,6 +138,7 @@ Provide graphical desktop environments for visual development workflows. - **Windows RDP Desktop**: Enable RDP on Windows and add a one-click Coder Desktop button for seamless access ### [AI Modules](https://registry.coder.com/modules?search=tag%3Aai) + Integrate AI-powered development tools and assistants. - **Aider**: Run Aider AI pair programming in your workspace @@ -143,6 +147,7 @@ Integrate AI-powered development tools and assistants. - **Goose**: Run Goose in your workspace ### [Integration Modules](https://registry.coder.com/modules?search=tag%3Aintegration) + Connect with external services and platforms. - **Hashicorp Vault Integration (GitHub)**: Authenticates with Vault using GitHub @@ -153,6 +158,7 @@ Connect with external services and platforms. - **JFrog (Token)**: Install the JF CLI and authenticate with Artifactory using Artifactory terraform provider ### [Web-based Tools](https://registry.coder.com/modules?search=tag%3Aweb) + Browser-accessible applications and interfaces. - **File Browser**: A file browser for your workspace @@ -433,21 +439,6 @@ resource "coder_app" "service" { } ``` -## Contributing to the Registry - -The [Coder Registry](https://github.com/coder/registry) hosts all community and official modules. For detailed contribution guidelines, code standards, and submission processes, refer to the [Registry Contributing Guide](https://github.com/coder/registry/blob/main/CONTRIBUTING.md). - -**Quick contribution steps**: - -1. Fork the [registry repository](https://github.com/coder/registry) -2. Follow the [registry contribution guidelines](https://github.com/coder/registry/blob/main/CONTRIBUTING.md) for module creation process -3. Implement tests: `bun test` -4. Format code: `bun run fmt` -5. Validate documentation: `bun run readme-validate` -6. Submit pull request with detailed description - -**Important**: The registry repository contains specific requirements for module structure, testing, documentation format, and submission process. Always consult the [official contributing documentation](https://github.com/coder/registry/blob/main/CONTRIBUTING.md) for the most current guidelines. - ## Next Steps - Explore [registry.coder.com](https://registry.coder.com) for existing modules From 2c060408796bb2c918dd57616e85e0549fd7458a Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 19:06:04 +0000 Subject: [PATCH 12/16] docs(modules): enhance module list with hyperlinks for better navigation --- docs/about/contributing/modules.md | 70 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 9d6a07624c8e6..7932154fa05e4 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -102,66 +102,66 @@ The Coder Registry organizes modules into different categories based on their fu Integrate development environments and code editors into workspaces. -- **code-server**: VS Code in the browser -- **Cursor IDE**: Add a one-click button to launch Cursor IDE -- **JetBrains Gateway**: Add a one-click button to launch JetBrains Gateway IDEs in the dashboard -- **Jupyter Notebook**: A module that adds Jupyter Notebook in your Coder template -- **JupyterLab**: A module that adds JupyterLab in your Coder template -- **VS Code Desktop**: Add a one-click button to launch VS Code Desktop -- **VS Code Web**: VS Code Web - Visual Studio Code in the browser -- **Windsurf Editor**: Add a one-click button to launch Windsurf Editor +- **[code-server](https://registry.coder.com/modules/coder/code-server)**: VS Code in the browser +- **[Cursor](https://registry.coder.com/modules/coder/cursor)**: Add a one-click button to launch Cursor IDE +- **[JetBrains Gateway](https://registry.coder.com/modules/coder/jetbrains-gateway)**: Add a one-click button to launch JetBrains Gateway IDEs in the dashboard +- **[Jupyter Notebook](https://registry.coder.com/modules/coder/jupyter-notebook)**: A module that adds Jupyter Notebook in your Coder template +- **[JupyterLab](https://registry.coder.com/modules/coder/jupyterlab)**: A module that adds JupyterLab in your Coder template +- **[VS Code Desktop](https://registry.coder.com/modules/coder/vscode-desktop)**: Add a one-click button to launch VS Code Desktop +- **[VS Code Web](https://registry.coder.com/modules/coder/vscode-web)**: VS Code Web - Visual Studio Code in the browser +- **[Windsurf Editor](https://registry.coder.com/modules/coder/windsurf)**: Add a one-click button to launch Windsurf Editor ### [Helper Modules](https://registry.coder.com/modules?search=tag%3Ahelper) Simplify template creation and workspace configuration. -- **AWS Region**: A parameter with human region names and icons -- **Azure Region**: A parameter with human region names and icons -- **Coder Login**: Automatically logs the user into Coder on their workspace -- **Dotfiles**: Allow developers to optionally bring their own dotfiles repository to customize their shell and IDE settings -- **Fly.io Region**: A parameter with human region names and icons -- **GCP Region**: Add Google Cloud Platform regions to your Coder template -- **Git Clone**: Clone a Git repository by URL and skip if it exists -- **Git commit signing**: Configures Git to sign commits using your Coder SSH key -- **Git Config**: Stores Git configuration from Coder credentials -- **Github Upload Public Key**: Automates uploading Coder public key to Github so users don't have to -- **Personalize**: Allow developers to customize their workspace on start -- **Slack Me**: Send a Slack message when a command finishes inside a workspace +- **[AWS Region](https://registry.coder.com/modules/coder/aws-region)**: A parameter with human region names and icons +- **[Azure Region](https://registry.coder.com/modules/coder/azure-region)**: A parameter with human region names and icons +- **[Coder Login](https://registry.coder.com/modules/coder/coder-login)**: Automatically logs the user into Coder on their workspace +- **[Dotfiles](https://registry.coder.com/modules/coder/dotfiles)**: Allow developers to optionally bring their own dotfiles repository to customize their shell and IDE settings +- **[Fly.io Region](https://registry.coder.com/modules/coder/fly-region)**: A parameter with human region names and icons +- **[GCP Region](https://registry.coder.com/modules/coder/gcp-region)**: Add Google Cloud Platform regions to your Coder template +- **[Git Clone](https://registry.coder.com/modules/coder/git-clone)**: Clone a Git repository by URL and skip if it exists +- **[Git commit signing](https://registry.coder.com/modules/coder/git-commit-signing)**: Configures Git to sign commits using your Coder SSH key +- **[Git Config](https://registry.coder.com/modules/coder/git-config)**: Stores Git configuration from Coder credentials +- **[Github Upload Public Key](https://registry.coder.com/modules/coder/github-upload-public-key)**: Automates uploading Coder public key to Github so users don't have to +- **[Personalize](https://registry.coder.com/modules/coder/personalize)**: Allow developers to customize their workspace on start +- **[Slack Me](https://registry.coder.com/modules/coder/slackme)**: Send a Slack message when a command finishes inside a workspace ### [Desktop Modules](https://registry.coder.com/modules?search=tag%3Adesktop) Provide graphical desktop environments for visual development workflows. -- **Amazon DCV Windows**: Amazon DCV Server and Web Client for Windows -- **KasmVNC**: A modern open source VNC server -- **Windows RDP**: RDP Server and Web Client, powered by Devolutions Gateway -- **Windows RDP Desktop**: Enable RDP on Windows and add a one-click Coder Desktop button for seamless access +- **[Amazon DCV Windows](https://registry.coder.com/modules/coder/amazon-dcv-windows)**: Amazon DCV Server and Web Client for Windows +- **[KasmVNC](https://registry.coder.com/modules/coder/kasmvnc)**: A modern open source VNC server +- **[Windows RDP](https://registry.coder.com/modules/coder/windows-rdp)**: RDP Server and Web Client, powered by Devolutions Gateway +- **[Windows RDP Desktop](https://registry.coder.com/modules/coder/local-windows-rdp)**: Enable RDP on Windows and add a one-click Coder Desktop button for seamless access ### [AI Modules](https://registry.coder.com/modules?search=tag%3Aai) Integrate AI-powered development tools and assistants. -- **Aider**: Run Aider AI pair programming in your workspace -- **Amazon Q**: Run Amazon Q in your workspace to access Amazon's AI coding assistant -- **Claude Code**: Run Claude Code in your workspace -- **Goose**: Run Goose in your workspace +- **[Aider](https://registry.coder.com/modules/coder/aider)**: Run Aider AI pair programming in your workspace +- **[Amazon Q](https://registry.coder.com/modules/coder/amazon-q)**: Run Amazon Q in your workspace to access Amazon's AI coding assistant +- **[Claude Code](https://registry.coder.com/modules/coder/claude-code)**: Run Claude Code in your workspace +- **[Goose](https://registry.coder.com/modules/coder/goose)**: Run Goose in your workspace ### [Integration Modules](https://registry.coder.com/modules?search=tag%3Aintegration) Connect with external services and platforms. -- **Hashicorp Vault Integration (GitHub)**: Authenticates with Vault using GitHub -- **Hashicorp Vault Integration (JWT)**: Authenticates with Vault using a JWT from Coder's OIDC provider -- **Hashicorp Vault Integration (Token)**: Authenticates with Vault using Token -- **HCP Vault Secrets**: Fetch secrets from HCP Vault -- **JFrog (OAuth)**: Install the JF CLI and authenticate with Artifactory using OAuth -- **JFrog (Token)**: Install the JF CLI and authenticate with Artifactory using Artifactory terraform provider +- **[Hashicorp Vault Integration (GitHub)](https://registry.coder.com/modules/coder/vault-github)**: Authenticates with Vault using GitHub +- **[Hashicorp Vault Integration (JWT)](https://registry.coder.com/modules/coder/vault-jwt)**: Authenticates with Vault using a JWT from Coder's OIDC provider +- **[Hashicorp Vault Integration (Token)](https://registry.coder.com/modules/coder/vault-token)**: Authenticates with Vault using Token +- **[HCP Vault Secrets](https://registry.coder.com/modules/coder/hcp-vault-secrets)**: Fetch secrets from HCP Vault +- **[JFrog (OAuth)](https://registry.coder.com/modules/coder/jfrog-oauth)**: Install the JF CLI and authenticate with Artifactory using OAuth +- **[JFrog (Token)](https://registry.coder.com/modules/coder/jfrog-token)**: Install the JF CLI and authenticate with Artifactory using Artifactory terraform provider ### [Web-based Tools](https://registry.coder.com/modules?search=tag%3Aweb) Browser-accessible applications and interfaces. -- **File Browser**: A file browser for your workspace +- **[File Browser](https://registry.coder.com/modules/coder/filebrowser)**: A file browser for your workspace Browse all available modules and explore specific categories at [registry.coder.com](https://registry.coder.com). From ab89f40698aa240ce777589e116d50822a61ae1e Mon Sep 17 00:00:00 2001 From: DevelopmentCats Date: Thu, 26 Jun 2025 19:31:02 +0000 Subject: [PATCH 13/16] docs(modules): update contributing guide with prerequisites and enhanced resource links for better clarity addressed all comments up to commit time aside from unresolved comments awaiting replies --- docs/about/contributing/modules.md | 34 +++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 7932154fa05e4..c883649041990 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -1,6 +1,17 @@ # Coder modules -Coder modules are reusable Terraform configurations that extend workspace functionality through the Coder Terraform provider. This guide focuses on understanding and creating effective modules. +Coder modules are reusable [Terraform configurations](https://developer.hashicorp.com/terraform/language) that extend workspace functionality through the Coder Terraform provider. This guide focuses on understanding and creating effective modules. + +## Prerequisites + +This guide assumes basic familiarity with Terraform concepts. If you're new to Terraform, we recommend reviewing these resources first: + +- **[What is Terraform?](https://developer.hashicorp.com/terraform/intro)** - Introduction to infrastructure as code +- **[Terraform Configuration Language](https://developer.hashicorp.com/terraform/language)** - Learn the HCL syntax used in `.tf` files +- **[Terraform Variables](https://developer.hashicorp.com/terraform/language/values/variables)** - Understanding input variables and configuration +- **[Terraform Modules](https://developer.hashicorp.com/terraform/language/modules)** - How modules work and module structure + +For hands-on learning, try the [Terraform tutorials](https://developer.hashicorp.com/terraform/tutorials) to get comfortable with basic concepts before creating Coder modules. ## Architecture Overview @@ -80,12 +91,11 @@ flowchart LR 1. **Module Registry**: External registry hosts reusable modules and starter templates - Modules are Terraform configurations using Coder-specific resources - Starter templates provide infrastructure-specific bases (Docker, AWS, GCP, etc.) to start building your own templates - - Community and official modules available at [registry.coder.com](https://registry.coder.com) + - [Coder registry](https://registry.coder.com) hosts a collection of official, partner, and community contributed templates and modules. -2. **Template Development**: Your Coder templates reference modules from the registry +2. **Templates**: Your Coder templates reference modules from the registry - Use starter templates as infrastructure-specific starting points for your own templates - Reference individual modules to add functionality to your templates - - Modules add `coder_script`, `coder_app`, and `coder_env` resources to templates 3. **Workspace Execution**: When workspaces are created, modules run through the Coder agent - **Scripts** install and configure tools (IDEs, languages, services) @@ -186,7 +196,7 @@ module-name/ ├── main.tf # Terraform configuration with Coder resources ├── main.test.ts # Test suite ├── README.md # Documentation with frontmatter -└── run.sh # Installation script +└── run.sh # Installation or setup script ``` ### File Purposes @@ -200,9 +210,9 @@ module-name/ The Coder Terraform provider offers several resource types for different aspects of workspace functionality. Understanding when and how to use each resource is crucial for effective module development. -### Coder Resources +### [Coder Resources](https://registry.terraform.io/providers/coder/coder/latest/docs) -#### coder_script - Command Execution +#### [coder_script - Command Execution](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/script) Execute commands during workspace lifecycle events. This is the primary mechanism for software installation, service configuration, and environment setup. @@ -237,7 +247,7 @@ resource "coder_script" "install" { } ``` -#### coder_app - User Interface +#### [coder_app - User Interface](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/app) Create accessible applications in the Coder workspace interface, providing users with one-click access to tools and services. @@ -251,7 +261,9 @@ Create accessible applications in the Coder workspace interface, providing users - `agent_id`: The Coder agent - `external`: `true` for protocol handlers, `false` for web apps +- `group`: Name of a group that this app belongs to. - `healthcheck`: Monitor service availability +- `order`: Control the display order of apps in the dashboard - `subdomain`: Access method for web apps - `url`: Service URL or protocol handler @@ -264,14 +276,16 @@ resource "coder_app" "service" { url = "http://localhost:${var.port}" healthcheck { - url = "http://localhost:${var.port}/health" + url = "http://localhost:${var.port}/api/status" # Service-specific endpoint interval = 5 threshold = 6 } } ``` -#### coder_env - Environment Variables +> **⚠️ Important**: Health check URLs are service-specific. Common paths include `/health`, `/healthz`, `/ping`, `/status`, or `/api/health`. Check your service's documentation or use the main service URL if no dedicated health endpoint exists. + +#### [coder_env - Environment Variables](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/env) Set environment variables in workspace sessions for tool configuration and authentication. From 9b8a380ab73ee4623f2de8a5b86bf1ede39a16fc Mon Sep 17 00:00:00 2001 From: DevCats Date: Fri, 27 Jun 2025 08:52:36 -0500 Subject: [PATCH 14/16] docs: update description Co-authored-by: Atif Ali --- docs/about/contributing/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index c883649041990..779b6638bacfb 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -89,7 +89,7 @@ flowchart LR **How Modules Work in the Coder Ecosystem:** 1. **Module Registry**: External registry hosts reusable modules and starter templates - - Modules are Terraform configurations using Coder-specific resources + - Modules are Terraform configurations that utilize additional Terraform resources to provide enhancements or add new features and tools. - Starter templates provide infrastructure-specific bases (Docker, AWS, GCP, etc.) to start building your own templates - [Coder registry](https://registry.coder.com) hosts a collection of official, partner, and community contributed templates and modules. From b9315c8c5bc1581a4969aaf2f987be5e11de104b Mon Sep 17 00:00:00 2001 From: DevCats Date: Fri, 27 Jun 2025 08:53:28 -0500 Subject: [PATCH 15/16] docs: remove depreciated vault-secrets Co-authored-by: Atif Ali --- docs/about/contributing/modules.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 779b6638bacfb..9ac194853af3f 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -163,7 +163,6 @@ Connect with external services and platforms. - **[Hashicorp Vault Integration (GitHub)](https://registry.coder.com/modules/coder/vault-github)**: Authenticates with Vault using GitHub - **[Hashicorp Vault Integration (JWT)](https://registry.coder.com/modules/coder/vault-jwt)**: Authenticates with Vault using a JWT from Coder's OIDC provider - **[Hashicorp Vault Integration (Token)](https://registry.coder.com/modules/coder/vault-token)**: Authenticates with Vault using Token -- **[HCP Vault Secrets](https://registry.coder.com/modules/coder/hcp-vault-secrets)**: Fetch secrets from HCP Vault - **[JFrog (OAuth)](https://registry.coder.com/modules/coder/jfrog-oauth)**: Install the JF CLI and authenticate with Artifactory using OAuth - **[JFrog (Token)](https://registry.coder.com/modules/coder/jfrog-token)**: Install the JF CLI and authenticate with Artifactory using Artifactory terraform provider From 1e7191ad385444389cec56d41583afb178facc79 Mon Sep 17 00:00:00 2001 From: DevCats Date: Fri, 27 Jun 2025 08:53:57 -0500 Subject: [PATCH 16/16] docs: update workspace execution content Co-authored-by: Atif Ali --- docs/about/contributing/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/about/contributing/modules.md b/docs/about/contributing/modules.md index 9ac194853af3f..519f42440ec56 100644 --- a/docs/about/contributing/modules.md +++ b/docs/about/contributing/modules.md @@ -97,7 +97,7 @@ flowchart LR - Use starter templates as infrastructure-specific starting points for your own templates - Reference individual modules to add functionality to your templates -3. **Workspace Execution**: When workspaces are created, modules run through the Coder agent +3. **Workspace Execution**: When workspaces are created, the Coder agent handles the Coder-specific additional resources added by the module and provides the extra functionality. - **Scripts** install and configure tools (IDEs, languages, services) - **Apps** provide web interfaces accessible through Coder dashboard - **Environment** sets up variables, paths, and development settings