-
Howdy 👋 I am curious to understand why this PR seemed to introduce a forced "-lock=false" option to Terraform plan without any option to override? Documentation I am reading that doesn't mention lock options: I have not actually hit an issue which is why I chose a discussion. My context was I was attempting to verify the introduction of an s3 state lock mechanism and assumed that plan would lock since that's the default for terraform. It appears I'll need another method, which is reasonable. I do see locking on plan is sort of a debated topic within the Terraform community and while documentation does not recommend disabling it, it appears to be a contextual choice: hashicorp/terraform#28130 I did search for previous issues/discussion and went to the blame to see if it had anything. I don't see anyone mentioning this. If I missed something my bad. This is truly an ask for perspective. I am learning terraform and am curious of your take given the expertise here. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @ojintoad. The dflook/terraform-plan (and dflook/terraform-check) actions run Think of the plan action as creating a speculative plan - what would happen if this change was applied right now? If we locked the state while we did this, then:
The second point sounds like a reason to lock the state, but at the time we review/apply the plan it could still easily be out of date due to the nature of concurrent CI jobs and asychronous PRs. These actions were specifically designed to work well with busy repos that have multiple open PRs, that may not be merged in any kind of predictable order, and have plans that take quite a while to run. When the terraform-apply action runs, it will generate a new plan (using a state lock) and compare it to the plan from the terraform-plan action - if they are the same then it will be applied. If the plan has changed then it will abort by default. One reason the plan could have changed is another apply operation changed something - but locking the state file for the original plan doesn't prevent that. |
Beta Was this translation helpful? Give feedback.
Hi @ojintoad.
The dflook/terraform-plan (and dflook/terraform-check) actions run
terraform plan
with-lock=false
because they do not write to the state. But the dflook/terraform-apply action does modify the state file, so it runsterraform plan
with the state lock enabled (it will then runterraform apply
, again with a state lock). So they both runterraform plan
, the difference is if the github action as a whole could modify the state file.Think of the plan action as creating a speculative plan - what would happen if this change was applied right now? If we locked the state while we did this, then: