-
-
Notifications
You must be signed in to change notification settings - Fork 999
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
Handling of .terraform.lock.hcl #1498
Comments
I just achieved this yesterday by doing the following: Add terraform {
extra_arguments "init_args" {
commands = [
"init"
]
arguments = [
"-upgrade",
]
}
} Then simply run plan on all your modules: terragrunt plan-all This will force update all your lock files. |
I achieved it with running Ideally creating |
Seems like #492 would solve this, right? |
Yes, if it'll ever get done. |
Hey guys. I'm just wondering what people are doing around Terragrunt and these 'helpful' new lockfiles. So say you have the structure in terragrunt like; env/region/stack
It would make sense to me that all 3 envs (dev/nonprod/prod) have the same lockfile contents, if you are promoting a release(git tag/commit/etc) through your environments. To do this it seems I'd need to in the first path generate the new .terraform.lock.hcl then manually copy it to the other two environments paths. That seems open to human error especially when we're talking about 100's of stacks and just messy and not very DRY. I guess ideally it'd be good if .terraform.lock.hcl was outside of the env/region path and bound to all stacks containing the same name, any idea how that would be possible using Terragrunt ? The other option I thought is in CI during the DEV planb/apply stage we pass the .terraform.lock.hcl file on through the pipeline, but then if you attempt to re-run the same TAG X days later and a new provider downloads results could differ. |
That's not SDLC. First you update it on dev and test if it's ok. If you don't commit lock files you will achieve what you mentioned - it will always look for a provider using defined chain and version restrictions. |
We do that but in a different way. We test it on dev env(lets say feature branch), then if passed we merge+tag the repo and promote the tag upwards, but if we need to manually copy the file to lockfile to ./nonprod/eu-west-1/consume-ami |
I'm also struggling with the new lockfile. Seems like a similar use case to @eperdeme. For us it's one module, many many implementations of the same module managing a baseline set of resources across all accounts of a given "env" or "stage" (so, all "dev" accounts, for example). The new lockfile is quite painful to update across all of the terragrunt directories, and would basically involve a human or CI process running The only advantage I can see to the lockfile is the hashes. The versions can already get pinned in the terraform config block. So for now, my workaround is basically just to git-ignore the lockfile. 🤷♂️ I also already construct the plugin-cache with known providers. So, pin provider versions, use terraform-bundle to create the plugin-cache with those versions, and host that for the build system. Build system retrieves the bundle, sets up the plugin-cache so only those versions are used/available, runs terragrunt. Also added an after-hook in the terragrunt config to remove
I'm considering keeping a more central copy of the lockfile in one place in the project, and using a before-hook to copy it into the terragrunt working dir before any command. I'd still remove it from the working dir after, and separately manage updates to that central copy. Edit: I suppose instead of copying the file, I could use |
Thanks for providing more context everyone. A few thoughts:
|
I guess I can make script that will run
It will not work in my case for example. My modules' monorepo uses the newest providers, as there is only Also wouldn't the file be overwritten automatically by Terragrunt if its coming from module's repo? |
Agreed. PRs welcome!
Hm, we typically have all of our automated testing in the
If you had the lock file checked into the |
I have a PR that implements #492 in #1520, which should allow you to do |
#1520 is now merged and released as https://github.com/gruntwork-io/terragrunt/releases/tag/v0.28.1 |
Love it! Tomorrow I'll test it. Thank you all. |
Will there be any way of upgrading providers' locks in batches?
I mean something that will run
terraform init -upgrade
for the whole Terragrunt module tree.Even first generating of
.terraform.lock.hcl
files is not straightforward and I needed to useterragrunt output-all
to make it faster.Imagine having hundreds of Terragrunt modules in your tree, that's my use case.
The text was updated successfully, but these errors were encountered: