feat: Add `disable_module_cache` attribute to `coderd_template` resource

Open Beginner friendly
#332 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Quiet
Tech stack
go, terraform

Research direction

Start in internal/provider/template_resource.go and inspect TemplateResourceModel alongside the existing cors_behavior and use_classic_parameter_flow attributes. Check how the model is mapped to codersdk.UpdateTemplateMeta and how defaults are represented. Done means Terraform can configure disable_module_cache on coderd_template with a default of false.

Written by the indexing model from the issue text.

Description

Summary

The coderd_template resource does not currently expose the disable_module_cache attribute, which was added to the Coder API in coder/coder#21931 (v2.31+). This means templates managed via Terraform have no way to control this setting.

Context

Since v2.30 (coder/coder#21398), Terraform modules are cached at template import time and reused for all subsequent workspace builds. A per-template toggle disable_module_cache was added in coder/coder#21931 to allow opting out of this behavior.

The setting is available via:

  • The Coder UI (Template Settings)
  • The REST API (PATCH /api/v2/templates/{id} with disable_module_cache: true)

But it is not available via the coderd_template Terraform resource, which is the primary way many teams manage their templates as code.

Related

  • coder/coder#22834 — Tracks the broader gaps: deployment-level flag, TF provider support, v2.30 backport
  • coder/coder#22531 — Related bug where module caching breaks relative-path file inclusion

API Reference

The Coder SDK already supports this field:

  • codersdk.UpdateTemplateMeta.DisableModuleCache (*bool, JSON: disable_module_cache)
  • Endpoint: PATCH /api/v2/templates/{id}

Proposed Change

Add a disable_module_cache boolean attribute to the TemplateResourceModel struct in internal/provider/template_resource.go, following the same pattern as the recently added cors_behavior (#293) and use_classic_parameter_flow attributes.

Default should be false (caching enabled) to match the server-side default.


Filed on behalf of @bjornrobertsson

Dominant language
Go
Stars
29
Forks
14
Avg merge
1d 19h
Merged PRs (30d)
16

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from coder/terraform-provider-coderd

All issues in coder/terraform-provider-coderd

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.