docs
/

Templates

2 min read

Learn how to create an embeddable "Open In Coder" button for your Workspaces As Code Template

The Templates tab features options that control the behavior of workspace templates.

The Enable using Workspace Templates toggle allows you to enable or disable the creation of workspaces using predefined templates located in Git repositories.

Enable workspace templates

Template policy (alpha)

If you enable the use of workspace templates, a template policy allows you to control which fields users can set and which values can be used when they define their workspaces.

The default template policy is as follows:

version: "0.2"
workspace:
    configure:
        start:
            policy: write
    dev-urls:
        policy: write
    specs:
        kubernetes:
            container-based-vm:
                policy: write
            cpu:
                policy: write
            disk:
                policy: write
            env:
                policy: write
            gpu-count:
                policy: write
            image:
                policy: write
            labels:
                policy: read
            memory:
                policy: write
            node-selector:
                policy: read
            tolerations:
                policy: read

Underneath the policy template preview, you can either upload your policy or you can drag-and-drop the file onto the UI. Click Save to persist your changes.

If, at any time, you want to remove your policy and use Coder's default policy, click Reset to default.

Embeddable Button

The Embeddable Button section features a form you can use for generating an embeddable button. This button makes it easy for developers to use your workspace template.

To create your button:

  1. Go to Manage > Admin > Templates.
  2. Fill out the fields.

Once you've filled out the form, Coder generates a custom Markdown snippet, which you can then add to your repository's README.md.

Open In Coder Button

Enabling workspaces as code

By default, workspaces as code is an opt-in feature. To enable workspaces as code, go to Admin > Templates and set Enable using Workspace Templates to On.

toggle workspaces as code

See an opportunity to improve our docs? Make an edit.