Coder caches resolved Terraform modules per template version and reuses
them across workspace builds instead of re-fetching from origin. This is
enabled by default and can be disabled per-template with
`disable_module_cache`, but neither the caching behavior nor the toggle
were documented anywhere outside the generated API reference.
Documents module caching in the Terraform Modules guide (what gets
cached, the 20MB archive limit, and how to disable it), and cross-links
it from the existing "Module not loaded" troubleshooting entry in the
Dynamic Parameters doc, since both describe the same module archive.
Also documents a second cause of "Module not loaded" warnings: template
versions published before Coder started archiving modules for Dynamic
Parameters have no cache at all, so every module in the template shows
the warning in the workspace creation form. Workspace builds still
succeed, since Terraform fetches modules from their original sources
during the build regardless of the cache; only the form's ability to
evaluate module-backed parameter values is affected. Publishing a new
template version regenerates the archive and resolves it.
<details>
<summary>Verification notes</summary>
Behavior confirmed by reading the source, not assumed:
- `coderd/provisionerdserver/provisionerdserver.go`: skips fetching
`CachedModuleFiles` for a workspace build when
`template.DisableModuleCache` is set. The same file's comment ("Older
templates (before dynamic parameters) will not have cached module
files") confirms why some template versions have no archive at all.
- `provisioner/terraform/provision.go` + `provisionerd/runner/init.go`:
the cached archive is extracted into `.terraform/modules` before
`terraform init` runs, so modules already present are not re-downloaded;
anything missing (e.g. skipped for size, or no archive at all) is still
fetched normally by Terraform during the build.
- `provisioner/terraform/modules.go`: `MaximumModuleArchiveSize` = 20MB.
-
`coderd/database/migrations/000416_workspace_module_reuse_toggle.up.sql`:
`disable_module_cache` defaults to `false`, i.e. caching is on by
default.
- `site/.../TemplateSettingsForm.tsx`: exact dashboard label and warning
copy reused verbatim in the doc.
</details>
> Generated by Coder Agents