Skip to content

feat: plumb user secrets through provisioner chain to terraform#24542

Open
zedkipp wants to merge 1 commit intomainfrom
zedkipp/plat-77-build-time-secrets-injection
Open

feat: plumb user secrets through provisioner chain to terraform#24542
zedkipp wants to merge 1 commit intomainfrom
zedkipp/plat-77-build-time-secrets-injection

Conversation

@zedkipp
Copy link
Copy Markdown
Contributor

@zedkipp zedkipp commented Apr 20, 2026

Passes user secrets from coderd to the Terraform process at workspace build time so the data.coder_secret data source in terraform-provider-coder can resolve values at plan time.

Secrets traverse two proto hops: provisionerdserver fetches them viaListUserSecretsWithValues, attaches them to AcquiredJob.WorkspaceBuild.user_secrets on provisionerd.proto; runner.go forwards into PlanRequest.user_secrets on provisioner.proto; the Terraform provisioner encodes each as CODER_SECRET_ENV_<name> or CODER_SECRET_FILE_<hex(path)> before invoking terraform plan. Only plan requests carry secrets; apply runs with nil because values are baked into plan state.

Fetch is gated on a workspace transitioning to start. stop and delete transitions never carry secrets, so revoking or deleting a stored secret cannot make a workspace unstoppable. DB errors on the fetch fail the job outright rather than silently continuing with an empty secret set.

Corresponding terraform-provider-coder change: coder/terraform-provider-coder#501

@zedkipp zedkipp force-pushed the zedkipp/plat-77-build-time-secrets-injection branch 3 times, most recently from b7bc9ed to e457dc3 Compare April 21, 2026 22:00
@zedkipp zedkipp force-pushed the zedkipp/plat-77-build-time-secrets-injection branch 2 times, most recently from 6fad51d to 01ca924 Compare April 22, 2026 21:44
Passes user secrets from coderd to the Terraform process at workspace
build time so the `data.coder_secret` data source in
terraform-provider-coder can resolve values at plan time.

Secrets traverse two proto hops: `provisionerdserver` fetches them via
`ListUserSecretsWithValues`, attaches them to
`AcquiredJob.WorkspaceBuild.user_secrets` on `provisionerd.proto`;
`runner.go` forwards into `PlanRequest.user_secrets` on
`provisioner.proto`; the Terraform provisioner encodes each as
`CODER_SECRET_ENV_<name>` or `CODER_SECRET_FILE_<hex(path)>` before
invoking `terraform plan`. Only plan requests carry secrets; apply runs
with `nil` because values are baked into plan state.

Fetch is gated on `WorkspaceTransitionStart`: stop and delete
transitions never carry secrets, so revoking or deleting a stored
secret cannot make a workspace unstoppable. DB errors on the fetch
fail the job outright rather than silently continuing with an empty
secret set.
@zedkipp zedkipp force-pushed the zedkipp/plat-77-build-time-secrets-injection branch from 01ca924 to a8372f7 Compare April 22, 2026 21:52
@zedkipp zedkipp changed the title feat: build-time user secret injection into terraform provisioner feat: plumb user secrets through provisioner chain to terraform Apr 22, 2026
@zedkipp zedkipp marked this pull request as ready for review April 22, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant