The source project of this merge request has been removed.
Add variable TF_INIT_FLAGS
After we committed the .terraform.lock.hcl
file to our git repositories we started to see the following error occur on random occasions:
$ gitlab-terraform apply
Initializing modules...
Initializing the backend...
Successfully configured the backend "http"! Terraform will automatically
use this backend unless the backend configuration changes.
Initializing provider plugins...
- Reusing previous version of hashicorp/random from the dependency lock file
- Reusing previous version of hashicorp/aws from the dependency lock file
- Reusing previous version of datadog/datadog from the dependency lock file
- Using previously-installed datadog/datadog v3.13.1
- Using previously-installed hashicorp/random v3.3.2
- Using previously-installed hashicorp/aws v4.23.0
Terraform has been successfully initialized!
╷
│ Error: Inconsistent dependency lock file
│
│ The given plan file was created with a different set of external dependency
│ selections than the current configuration. A saved plan can be applied only
│ to the same configuration it was created from.
│
│ Create a new plan from the updated configuration.
╵
This MR tries to fix the issue by running terraform init with -lockfile=readonly
before the apply
, plan
, destroy
& validate
commands.
The lockfile should only be able to change with an explicit call to gitlab-terraform init
.
This MR will add a new variable TF_INIT_FLAGS
to allow users to pass custom flags to terraform init
.
We can then use this variable to set -lockfile=readonly
during the init.
Edited by Tobias Germer