coder / coder/internal

Terraform Resources for Dev Containers

Offen
#1,237 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
epic
Vorherrschende Sprache
Keine Sprachdaten
Sterne
3
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

# Epic: Terraform Resources for Dev Containers

## Summary

Enable template authors to attach Terraform resources (`coder_app`, `coder_script`, `coder_env`, `coder_ai_task`) to `coder_devcontainer` resources, eliminating the need to choose between Dev Containers and our collection of Terraform modules.

## Problem Statement

**Opting in** to Dev Containers requires **opting out** of our collection of Terraform modules as there is no way of associating terraform resources to the `coder_devcontainer` resource.

Agents used for Dev Containers are created dynamically *after* workspace provisioning. Since the sub-agent doesn't exist at Terraform plan/apply time, there is no way to reference it in Terraform.

## Solution Overview

### Phase 1: Terraform-defined Resources

Introduce a computed `subagent_id` field on the `coder_devcontainer` resource that can be referenced by other Terraform resources. This ID is pre-computed at plan time and used when the sub-agent is created at runtime.

```hcl
resource "coder_devcontainer" "main" {
agent_id = coder_agent.main.id
workspace_folder = "/workspaces/project"
}

resource "coder_app" "code_server" {
agent_id = coder_devcontainer.main.subagent_id
slug = "code-server"
display_name = "VS Code"
url = "http://localhost:8080"
}
```

### Phase 2: `devcontainer.json`-defined Resources

Enable Terraform modules to be defined directly in `devcontainer.json` via `customizations.coder.modules`, allowing developers to attach modules to their dev container without modifying Terraform templates. The modules are provisioned by coderd using `coder/preview`.

```json
{
"customizations": {
"coder": {
"modules": {
"registry.coder.com/coder/code-server/coder:1.0.0": {},
"registry.coder.com/coder/zed/coder:1": {
"folder": "/home/coder/coder"
}
}
}
}
}
```

The key format is `:` and the value is an object of key-value mappings where each key is translated into a Terraform variable.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne damit, die Ressource coder_devcontainer und ihre Interaktion mit coder_app, coder_script, coder_env und coder_ai_task nachzuverfolgen; überprüfe anschließend die Anpassungen customizations.coder.modules in devcontainer.json und den coder/preview-Pfad von coderd. Der Issue beschreibt zwei Phasen. Bestätige daher vor der Implementierung den vorgesehenen Umfang und die Akzeptanzkriterien; als abgeschlossen gilt die Umsetzung der angegebenen Ressourcenverknüpfungen und des Verhaltens bei der Modulbereitstellung.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
terraform
Bereich
infrastructure
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.