-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lock file handling strategy is not best practice? #1653
Comments
Thanks for raising this discussion! I suspect that different users will want to handle lock files differently:
I suspect (1) is the best practice for most, so I'd be in favor of this update:
On the other hand, this change might interfere with (2):
Perhaps this is one place where we add a flag that skips the lock file copying functionality. Or, vice versa, enables the copying functionality, with the default being off. |
That sounds like the right solution. My concern would be what the default is - at the moment I suspect somebody who isn't giving much thought to this will read the docs (or not) and end up with scenario 2 when they almost certainly would be better off with scenario 1. To be honest I don't see much of a use case for scenario 2 but maybe I can't see past my own experience here. Where I have used lock files in the past, it is analogous with scenario 1. For example:
Drawing parallels with this in the context of terraform:
...but maybe not every use case is as simplistic as this. Or for some others the |
I think the key use case you're missing is that people often use Terragrunt to generate code. This includes generating It's worth mentioning that in most programming environments, including Node.js, there are actually multiple lock files. E.g., The open source project express.js has its own lock file; and my project, which depends on |
yep, you're right. I guess a rule of thumb is the lock file lives with the provider version constraints definition - i.e. the Not sure its worth debating here but not sure you are right about the multi-layer lock files, at least in the Both modules and applications will have |
I agree with @james-skinner-deltatre here, it really seems appropriate to version terraform lockfiles within the underlying modules instead of within the live repository that contains the
It would be much easier if the live environment only had to be concerned with the version of the terraform module that's being ran, that's it. Then, the module could handle all of the required terraform providers and their exact versions. I like @brikis98's suggestion of adding a flag to skip the lockfile copying functionality, or perhaps adding it as a configuration attribute within the I'd be happy to open a PR with this functionality if it would be welcomed. |
This analogy breaks when you consider what @brikis98 said - the referenced module that provisions a microservice is not akin to a Node.js App, because in most cases you can't even apply it without all the config generated by Terragrunt. It would be great if Terragrunt had better support for lock files, rather than more options to disable them. |
This has been released in v0.67.11 |
I am looking at adopting
terragrunt
into our workflow. Everything looks good to me so far except the advice and behaviour around handling.terraform.lock.hcl
files does not seem right.I have read over the related issue #1498 and I think this comment hits the nail on the head.
The lock file exists so that I can pull down dependencies for a specific version of my codebase in a repeatable way. So that means when I have [email protected] and run
terraform init
I get the same provider versions, whether I am running tests, deploying to dev or stage or prod etc.This means the lock file belongs with the module code - i.e. versioned alongside the provider constraints and the rest of the code.
The terragrunt docs on the other hand, imply the lock file should live with the environment configuration. If you do this then:
From what I can see, in the scenario where the lock file lives in the module code,
terragrunt
does respect the.terraform.lock.hcl
file rather than overwriting it, which is great. However I think the following changes would be positive:.terraform.lock.hcl
file alongside the code, the copying functionality should be disabled...or maybe I am missing something here?
The text was updated successfully, but these errors were encountered: