terraform-switcher: Version: v1.1.1 no longer reads terraform required_version anymore

head -2 versions.tf

terraform {
  required_version = "1.6.3"

tfswitch 1.1.1 now shows questions in a github action ci/cd pipeline:

Use the arrow keys to navigate: ↓ ↑ → ←
? Select Terraform version:
  ▸ 1.5.7 *recent
    1.6.3 *recent
    1.1.9 *recent
    1.8.4
↓   1.8.3

‘old’ version 0.13 does what I expect it to :

~/bin/tfswitch-0.13.1308
Reading required version from terraform file
Reading required version from constraint: 1.6.3
Matched version: 1.6.3
Installing terraform at /home/hans/bin
Switched terraform to version "1.6.3"

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 29 (13 by maintainers)

Most upvoted comments

Ah, no, before we “actually” attempt to get the version constraints, we check if there “is terraform” (https://github.com/warrensbox/terraform-switcher/blob/master/lib/param_parsing/versiontf.go#L66), during which we ignore any errors whilst loading the terraform and don’t attempt to load it “properly”. So yes, if there’s terraform with incorrect syntax, we silently ignore it. I will bring this up in #429

What can I try next ?

Well, looks like wait for a next release when we will provide an correction to the broken logic.

@MatrixCrawler Maybe you may have an idea of what could be preventing tfswitch from picking up TF version for @d33psky given an existing logic in parameters parsing? Thanks.