Commit 1db72ded authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch '89-tf-validate-cached-state-config-workaround-fix' into 'master'

fix: tf-validate: remove TF_PROJECT_DIR from path

Closes #89

See merge request to-be-continuous/terraform!126
parents e829cf3a 5a0302db
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1221,9 +1221,11 @@ tf-validate:
      # Cached backend configuration in `.terraform/terraform.tfstate` may lead to
      # authentication failure of the `terraform init` command even with `-backend=false` flag
      # see https://github.com/hashicorp/terraform/issues/33726#issuecomment-1697854309
      if [[ -f $TF_PROJECT_DIR/.terraform/terraform.tfstate ]]; then
      #
      # assumption: working dir is $TF_PROJECT_DIR, currently set in .tf-base (see #89)
      if [[ -f .terraform/terraform.tfstate ]]; then
        log_info "--- \\e[32mpre-init\\e[0m tf-validate: removing cached .terraform/terraform.tfstate to disable any preconfigured backend"
        rm "$TF_PROJECT_DIR/.terraform/terraform.tfstate"
        rm ".terraform/terraform.tfstate"
      fi
    - tf_pre_init
    - terraform init -backend=false