GoogleCloudPlatform / terraform-python-testing-helper

Simple Python test helper for Terraform.
https://pypi.org/project/tftest/
Apache License 2.0
214 stars 31 forks source link

Options for managing `.terraform.lock.hcl`? #39

Closed lorengordon closed 2 years ago

lorengordon commented 2 years ago

I occasionally run into an issue with the .terraform.lock.hcl, where I either need to pass -upgrade to terraform init, or just remove the lock file to let it regenerate. It doesn't look to me like parse_args() is supporting the -upgrade option? I was checking to see if I could (ab)use extra_files to remove it after the test, but that doesn't seem like a great option... Not sure if I'm missing something obvious here...

Fwiw, the issue appears to be when I run tests at some point in time, which generates the lock file on my machine. Then I add some new feature to the module later and re-run the tests. The provider version in the lockfile does not yet support the feature, so the test fails. And like I said, manually deleting the lock file gets it working, or manually running terraform init -upgrade. This is a re-usable module, not a root module, so the test configs do not commit the lock file.