-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Environment
Component: Coder CLI
Version: v2.25.2
File: cli/parameterresolver.go#L233
Summary
The CLI's parameter resolver rejects dynamic parameters (using count conditions) when creating workspaces, even though the same parameters work perfectly via API calls.
This breaks CLI/pipeline workflows for templates with dynamic parameters.
Coder Docs may indicate that creating Workspaces with the CLI should work.
This primarily affects users who want to automate the 'coder create' command, i.e. CI/CD etc.
Expected Behavior
coder create --template test test-ws --rich-parameter-file param.ymlA simple alternative would be to generate an error message explaining the disparity or Beta status when Dynamic Parameters are detected and cause errors.
Workaround
- Use the API
- Create Workspaces in the UI
# Get template ID
TEMPLATE_ID=$(coder templates list --output json | jq -r ".[] | select(.name == \"$TEMPLATE\") | .id")
# Convert YAML to JSON
PARAMS=$(yq eval '. | to_entries | map({"name": .key, "value": .value | tostring})' param.yml -o json)
# Create via API
curl -X POST "$CODER_URL/api/v2/users/me/workspaces" \
-H "Coder-Session-Token: $CODER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
--data "{\"name\":\"$WORKSPACE\",\"rich_parameter_values\":$PARAMS,\"template_id\":\"$TEMPLATE_ID\"}"Expected Resolution
The CLI should successfully create and start a Workspace, where it can evaluate dynamic parameters using provided parameter values, matching the behaviour of the API and UI.
Related Issues
#19754 – Dynamic Parameters: local module path cannot be resolved
#19789 – Template parsing error when using count with module outputs