Movatterモバイル変換


[0]ホーム

URL:


HomeAdministrationTemplatesExtending Templates

Extending Templates

There are a variety of Coder-native features to extend the configuration of yourdevelopment environments. Many of the following features are defined in yourtemplates using theCoder Terraform provider.The provider docs will provide code examples for usage; alternatively, you canview ourexample templatesto get started.

Workspace agents

For users to connect to a workspace, the template must include acoder_agent.The associated agent will facilitateworkspace connections via SSH,port forwarding, and IDEs. The agent may also display real-timeworkspace metadata like resource usage.

resource "coder_agent" "dev" { os = "linux" arch = "amd64" dir = "/workspace" display_apps { vscode = true }}

You can also leverageresource metadata to displaystatic resource information from your template.

Templates must include some computational resource to start the agent. Allprocesses on the workspace are then spawned from the agent. It also provides allinformation displayed in the dashboard's workspace view.

A healthy workspace agent

Multiple agents may be used in a single template or even a single resource. Eachagent may have its own apps, startup script, and metadata. This can be used toassociate multiple containers or VMs with a workspace.

Resource persistence

The resources you define in a template may beephemeral orpersistent.Persistent resources stay provisioned when workspaces are stopped, where asephemeral resources are destroyed and recreated on restart. All resources aredestroyed when a workspace is deleted.

You can read more about how resource behavior and workspace state in theworkspace lifecycle documentation.

Template resources follow thebehavior of Terraform resourcesand can be further configured  using thelifecycle argument.

A common configuration is a template whose only persistent resource is the homedirectory. This allows the developer to retain their work while ensuring therest of their environment is consistently up-to-date on each workspace restart.

When a workspace is deleted, the Coder server essentially runs aterraform destroy to remove allresources associated with the workspace.

Tip

Terraform'sprevent-destroyandignore-changesmeta-arguments can be used to prevent accidental data loss.

Coder apps

Additional IDEs, documentation, or services can be associated to your workspaceusing thecoder_appresource.

Coder Apps in the dashboard

Note that some apps are associated to the agent by default asdisplay_appsand can be hidden directly in thecoder_agentresource. You can arrange the display orientation of Coder apps in your templateusingresource ordering.

Coder app examples

resource "coder_app" "code-server" { agent_id = coder_agent.main.id slug = "code-server" display_name = "code-server" url = "http://localhost:13337/?folder=/home/${local.username}" icon = "/icon/code.svg" subdomain = false share = "owner"}

Check out ourmodule registry foradditional Coder apps from the team and our OSS community.

On this page

[8]ページ先頭

©2009-2025 Movatter.jp