Skip to content

feat: add write-only workspace secrets linked to builds - #30200

Closed
Emyrk wants to merge 3 commits into
mainfrom
steven/relay-7-workspace-secrets
Closed

Emyrk wants to merge 3 commits into
mainfrom
steven/relay-7-workspace-secrets

Conversation

@Emyrk

@Emyrk Emyrk commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Adds workspace secrets that are set inline on a workspace or build request and delivered only through the agent manifest. This is the coderd half of RELAY-7: agent-relay modules can stop passing provider credentials as rich parameters, which land in workspace_build_parameters, Terraform state, insights, and Prometheus.

Closes RELAY-7 on the coderd side. Supersedes #29739.

What changed

  • New workspace_secrets table. Each row is linked to one build (workspace_build_id). Columns mirror user_secrets (dbcrypt-encrypted value, env_name/file_path targets) plus ephemeral and cleared_at. Per-build caps via a trigger with the same limits as user secrets.
  • CreateWorkspaceRequest.secrets and CreateWorkspaceBuildRequest.secrets (WorkspaceSecretInput{name, value, env_name, file_path, ephemeral}). Applied inside the wsbuilder transaction; never placed in the provisioner job input.
  • On each new build: copy forward the previous build's live, non-ephemeral rows (minus names the request replaces or removes), insert the request's entries, then clear the previous build's rows (value = NULL, cleared_at = now()). Cleared rows stay as history of what each build received.
  • Agent manifest appends the live workspace secrets after user secrets so a workspace secret wins on an env var or file path conflict. Agent needs no changes.
  • Write-only: no API returns values or metadata.
  • Validation reuses the user secret rules and file path delivery policy; duplicate names within one request are rejected.
  • dbcrypt rotate/decrypt cover the new table; delete clears values instead of dropping rows.
  • Docs: "Workspace secrets" section in docs/admin/security/secrets.md.

Follow-ups (out of scope)

  • Registry module and relay changes to send secrets instead of agent_relay_credential.
  • CLI flag and dashboard UI (a history view could use GetWorkspaceSecretsHistory).
  • Retention/pruning of cleared rows if history growth matters.
Design decisions
Question Decision
Linkage Rows belong to a build. Only the latest build has live rows; older builds keep cleared rows as history.
Carry-forward Non-ephemeral secrets are copied to each new build unless the request replaces or removes them. A request without secrets still carries the set forward.
Ephemeral Delivered to exactly the build it was set on; not copied to the next build regardless of who triggers it or whether the build succeeds.
Source of copy The latest build, even if it failed.
Write path Inline on create workspace and create build requests. Authz is ActionUpdate on the workspace, so the relay's service account works the same way it does with rich_parameter_values. The copy-forward read runs as system inside the transaction; values are only re-inserted for the same workspace and never returned.
Template declaration None in Terraform. A startup script checks for the expected env vars. No provider or preview changes.
Reads Write-only through the API. Values are readable only in system contexts (manifest, build transaction, key rotation).
Removal "value": "" omits the secret from the new build; the previous row is cleared like any other.
Precedence Workspace secrets override user secrets on the same env_name/file_path.
Limits Same caps as user secrets (50, 200 KiB, 24 KiB env), enforced per build by a mirrored trigger.

Created by Coder Agents on behalf of @Emyrk.

@linear-code

linear-code Bot commented Sep 30, 2026

Copy link
Copy Markdown

RELAY-7

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@Emyrk Emyrk changed the title feat: add write-only workspace secrets delivered through the agent manifest feat: add write-only workspace secrets linked to builds Sep 30, 2026
@Emyrk

Emyrk commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

Superseded by the stack starting at #30248 (#30248, #30249, #30250, #30251, #30252).

Comment by Coder Agents on behalf of @Emyrk.

@Emyrk Emyrk closed this Oct 1, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant