Skip to content
Commit c6d84511 authored by Alexis Deruelle's avatar Alexis Deruelle
Browse files

fix: tf-validate: remove cached terraform.tfstate

In 'tf-validate' job, terraform validate will try to access the remote
backend when it's already configured, which happens because .terraform/
folder is cached (backend config is stored in
.terraform/terraform.tfstate).

However with the GCP variant currently the pipeline has no credentials
in place yet at this stage and the '-backend=false' flag is not enough
to prevent this from happening in this case.

The problem is well documented, see
https://github.com/hashicorp/terraform/issues/33726#issuecomment-1697854309

Solution:

 - hide the pre-configured backend setup by removing the
   terraform.tfstate file beforehand in the tf-validate script
 - setting the cache policy to pull in order to keep the file for subsequent
   jobs

Fixex: #80
parent 09f54e00
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment