docs(aws): phase 5 Fargate workspaces
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
084fa6efe4
commit
595897a5fd
2 files changed
+70
-16
No files matched your search
@@ -297,7 +297,9 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
|
||||
is stopped again) and `tunnels.rs` the registry of open tunnels by project — an AWS project's
|
||||
`ContainerTarget::for_project` is its tunnel's endpoint, its stored `container_id` is that
|
||||
endpoint's URL, and the AWS death watch confirms exits through the registry. Shutdown closes
|
||||
every tunnel. AWS SDK calls stay in `aws/` (`runtime.rs`, `tasks.rs`, `workspace.rs`).
|
||||
every tunnel (`for_project` is `None` while none is open; `for_project_waiting` covers the
|
||||
background re-attach after an app restart). AWS SDK calls stay in `aws/` (`runtime.rs`,
|
||||
`tasks.rs`, `workspace.rs`).
|
||||
`agent.rs` reuses `docker/exec.rs`'s `OneshotOutput`, host-file reader and uid probe so the two
|
||||
variants cannot drift; an `Agent` target's token never appears in `Debug` or error text.
|
||||
**Container-interior code must go through `ContainerTarget`, never `docker::exec`, bollard or
|
||||
@@ -336,6 +338,24 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
|
||||
`aws/README.md` ("Live verification"). Its `environment` tests apply the real modules as a role
|
||||
holding only the admin files (`cargo build` first: the runner they start is the built app
|
||||
binary), in a throwaway state bucket.
|
||||
**A Fargate workspace's resources** (`workspace.rs`, `tasks.rs`, `runtime.rs`). **No project
|
||||
data in a task definition (P1):** every workspace user has `ecs:Describe*` on `*`, so
|
||||
`environment`, tags, labels and `overrides` are public to the account. The task definition carries
|
||||
`TRIPLEC_HOST=aws`, `COLORTERM`, the three ownership tags, a fingerprint docker label (a hash,
|
||||
`FINGERPRINT_LABEL`) and `valueFrom` references into the project's **one secret**
|
||||
(`triple-c/<env>/<owner_key>/<project-id>`, JSON, 64 KB cap: files, repos, instructions, settings,
|
||||
custom env, the agent token). The token rotates each start; a running task is attached to by reading
|
||||
it back (the task role has no Secrets Manager access). **Anyone may register a revision into any
|
||||
`triple-c-*` family** (IAM can't scope it), so a revision or task is reused only when it carries the
|
||||
caller's own owner tag + this project's tag (+ the fingerprint), and `RunTask` always names the exact
|
||||
`family:revision` ARN, never "latest". Names come only from `tofu_modules.rs`, built from `owner_key`
|
||||
(`aws:userid` contains `:`). Workspace users can't deregister or delete task definitions
|
||||
(`DeregisterTaskDefinition` is `*`-only in IAM): removal leaves revisions ACTIVE for an admin
|
||||
(`aws/README.md`). Stop: the stop guard (`commands/stop_guard.rs`) dry-runs `triple-c-wip-push`
|
||||
through the agent, may push first, then writes `pushed` or `discard` to `/run/triple-c/stop-reason`
|
||||
(root-owned; the entrypoint's TERM hook reads it, and the idle watcher writes `idle`) so the hook
|
||||
doesn't push twice; the marker is cleared if StopTask fails. Claude Code's sandbox is forced off in
|
||||
the generated settings (bubblewrap can't create namespaces on Fargate, verified live).
|
||||
**Environments are OpenTofu modules** (`aws/terraform/{environment,user-onboard,permissions-boundary}`;
|
||||
spec D2–D10). `tofu_modules.rs` embeds them and is the **only** place the shared names are built
|
||||
(environment, `/triple-c/environments/<env>` record, owner key — `sha256("<region>:<aws:userid>")`,
|
||||
@@ -367,6 +387,20 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
|
||||
- **`Dockerfile`** — Ubuntu 24.04 base with Claude Code, Node.js 22, Python 3.12, Rust, Docker CLI, git, gh, AWS CLI v2, ripgrep, pnpm, uv, ruff pre-installed, plus the shared
|
||||
libraries a browser links against (see below) and the VPN tooling the `vpn_support_enabled`
|
||||
toggle grants capability for (`iproute2`, `wireguard-tools`, `iptables`)
|
||||
- **`TRIPLEC_HOST=aws` mode** (`entrypoint.sh`, the `aws_*` blocks; inert without it). There are no
|
||||
bind mounts: `TRIPLEC_FILES` (JSON of base64 files) is decoded into `/tmp/.host-ssh` / `/tmp/.host-ca`
|
||||
so the SSH merge and CA install run unchanged, and `TRIPLEC_REPOS` is kept in an unexported shell
|
||||
variable; **both are unset before the agent-token block snapshots the environment** (that snapshot is
|
||||
every terminal's env and the files hold private keys). Repos clone in the background after the agent
|
||||
starts (terminals are usable before they arrive). Hybrid storage mounts EFS at `/mnt/triple-c-home`
|
||||
and symlinks `~/.claude`, `~/.claude.json`, `~/.ssh` into it (mounting over `/home/claude` would hide
|
||||
the image's tooling); root never follows those links outside the mount (`aws_hybrid_ssh_dir`). On
|
||||
TERM the hook pushes unsaved work to a `triple-c/wip/<stamp>` branch via a temporary index (the
|
||||
user's index is untouched; needs the task definition's `stopTimeout` raised, 120 s) unless the stop
|
||||
marker says the app handled it. The idle watcher runs as root under a supervisor and signals the
|
||||
entrypoint's own PID (not PID 1, which is docker-init), so idle and ECS stops share one trap.
|
||||
**The `TRIPLEC_` env prefix is reserved** on both hosts (`RESERVED_ENV_PREFIXES`; `workspace.rs`
|
||||
drops custom variables in it): the entrypoint's settings live there.
|
||||
- **Browser runtime libraries are baked in; browser *binaries* are not.** A layer runs
|
||||
`npx --yes playwright@latest install-deps chromium` as root, so Playwright names its own
|
||||
dependencies and the list cannot rot against Ubuntu 24.04's `t64` renames or a new Chromium
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Triple-C on AWS (ECS on EC2 / Fargate) — design
|
||||
|
||||
Date: 2026-11-13
|
||||
Status: **draft for review** (user decisions recorded 2026-11-13 and 2026-11-14; phase 4 done). The user set the direction (local or AWS, login like the AWS CLI,
|
||||
Status: **draft for review** (user decisions recorded 2026-11-13 and 2026-11-14; phases 1-5 done). The user set the direction (local or AWS, login like the AWS CLI,
|
||||
permission check, hosting options, secrets pushed automatically, shared accounts). Everything else
|
||||
here is a proposal.
|
||||
|
||||
@@ -319,9 +319,8 @@ other.
|
||||
unkillable keepalive.
|
||||
3. **Fargate restrictions** are handled by the host, not the image: no `privileged`, and no added
|
||||
capabilities except `SYS_PTRACE`. So VPN (`NET_ADMIN`) and Docker access are unavailable. The
|
||||
bubblewrap sandbox likely can't create user namespaces on Fargate (**verify**), so the generated
|
||||
Claude Code settings use `enableWeakerNestedSandbox` or turn the sandbox off, with a visible
|
||||
notice.
|
||||
bubblewrap sandbox can't create user namespaces on Fargate (verified, phase 5 P9), so the generated
|
||||
Claude Code settings turn the sandbox off, with a visible notice.
|
||||
|
||||
**Getting the image into the account:**
|
||||
|
||||
@@ -542,7 +541,7 @@ way.
|
||||
| Marketplace installs | Yes (files copied through the agent) | Yes | Yes |
|
||||
| LLM gateway (LiteLLM) | Sidecar container in the task definition | Sidecar | Sidecar |
|
||||
| Ollama / llama.cpp on the user's machine | **No**, unless the URL is reachable from AWS | No | No |
|
||||
| Claude Code sandbox (bubblewrap) | Weaker nested mode or off (**verify**) | Weaker nested mode | Full |
|
||||
| Claude Code sandbox (bubblewrap) | Off (bubblewrap fails on Fargate, P9) | Weaker nested mode | Full |
|
||||
| Docker access | No | No | Yes |
|
||||
| VPN support | No | No | Yes |
|
||||
| Snapshots | Setup script instead | Setup script | Setup script |
|
||||
@@ -596,24 +595,43 @@ pub aws_placement: Option<AwsPlacement>, // { region, environment } — set wh
|
||||
pub aws: Option<AwsWorkspaceConfig>,
|
||||
|
||||
pub struct AwsWorkspaceConfig {
|
||||
pub launch_type: LaunchType, // Fargate | Ec2 { capacity_provider }
|
||||
pub cpu: u32, pub memory_mib: u32, pub arch: Arch,
|
||||
pub storage: StorageMode, // Ephemeral | Hybrid | Efs
|
||||
pub ephemeral_gib: u32,
|
||||
pub cpu: u32, pub memory_mib: u32, pub arch: Arch, // X86_64 | Arm64 (Fargate's valid pairs)
|
||||
pub storage: StorageMode, // Ephemeral | Hybrid (Efs: phase 6)
|
||||
pub ephemeral_gib: u32, // 21-200
|
||||
pub spot: bool,
|
||||
pub idle_stop_minutes: Option<u32>,
|
||||
pub repos: Vec<RepoSource>, // { url, branch, folder } — parallel to ProjectPath
|
||||
pub secrets_delivery: SecretsDelivery, // SecretsManager | CopyAtConnect
|
||||
pub setup_script: Option<String>,
|
||||
pub wip_push_on_stop: bool,
|
||||
// runtime state (not user-edited)
|
||||
pub repos: Vec<RepoSource>, // { url, branch: Option, folder } — parallel to ProjectPath
|
||||
pub wip_push_on_stop: bool, // default true
|
||||
// runtime state (store-owned, not user-edited)
|
||||
pub task_arn: Option<String>, pub access_point_id: Option<String>,
|
||||
pub task_definition_arn: Option<String>, // the exact family:revision last run
|
||||
}
|
||||
// Not built yet: launch_type (Fargate only; EC2 is phase 7), secrets_delivery (Secrets Manager
|
||||
// only; Copy-at-connect is phase 6), setup_script (phase 6).
|
||||
```
|
||||
|
||||
Existing `projects.json` files deserialize unchanged (`host_id` missing → Local).
|
||||
`Project.container_id` stays Docker-only. AWS uses `aws.task_arn`.
|
||||
|
||||
### Phase 5: rulings (2026-11-15)
|
||||
|
||||
- **P1** One secret per project (`triple-c/<env>/<owner_key>/<project-id>`) holds everything project-shaped; task definitions carry only constants. Every user has `ecs:Describe*` on `*`, so anything in a task definition is public to the account. `owner_key` replaces `<owner>` (`aws:userid` contains `:`).
|
||||
- **P2** The agent token rotates on every start; users may read their own secrets so a second machine can attach to a running task. The task role has no Secrets Manager access.
|
||||
- **P3** Workspace users register their own task definitions (`workspace-user-tasks.json`, owner request tag + the three tag keys); family `triple-c-<env>-<owner_key>-<project-id-12>`. Anyone can register into any `triple-c-*` family, so revisions and tasks are trusted by owner tag and run by exact `family:revision` ARN.
|
||||
- **P4** Hybrid persists by symlinking `~/.claude`, `~/.claude.json`, `~/.ssh` into the EFS mount (`/mnt/triple-c-home`), not by mounting over `/home/claude`: EFS can't seed from the image, and masking would hide the image's tooling.
|
||||
- **P5** AWS runs a registry image only; `LocalBuild` maps to the registry image and `Custom` must name a registry reference.
|
||||
- **P6** Left for phase 6+: EFS mode, Copy-at-connect, setup scripts, cost estimate, port mappings, the LLM gateway sidecar, Docker access, VPN, the admin's maximum lifetime. The UI shows them disabled with the reason.
|
||||
- **P7** Idle means no authenticated agent activity for N minutes, no `claude` process and no running scheduler job; default off, 5-1440 minutes when on.
|
||||
- **P8** Spot uses `FARGATE_SPOT`; stop code `SpotInterruption` shows as Stopped with a Spot reason.
|
||||
- **P9** Bubblewrap fails on Fargate (measured live), so the AWS host forces Claude Code's sandbox off in the generated settings, with a notice.
|
||||
- **R1** Files travel as one secret key `TRIPLEC_FILES` (JSON of base64), decoded by the entrypoint, then unset.
|
||||
- **R2** The task definition's `environment` is exactly `TRIPLEC_HOST=aws` and `COLORTERM=truecolor` (no key list).
|
||||
- **R3/R4** The tunnel registry feeds `has_exited` (the exit source takes an injected project-to-task lookup); the sandbox is forced off in settings (P9).
|
||||
- **R5** The live test pushes the image to a throwaway private ECR repo and grants the execution role a test-only pull policy, because Fargate can't pull a local image.
|
||||
- **R6** Repos clone in the background after the agent starts, so the 30 s health window holds; cost: a terminal may open before a repo exists.
|
||||
- **R7** OpenAI Compatible is allowed on AWS with a warning that the URL must be reachable from AWS; only the local LiteLLM sidecar is unavailable.
|
||||
- **R8** Removal leaves task-definition revisions ACTIVE for an admin to clear: `ecs:DeregisterTaskDefinition` is only grantable on `*`, so granting it would let any user break others' workspaces. Cost: stale revisions accumulate (free).
|
||||
|
||||
## Shipped AWS artefacts
|
||||
|
||||
```
|
||||
@@ -650,7 +668,9 @@ TLS only, tagged `triple-c:component=state`), one object per deployment (D9).
|
||||
admin request, **strict tenancy**. **Done 2026-11-14**; deployed, joined, updated and destroyed
|
||||
for real as a role holding only the admin policies (see "Phase 4: live verification").
|
||||
5. **Fargate workspaces.** Ephemeral and Hybrid storage, Secrets Manager delivery, git bootstrap,
|
||||
start/stop/status, stop guard with WIP push on by default, idle auto-stop, logs.
|
||||
start/stop/status, stop guard with WIP push on by default, idle auto-stop, logs. **Done 2026-11-15**; verified live on Fargate:
|
||||
cold start about 94-104 s, ECS `HEALTHY` about 135 s, attach to a running task about 2 s, idle
|
||||
stop verified (see "Phase 5: rulings" and `aws/README.md` "Phase 5").
|
||||
6. **EFS mode, Copy-at-connect, setup scripts, cost estimate.**
|
||||
7. **ECS on EC2.** Per-user capacity providers in the onboarding module, privileged/Docker/VPN on
|
||||
dedicated capacity.
|
||||
|
||||
Reference in new issue
Block a user