Coder powers secure, scalable development across key industries — automotive, finance, government, and technology — enabling faster builds, tighter compliance, and seamless AI adoption in enterprise-grade cloud environments.
Learn how to create and contribute Terraform modules to the Coder Registry. Modules provide reusable components that extend Coder workspaces with IDEs, development tools, login tools, and other features.
What are Coder modules
Coder modules are Terraform modules that integrate with Coder workspaces to provide specific functionality. They are published to the Coder Registry at registry.coder.com and can be consumed in any Coder template using standard Terraform module syntax.
Create your namespace README at registry/[your-username]/README.md:
---
display_name: "Your Name"
bio: "Brief description of what you do"
github: "your-username"
avatar: "./.images/avatar.png"
linkedin: "https://www.linkedin.com/in/your-username"
website: "https://your-website.com"
support_email: "[email protected]"
status: "community"
---
# Your Name
Brief description of who you are and what you do.
Note
The linkedin, website, and support_email fields are optional and can be omitted or left empty if not applicable.
2. Generate module scaffolding
Use the provided script to generate your module structure:
./scripts/new_module.sh [your-username]/[module-name]
cd registry/[your-username]/modules/[module-name]
This creates:
main.tf - Terraform configuration template
README.md - Documentation template with frontmatter
run.sh - Optional execution script
3. Implement your module
Edit main.tf to build your module's features. Here's an example based on the git-clone module structure:
terraform {
required_providers {
coder = {
source = "coder/coder"
}
}
}
# Input variables
variable "agent_id" {
description = "The ID of a Coder agent"
type = string
}
variable "url" {
description = "Git repository URL to clone"
type = string
validation {
condition = can(regex("^(https?://|git@)", var.url))
error_message = "URL must be a valid git repository URL."
}
}
variable "base_dir" {
description = "Directory to clone the repository into"
type = string
default = "~"
}
# Resources
resource "coder_script" "clone_repo" {
agent_id = var.agent_id
display_name = "Clone Repository"
script = <<-EOT
#!/bin/bash
set -e
# Ensure git is installed
if ! command -v git &> /dev/null; then
echo "Installing git..."
sudo apt-get update && sudo apt-get install -y git
fi
# Clone repository if it doesn't exist
if [ ! -d "${var.base_dir}/$(basename ${var.url} .git)" ]; then
echo "Cloning ${var.url}..."
git clone ${var.url} ${var.base_dir}/$(basename ${var.url} .git)
fi
EOT
run_on_start = true
}
# Outputs
output "repo_dir" {
description = "Path to the cloned repository"
value = "${var.base_dir}/$(basename ${var.url} .git)"
}