terragrunt
terragrunt copied to clipboard
Error: Required plugins are not installed (terraform 1.1)
After upgrading terraform to version 1.1 I've got error Error: Required plugins are not installed for every terragrunt command.
Configurations
terraform {
extra_arguments "cache" {
commands = [
"init",
"apply",
"refresh",
"import",
"plan",
"taint",
"untaint"
]
env_vars = {
TF_PLUGIN_CACHE_DIR = "$HOME/.terraform.d/plugin-cache"
}
}
}
and
$ cat ~/.terraformrc
plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"
do not make any effect.
More outputs:
$ terragrunt apply
╷
│ Error: Required plugins are not installed
│
│ The installed provider plugins are not consistent with the packages
│ selected in the dependency lock file:
│ - registry.terraform.io/cloudflare/cloudflare: there is no package for registry.terraform.io/cloudflare/cloudflare 2.23.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/aws: there is no package for registry.terraform.io/hashicorp/aws 3.49.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/helm: there is no package for registry.terraform.io/hashicorp/helm 2.2.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/kubernetes: there is no package for registry.terraform.io/hashicorp/kubernetes 2.3.2 cached in .terraform/providers
│
│ Terraform uses external plugins to integrate with a variety of different
│ infrastructure services. To download the plugins required for this
│ configuration, run:
│ terraform init
╵
ERRO[0004] exit status 1
$ terragrunt init
╷
│ Error: Required plugins are not installed
│
│ The installed provider plugins are not consistent with the packages
│ selected in the dependency lock file:
│ - registry.terraform.io/hashicorp/aws: there is no package for registry.terraform.io/hashicorp/aws 3.49.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/helm: there is no package for registry.terraform.io/hashicorp/helm 2.2.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/kubernetes: there is no package for registry.terraform.io/hashicorp/kubernetes 2.3.2 cached in .terraform/providers
│ - registry.terraform.io/cloudflare/cloudflare: there is no package for registry.terraform.io/cloudflare/cloudflare 2.23.0 cached in .terraform/providers
│
│ Terraform uses external plugins to integrate with a variety of different
│ infrastructure services. To download the plugins required for this
│ configuration, run:
│ terraform init
╵
ERRO[0004] exit status 1
Hello @Sebor this issue occurs on which Terragrunt version? which OS?
Hello @Sebor this issue occurs on which Terragrunt version? which OS?
Sorry, I forgot to mention it. OS: MacOS 12.1 Terragrunt: v0.35.16
Apple MBP M1 with terraform for ARM 64. OS: MacOS 12.0.1
Terraform v1.1.2
on darwin_arm64
╷
│ Error: Required plugins are not installed
│
│ The installed provider plugins are not consistent with the packages
│ selected in the dependency lock file:
│ - registry.terraform.io/hashicorp/aws: there is no package for registry.terraform.io/hashicorp/aws 3.60.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/external: there is no package for registry.terraform.io/hashicorp/external 2.1.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/local: there is no package for registry.terraform.io/hashicorp/local 2.1.0 cached in .terraform/providers
│ - registry.terraform.io/hashicorp/null: there is no package for registry.terraform.io/hashicorp/null 3.1.0 cached in .terraform/providers
│
│ Terraform uses external plugins to integrate with a variety of different
│ infrastructure services. To download the plugins required for this
│ configuration, run:
│ terraform init
╵
@Sebor can you try deleting the .terraform.lock.hcl file?
I was able to reproduce and then solve by removing the lock file.
Hi, @exocom! I remember I had done it before posted issue. But now suddenly I cannot reproduce this one...
If you have dependencies, try to clear and init or upgrade the dependencies first. This step solved my issue.
Can confirm removing the lock files solves it, but you need to do it on the current module and any it depends on.
terragrunt version v0.36.1
Terraform v1.1.5
on darwin_amd64
we've also been running into this issue, and don't fully grasp the reason for the failures.
I kept running into this error for a particular directory. I tried deleting the terraform lock files but that wasn't helping. Finally I found if I deleted ./.terragrunt-cache from where I was executing terragrunt, it finally worked without error for me.
@Sebor can you try deleting the
.terraform.lock.hclfile? I was able to reproduce and then solve by removing the lock file.
Same problem and deleting the lock file is the only solution that works for me.
My team has been running up against this problem constantly for at least a month. We've updated our lockfiles with terragrunt init -upgrade, but haven't tried deleting them yet. For folks that have had luck with the deletion route: can I reinstate the lockfile after I get a clean plan/apply? I ask because we like to have our lockfiles checked in to git, to ensure that our Actions runner will always use the same set of providers.
If you have dependencies, try to clear and init or upgrade the dependencies first. This step solved my issue.
This one.
I've switched terraform version and this error occurred.
Obviously first thing I deleted lock file and than .terragrunt-cache, but issue still happened.
So my solution was to comment out dependency blocks and than re-init terragrunt.
Then I run terragrunt init on dependenent modules and than returned the first terragrunt.hcl to original form.
My guess would be that terragrunt assumes that you have provider from dependent module installed but after version switch terragrunt can't find it.
I've came across this issue a few times (also apple silicon) - my solution was clearing .terragrunt-cache and/or .terraform.lock.hcl in dependency block paths. It wasn't my direct module causing the issue but work I had init/plan/applied days ago where there has been a provider update then causing issues when its fetching output from the dependency.
We have this issue randomly on our build server, it's quite frequent. It only seems to affect modules with terragrunt dependencies on others. A rebuild generally fixes it.
If you have dependencies, try to clear and init or upgrade the dependencies first. This step solved my issue.
This did the trick for me.
Deleting lock file and cache didn't help.
I usually get this issue and the solution for this is to delete the cached terraform files by running this two commands in ubuntu to the XYZ directory location example: /mnt/c/Repo/azure_xyz
Hope it helps :)
find . -name .terraform.lock.hcl -exec rm -rf {} \;
find . -name .terraform -type d -exec rm -rf {} \;
Edit: I tried running terragrunt run-all init -upgrade which also solved the problem. However I would like to understand the error a little bit better...
Also this solution does not require you to delete the terragrunt cache files.
tl;dr: try setting disable_dependency_optimization to true in your remote block.
My team and I manage a monorepo with 300+ root modules in it, all as terragrunt modules. We have run into this problem hundreds of times per day, every day. Here are some of the things we've learned:
We have rarely or never seen this issue when we run terragrunt on our local machines, we only see the issue when it's run in our GitHub Actions workflow. I'm guessing it's because on our locals we cache our providers long-term in $HOME/.terraform.d/plugin-cache.
Yesterday we turned on debug logging for both terragrunt and terraform, to see what a failure and a success look like next to each other. We've only done some spot checking, but we realized something: We almost always see the "Required plugins not installed" error in a root module that has more than 1 dependency block! This led us to believe it was some kind of race condition in the way terragrunt handles dependencies.
Another factor we're considering is that only 10% of our terragrunt modules are the kind with .tf files in them. The vast majority of our roots use a terraform block in terragrunt.hcl. I'm not sure how this might make a difference to terragrunt's execution.
One of my teammates looked into the terragrunt docs to see what they could find about dependencies, and they found a flag we could set in our remote block to disable dependency optimization. Setting disable_dependency_optimization to true in our remote block seems to have made the problem go away! We're still investigating, but this is a promising lead for us.
I'll be back if we find out more in our travels.
i have the same issue. works like a charm locally on laptop, but fails with no patterns on server when running through azure pipelines.
tl;dr: try setting
disable_dependency_optimizationtotruein yourremoteblock.
the setting above worked for me aswell. but im more interessted in knowing why, seems to appear after upgrade to tf 1.1.x for me
I've came across this issue a few times (also apple silicon) - my solution was clearing .terragrunt-cache and/or .terraform.lock.hcl in dependency block paths.
This resolved it for me, thank you! 💯 So: Go into every folder of your dependencies and delete the .terragrunt-cache folders, then rerun terragrunt commands.
So: Go into every folder of your dependencies
I've been using find . -name '.terragrunt-cache' | xargs rm -rf to do it more automatically.
We are facing the same issue after upgrading TF from 1.1.3 to 1.4.2. On Arch Linux with terragrunt version 0.43.2.
Neither deleting lock and/or cache files nor deleting plugin-cache nor setting the optimization flag yield any meaningful improvement.
So far the only way is to delete the files and re-run and hope it works.
And it takes a long time to fail. 2 minutes for a modulke with 3 dependencies.
We are facing the exact same problem.
Switch the setting disable_dependency_optimization to true doesn't worked at all.
Our Terraform Setup is running in a Gitlab CI/CD.
I've came across this issue a few times (also apple silicon) - my solution was clearing
.terragrunt-cacheand/or.terraform.lock.hclin dependency block paths. It wasn't my direct module causing the issue but work I had init/plan/applied days ago where there has been a provider update then causing issues when its fetching output from the dependency.
This was the exact issue I was having. This solution worked for me. Thanks @mark-lightfoot
Had same issue removing .terraform.lock.hcl seems to be the trick for now
Same issue. I had to run an 'init' in every dependency before launching anything. I confirm it looks like a race condition because it appears only with more than one dependency.
Setting 'disable_dependency_optimization = true' seems to fix it in my case.
As I can see this issue is mostly happening with Apple Silicon M1&M2. As I may see it is because of .terraform.lock.hcl does not contain provider selection for the target arch darwin_arm64. So solution would be to delete terraform.lock.hcl and .terragrunt-cache or to regenerate lock file by adding support for all target platforms, e.g. terragrunt providers lock -platform=darwin_arm64 -platform=linux_amd64 -platform=darwin_amd64. Be aware if you are using some old providers, you may experience the same issue, as they do not have binary for darwin_arm64 (happened to me). In this case TF by default selects darwin_amd64 and fails to find binary afterwards as there is no darwin_arm64. Maybe you can try in that case with Rosetta emulation layer, but you will need to change terraform binary to amd64.
I have faced a similar issue on Ubuntu 20.04.5 LTS server
I tried deleting the .terragrunt_cache , .terraform.lock.hcl and .terraform folder but nothing worked.
I completely removed the git repo from local and cloned it once again which fixed the issue.
I had the exact same issue, I worked around it by adding the following to my ~/.terraformrc:
plugin_cache_may_break_dependency_lock_file = true
Hope this helps, this completely fixed it for me.
I had this error because some of the modules in dependency block had issues with aws provider plugin. You should first resolve the problem with linked module then it should work