Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add deployment-level option to disable Terraform module caching - #29187

Merged
Emyrk merged 4 commits into
mainfrom
steven/plat-294-disable-module-cache
Sep 11, 2026
Merged

feat: add deployment-level option to disable Terraform module caching#29187
Emyrk merged 4 commits into
mainfrom
steven/plat-294-disable-module-cache

Conversation

@Emyrk

@Emyrk Emyrk commented Sep 10, 2026

Copy link
Copy Markdown
Member
Screenshot From 2026-09-11 17-09-41

Closes #22834.

Adds CODER_PROVISIONER_DISABLE_MODULE_CACHE so an admin can disable Terraform module caching for every template at once instead of toggling ~100 templates by hand.

  • The deployment setting wins. Templates cannot opt back in, and the per-template toggle becomes read-only while the deployment setting is on.
  • Modules stay cached at template import, so dynamic parameter rendering still resolves module-defined parameters. Only the workspace build is denied the cached files.
  • Templates report module_cache_disabled_by_deployment, and template settings shows why the checkbox is locked.
Agent context

Decisions taken with @Emyrk before implementing:

  1. Precedence. deployment || template, no per-template override, so no migration and no nullable column. The rule lives in one place, codersdk.ModuleCacheDisabled.
  2. Import-time caching untouched. dynamicparameters/render.go overlays cached_module_files at .terraform/modules to render module-defined parameters. Skipping the cache there would reproduce the Module not loaded. Did you run terraform init? failure reported by a customer, so the deployment setting only affects what AcquireJob hands the provisioner.
  3. Write path. A PATCH carrying disable_module_cache is discarded while the deployment setting is on, rather than persisted. Persisting it would silently keep templates opted out after the deployment setting is removed.
  4. API shape. disable_module_cache keeps its meaning (this template's stored value) and the new read-only module_cache_disabled_by_deployment reports the deployment state. Reading the effective value from /deployment/config was rejected because template admins may lack deployment-config read permission.
  5. Naming. CODER_PROVISIONER_DISABLE_MODULE_CACHE over the issue's CODER_DISABLE_TERRAFORM_MODULE_CACHE, to match the provisioning option group.

Note: InsertTemplateParams has no disable_module_cache binding, so new templates always store false. With deployment precedence they still behave as opted out, so the create path needed no change.

Out of scope and tracked elsewhere: the coderd_template Terraform provider attribute (separate repo) and backporting the per-template toggle to release/2.30.


Coder Agents on behalf of @Emyrk.

CODER_PROVISIONER_DISABLE_MODULE_CACHE withholds cached Terraform modules
from every workspace build, so admins no longer have to toggle each template.
The deployment setting wins: templates cannot opt back in, and the
per-template toggle becomes read-only while it is set.

Modules stay cached at template import so dynamic parameter rendering keeps
resolving module-defined parameters.

Templates report the deployment state as module_cache_disabled_by_deployment
so the settings UI can explain why the toggle is locked.
@linear-code

linear-code Bot commented Sep 10, 2026

Copy link
Copy Markdown

PLAT-294

@github-actions

github-actions Bot commented Sep 10, 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.

Comment thread codersdk/templates.go
Comment on lines +74 to +81
// provisioning for this template. It is read-only while
// ModuleCacheDisabledByDeployment is true.
DisableModuleCache bool `json:"disable_module_cache"`

// ModuleCacheDisabledByDeployment reports that the deployment disables the
// Terraform module cache for every template. Templates cannot opt back in,
// so the effective state is disabled regardless of DisableModuleCache.
ModuleCacheDisabledByDeployment bool `json:"module_cache_disabled_by_deployment"`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 separate bools so the end user knows the state

@Emyrk

Emyrk commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

Manually checked

@Emyrk
Emyrk marked this pull request as ready for review September 11, 2026 22:10

@BobbyHo BobbyHo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the Go files, and the changes LGTM. I’m not very familiar with the TypeScript files, but based on the screenshots in the PR description, they look correct as well.

@Emyrk
Emyrk merged commit 940f988 into main Sep 11, 2026
40 checks passed
@Emyrk
Emyrk deleted the steven/plat-294-disable-module-cache branch September 11, 2026 23:13
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 11, 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.

feat: Add deployment-level option to disable Terraform module caching

2 participants