Summary
The coder-utils module currently requires start_script but gives install_script a default of null. In practice this is backwards — most consumers always need an install step but may not need a persistent start process. The module should be reworked so that install_script is the only required script and start_script becomes optional.
Current Behavior
install_script has default = null (optional).
start_script is required (no default).
module_dir_name sets a directory under $HOME/<name>.
- Four separate outputs (
pre_install_script_name, install_script_name, post_install_script_name, start_script_name) are always populated, even when the corresponding script is not created.
Desired Behavior
1. Flip required/optional for install vs start
install_script — required (remove default). The coder_script resource is always created (no count).
start_script — optional (default = null). Conditionally created with count = var.start_script != null ? 1 : 0.
2. Rename module_dir_name → module_directory
Give callers direct control over the full working directory path instead of only a subdirectory name. This is a breaking variable rename.
3. Consolidate outputs into a single map
Replace the four individual outputs with a single script_names map:
output "script_names" {
value = {
pre_install = var.pre_install_script != null ? local.pre_install_script_name : ""
install = local.install_script_name
post_install = var.post_install_script != null ? local.post_install_script_name : ""
start = var.start_script != null ? local.start_script_name : ""
}
}
Empty string ("") for scripts that are not provided, rather than emitting a name for a resource that does not exist.
4. Move sync dependency resolution into locals
Introduce install_sync_deps and start_sync_deps locals to compute the correct coder exp sync want arguments, removing the duplicated conditional logic from inline script templates.
5. Add mkdir -p to every script block
With install_script now potentially the first script to run (no pre_install_script), each script block should ensure the module directory exists via mkdir -p.
6. Bump required Terraform version to >= 1.9
Breaking Changes
install_script becomes required — callers that omitted it will need to provide a value.
start_script becomes optional — callers relying on it being required should be unaffected (providing a value still works).
module_dir_name renamed to module_directory.
- Four individual outputs replaced by a single
script_names map output — callers referencing module.coder_utils.install_script_name must change to module.coder_utils.script_names.install, etc.
Open Questions
- Semver: These are breaking changes. Should the version bump be
2.0.0 instead of 1.1.0?
- Missing newline at EOF in
main.tf should be fixed.
Related
Summary
The
coder-utilsmodule currently requiresstart_scriptbut givesinstall_scripta default ofnull. In practice this is backwards — most consumers always need an install step but may not need a persistent start process. The module should be reworked so thatinstall_scriptis the only required script andstart_scriptbecomes optional.Current Behavior
install_scripthasdefault = null(optional).start_scriptis required (no default).module_dir_namesets a directory under$HOME/<name>.pre_install_script_name,install_script_name,post_install_script_name,start_script_name) are always populated, even when the corresponding script is not created.Desired Behavior
1. Flip required/optional for install vs start
install_script— required (remove default). Thecoder_scriptresource is always created (nocount).start_script— optional (default = null). Conditionally created withcount = var.start_script != null ? 1 : 0.2. Rename
module_dir_name→module_directoryGive callers direct control over the full working directory path instead of only a subdirectory name. This is a breaking variable rename.
3. Consolidate outputs into a single map
Replace the four individual outputs with a single
script_namesmap:Empty string (
"") for scripts that are not provided, rather than emitting a name for a resource that does not exist.4. Move sync dependency resolution into
localsIntroduce
install_sync_depsandstart_sync_depslocals to compute the correctcoder exp sync wantarguments, removing the duplicated conditional logic from inline script templates.5. Add
mkdir -pto every script blockWith
install_scriptnow potentially the first script to run (nopre_install_script), each script block should ensure the module directory exists viamkdir -p.6. Bump required Terraform version to
>= 1.9Breaking Changes
install_scriptbecomes required — callers that omitted it will need to provide a value.start_scriptbecomes optional — callers relying on it being required should be unaffected (providing a value still works).module_dir_namerenamed tomodule_directory.script_namesmap output — callers referencingmodule.coder_utils.install_script_namemust change tomodule.coder_utils.script_names.install, etc.Open Questions
2.0.0instead of1.1.0?main.tfshould be fixed.Related