Summary
Add a deployment-level (global) option to disable Terraform module caching across all templates, instead of requiring administrators to toggle each template individually.
The per-template disable_module_cache toggle already exists in v2.31+ (verified in code), but there is no server-wide flag and no deployment default that templates can inherit from. Admins with many templates (e.g. ~100) currently have to update each one by hand.
Verified current state (as of main, 2026-06-08)
- Per-template toggle exists in v2.31+.
disable_module_cache is a real field:
codersdk/templates.go exposes DisableModuleCache bool on the template and DisableModuleCache *bool on the update-meta request.
- DB migration
000416_workspace_module_reuse_toggle adds disable_module_cache BOOL NOT NULL DEFAULT false to the templates table.
- Wired through
coderd/templates.go, coderd/templates_meta_update.go, coderd/provisionerdserver/provisionerdserver.go, the audit table, generated TS types, and the Template Settings UI.
- Release coverage: present in
release/2.31, release/2.32, release/2.32.0-rc, and main; absent in release/2.30.
- No deployment-level / global option exists. No matching flag or env var (e.g.
CODER_DISABLE_TERRAFORM_MODULE_CACHE) was found in codersdk/deployment.go, cli/, enterprise/cli/, or cli/server.go.
- No Terraform provider support. The
coderd Terraform provider (coderd_template resource) does not expose a disable_module_cache attribute, so templates managed as code cannot set it.
Proposed Behavior
- Deployment-level configuration option — A global flag (e.g.
CODER_DISABLE_TERRAFORM_MODULE_CACHE) to disable module caching across all templates.
- Per-template override — The existing per-template
disable_module_cache setting should be able to override the deployment default, so individual templates can opt back in/out.
- UI messaging when globally disabled — When caching is disabled at the deployment level, the template settings UI should indicate this clearly, e.g.: "Terraform module caching is disabled at the deployment level. Modules will be re-downloaded on each workspace build. Note: disabling caching means provisioner nodes may accumulate Terraform module files on disk, which can impact stability at scale."
- Terraform provider support — Expose
disable_module_cache on the coderd_template resource in the coderd Terraform provider, so templates managed as code can set the toggle. (Lives in the separate provider repo; tracked as part of this body of work.)
Background: why caching exists (do not regress these)
Module caching was introduced (#21398, v2.30) to solve real problems, and the global opt-out must remain opt-in so these defaults are preserved:
- Disk/memory pressure: Repeated module downloads on every workspace build could cause an ever-growing
.terraform/modules cache on provisioner nodes, leading to OOM at scale.
- Stability: Upstream module changes could break workspace restarts without any template changes.
- Performance: Eliminating repeated downloads speeds up workspace startup.
Out of scope / tracked elsewhere
- Backporting the per-template toggle to
release/2.30.
original description
Is there an existing issue for this?
Current Behavior
Since v2.30 (#21398), Terraform modules are cached at template import time and reused for all subsequent workspace builds. This means that semver version constraints like ~> 1.1.0 are resolved once at import time and then effectively pinned — the constraint is never re-evaluated on workspace builds, even when newer matching versions are available upstream.
This silently overrides Terraform's native version resolution semantics. If a user specifies version = "~> 1.1.0", the intent is "give me the latest patch within this range." The caching behavior changes this to "pin whatever version was latest at import time," which is fundamentally different from what the user declared in their configuration.
Additional context: disable_module_cache toggle not available in v2.30.x
A per-template toggle (disable_module_cache) was added in #21931, which merged to main on Feb 5, 2026. However, this was never cherry-picked to the release/2.30 branch. This means:
Additionally, even in v2.31+ where the per-template toggle exists:
- There is no deployment-level or server-wide flag to disable module caching — administrators with many templates (e.g. ~100) must update each template individually
- The
coder/coderd Terraform provider (coderd_template resource) does not expose the disable_module_cache attribute, so templates managed via Terraform cannot use this setting
Background: why caching was introduced
The caching behavior was introduced to solve real problems:
- Disk/memory pressure: Repeated module downloads on every workspace build could cause ever-growing
.terraform/modules cache on provisioner nodes, leading to OOM or exit code 1 on coderd instances at scale
- Stability: Upstream module changes could break workspace restarts without any template changes
- Performance: Eliminating repeated downloads speeds up workspace startup
These are valid concerns. However, the current implementation is all-or-nothing with no way to manage it at the deployment level, and it overrides Terraform's native version resolution without the user's consent.
Expected Behavior
- Terraform semver constraints should be respected as written — if a user specifies
~> 1.1.0, they expect the latest matching version to be fetched on each workspace build, not a cached/pinned version from import time. If explicit pinning is desired, the user would specify an exact version (e.g. version = "1.1.3").
- Deployment-level configuration option — A global flag (e.g.
CODER_DISABLE_TERRAFORM_MODULE_CACHE) to disable module caching across all templates, rather than requiring per-template updates. Per-template settings could still override the deployment default.
- UI messaging when globally disabled — When caching is disabled at the deployment level, the template settings UI should indicate this clearly, e.g.: "Terraform module caching is disabled at the deployment level. Modules will be re-downloaded on each workspace build. Note: disabling caching means provisioner nodes may accumulate Terraform module files on disk, which can impact stability at scale."
- Backport — The
disable_module_cache toggle should be backported to v2.30.x so that users on that release line have a way to opt out.
- Terraform provider support — The
coder/coderd Terraform provider should expose the disable_module_cache attribute on the coderd_template resource.
Steps to Reproduce
-
Create a template that references a module with a semver constraint:
module "base_template" {
version = "~> 1.1.0"
# ...
}
-
Push the template version (module resolves to e.g. 1.1.3)
-
A new version 1.1.4 is released upstream
-
Start a workspace — it still uses 1.1.3 from cache, ignoring the available 1.1.4
Environment
- Coder version: v2.30.3+55da992 (confirmed:
disable_module_cache toggle is absent)
Created on behalf of @maxbeutel
Summary
Add a deployment-level (global) option to disable Terraform module caching across all templates, instead of requiring administrators to toggle each template individually.
The per-template
disable_module_cachetoggle already exists in v2.31+ (verified in code), but there is no server-wide flag and no deployment default that templates can inherit from. Admins with many templates (e.g. ~100) currently have to update each one by hand.Verified current state (as of
main, 2026-06-08)disable_module_cacheis a real field:codersdk/templates.goexposesDisableModuleCache boolon the template andDisableModuleCache *boolon the update-meta request.000416_workspace_module_reuse_toggleaddsdisable_module_cache BOOL NOT NULL DEFAULT falseto thetemplatestable.coderd/templates.go,coderd/templates_meta_update.go,coderd/provisionerdserver/provisionerdserver.go, the audit table, generated TS types, and the Template Settings UI.release/2.31,release/2.32,release/2.32.0-rc, andmain; absent inrelease/2.30.CODER_DISABLE_TERRAFORM_MODULE_CACHE) was found incodersdk/deployment.go,cli/,enterprise/cli/, orcli/server.go.coderdTerraform provider (coderd_templateresource) does not expose adisable_module_cacheattribute, so templates managed as code cannot set it.Proposed Behavior
CODER_DISABLE_TERRAFORM_MODULE_CACHE) to disable module caching across all templates.disable_module_cachesetting should be able to override the deployment default, so individual templates can opt back in/out.disable_module_cacheon thecoderd_templateresource in thecoderdTerraform provider, so templates managed as code can set the toggle. (Lives in the separate provider repo; tracked as part of this body of work.)Background: why caching exists (do not regress these)
Module caching was introduced (#21398, v2.30) to solve real problems, and the global opt-out must remain opt-in so these defaults are preserved:
.terraform/modulescache on provisioner nodes, leading to OOM at scale.Out of scope / tracked elsewhere
release/2.30.original description
Is there an existing issue for this?
Current Behavior
Since v2.30 (#21398), Terraform modules are cached at template import time and reused for all subsequent workspace builds. This means that semver version constraints like
~> 1.1.0are resolved once at import time and then effectively pinned — the constraint is never re-evaluated on workspace builds, even when newer matching versions are available upstream.This silently overrides Terraform's native version resolution semantics. If a user specifies
version = "~> 1.1.0", the intent is "give me the latest patch within this range." The caching behavior changes this to "pin whatever version was latest at import time," which is fundamentally different from what the user declared in their configuration.Additional context:
disable_module_cachetoggle not available in v2.30.xA per-template toggle (
disable_module_cache) was added in #21931, which merged tomainon Feb 5, 2026. However, this was never cherry-picked to therelease/2.30branch. This means:Additionally, even in v2.31+ where the per-template toggle exists:
coder/coderdTerraform provider (coderd_templateresource) does not expose thedisable_module_cacheattribute, so templates managed via Terraform cannot use this settingBackground: why caching was introduced
The caching behavior was introduced to solve real problems:
.terraform/modulescache on provisioner nodes, leading to OOM or exit code 1 on coderd instances at scaleThese are valid concerns. However, the current implementation is all-or-nothing with no way to manage it at the deployment level, and it overrides Terraform's native version resolution without the user's consent.
Expected Behavior
~> 1.1.0, they expect the latest matching version to be fetched on each workspace build, not a cached/pinned version from import time. If explicit pinning is desired, the user would specify an exact version (e.g.version = "1.1.3").CODER_DISABLE_TERRAFORM_MODULE_CACHE) to disable module caching across all templates, rather than requiring per-template updates. Per-template settings could still override the deployment default.disable_module_cachetoggle should be backported to v2.30.x so that users on that release line have a way to opt out.coder/coderdTerraform provider should expose thedisable_module_cacheattribute on thecoderd_templateresource.Steps to Reproduce
Create a template that references a module with a semver constraint:
Push the template version (module resolves to e.g.
1.1.3)A new version
1.1.4is released upstreamStart a workspace — it still uses
1.1.3from cache, ignoring the available1.1.4Environment
disable_module_cachetoggle is absent)Created on behalf of @maxbeutel