[BUILD-881] Review Terraform error like "Required plugins are not installed" Created: 09/Aug/22  Updated: 24/Apr/23

Status: In Progress
Project: Build
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Neutral
Reporter: Roberto Gomez Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoR:
Empty
Team: Foundation
Approved:
Yes

 Description   

Sometimes Jenkins builds failed with the Terraform error like:

13:26:26  ╷
13:26:26  │ Error: Required plugins are not installed
13:26:26  │ 
13:26:26  │ The installed provider plugins are not consistent with the packages
13:26:26  │ selected in the dependency lock file:
13:26:26  │   - registry.terraform.io/hashicorp/archive: the cached package for registry.terraform.io/hashicorp/archive 2.2.0 (in .terraform/providers) does not match any of the checksums recorded in the dependency lock file
13:26:26  │ 
13:26:26  │ Terraform uses external plugins to integrate with a variety of different
13:26:26  │ infrastructure services. You must install the required plugins before
13:26:26  │ running Terraform operations.
13:26:26  ╵
 

There's a probable solution, that suggests the error is caused by:

<<The issue is that my local workstation is a Mac which uses the darwin platform, so all of the providers are downloaded for darwin and the hashes stored in the lockfile for that platform. When the CI system, which is running on Linux runs, it attempts to retrieve the providers listed in the lockfile, but the checksums don't match because they use a different platform.>>

 

We can check this kind of solution, but then again, also the lock files like the following must be included in VCS? 

 

 $ find . -name ".lock"                
./magnolia-core-experimental/eu-central-1/magnolia-mgmt-ui/.terragrunt-cache/BI4PwkgML2iC1bYuygGAMDkmgLQ/ZAi6KoCBlp_GK_BvGbKEAVu77II/magnolia-mgmt-ui/.terraform.lock.hcl
./magnolia-core-experimental/eu-central-1/magnolia-mgmt-ui/.terraform.lock.hcl
./magnolia-core-experimental/.terraform.lock.hcl
./magnolia-core-production/eu-central-1/magnolia-mgmt-ui/.terragrunt-cache/R_YCpqSiA6hzGIX2uFUxKzPvISA/ZAi6KoCBlp_GK_BvGbKEAVu77II/magnolia-mgmt-ui/.terraform.lock.hcl
./magnolia-core-production/eu-central-1/magnolia-mgmt-ui/.terraform.lock.hcl
./magnolia-core-production/.terraform.lock.hcl
./.terraform.lock.hcl

 



 Comments   
Comment by Roberto Gomez [ 27/Mar/23 ]

Trying env param TF_PLUGIN_CACHE_MAY_BREAK_DEPENDENCY_LOCK_FILE, see https://developer.hashicorp.com/terraform/cli/config/config-file#allowing-the-provider-plugin-cache-to-break-the-dependency-lock-file

Comment by Roberto Gomez [ 24/Apr/23 ]

Adding the .terraform.lock.hcl seems to have improve the situation, as we don't get the error so frequently. But, still not there, because today's renovate PR failed again.

Generated at Sun Feb 11 23:46:04 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.