You know when’s the most annoying time to see a terraform version error?
When you are trying to terraform import
a bunch of orphaned resources that didn’t successfully delete during CRUD cause of a bug in a custom module.
Error: Error loading state:
Remote workspace Terraform version "1.4.6" does not match local Terraform version...
…
SREs are probably laughing at us for not using direnv
; but hey, why do I even need to worry about matching versions when I’m using remote
workspace mode with Terraform Cloud? Don’t have to match versions with apply
and plan
…
anways, here’s the quick fix.
- If you want version
1.4.6
brew uninstall terraform # I assume you are civilised
brew install tfenv
tfenv install 1.4.6
tfenv use 1.4.6
terraform --version # trust but validate
- If you want to switch to another verison
tfenv install 1.5.4
tfenv use 1.5.4
terraform --version
- If you are an over-achiever
- spend the time to set up direnv like the SREs told you
- or try the tips in this stackoverflow thread