Dynamically Adjust Tofu Version per Stack Based on Repository
The team is in the process of upgrading multiple IaC repos and finds it tedious and error-prone to manually update the Terraform/OpenTofu version per stack in the Spacelift UI each time a version bump occurs (e.g., from ~> 1.9.0 to ~> 1.10.0).
Since different repositories (and branches) may use different versions of Tofu during transition periods, managing this statically at the stack level adds friction to CI/CD workflows and increases the chance of misalignment.
Proposed Solution
Enable the stack to dynamically select the Terraform/OpenTofu version based on a config value found in the repository itself — for example:
A
tofu-versionfile in the rootA version defined in
spacelift.yamlReading from
.tool-versionsor a specific environment variable
This would allow teams to:
Keep versioning in sync with repo changes
Reduce manual maintenance overhead in Spacelift
Smoothly transition across versions during upgrade cycles
Log in to comment and vote
Comments3
Natalia Gazda
Aug 12, 2025
Hey @Charles Bushong thanks for the request!
Do you know you can achieve that using Spacelift's runtime configuration feature! No more manual UI updates needed.
Simply create a
.spacelift/config.ymlfile in your repository root. You can even set defaults for all stacks in the repo.Would this approach work for your use case? Happy to have someone from support reach out to you to help with the config setup.
Jade Elephant
Aug 12, 2025
Oh that’s awesome, I had no idea. I’m trying to read the docs, but I don’t see any example files to show a full format of the file. I think that would go a long way for understanding.
Natalia Gazda
Aug 13, 2025
@Charles Bushong I’ll make sure we’ll add it to the docs :) Someone from solutions team might still reach out to double check you’re all set :)
yaml version: "2" stacks: your-stack-slug: terraform_version: "~> 1.10.0" # or specify exact version # For OpenTofu: # opentofu_version: "1.10.0" # terraform_workflow_tool: "OPEN_TOFU"You can even set defaults for all stacks in the repo:
yaml version: "2" stack_defaults: terraform_version: "~> 1.10.0" stacks: specific-stack: terraform_version: "~> 1.9.0" # Override for specific stack