Closed blundell closed 2 years ago
Ah I have found a state file in my original root project.
i.e. I am running in a module in a composite project
/my-project/ <<< 1 state file was found here
/my-composite-build/ <<< 3 here would also be ok, its the root project I expect
/my-terraform-module/ <<< 2 was hoping for it here
The lock file is a dependency management mechanism to avoid installing unwanted upgrades during terraform init
. On the other hand the plan file has it's own stateFile
variable with a default in "src/$name/terraform/terraform.tfstate"
.
It is normally created by Terraform itself when you execute the plan.
ty
that's what I was trying to say, it's not being created in "src/$name/terraform/terraform.tfstate"
I'll see if I can make a simpler reproduction project (I use composite builds https://docs.gradle.org/current/userguide/composite_builds.html)
I made a simple reproduction project here: https://github.com/blundell/TerraformGradlePluginPlayground
Running
./gradlew :backend:backend-terraform:terraformPlan
export ENABLE_TF_APPLY=true
./gradlew :backend:backend-terraform:terraformApply && export ENABLE_TF_APPLY=false
The tfstate file is not generated.
Main TF File: https://github.com/blundell/TerraformGradlePluginPlayground/blob/master/backend/backend-terraform/src/main/terraform/main.tf Build file: https://github.com/blundell/TerraformGradlePluginPlayground/blob/master/backend/backend-terraform/build.gradle.kts
(I confirmed it should be generated with this setup here https://github.com/gruntwork-io/terratest/issues/1060)
Any thoughts on this? I'm stuck without a state file :-)
I can see the state is generated in build/terraform/main/runtimeExecution/terraform.tfstate
I guess a work around for now is if I copy that file back out the build folder manually after each apply?
💯
I ran
terraformApply
and I got a .lock.hcl file, but I did not get a state file? Should I have?Also is this an error in the readme:![image](https://user-images.githubusercontent.com/655860/153078122-57c27f61-e22d-42e1-ae8f-c64c75c8222a.png)
Under the state file title it says:
and the example says
lockFile =
.. should it bestateFile =
?