-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
terraform init and lock file platform #28041
Comments
Originally posted by @apparentlymart in #27241 (comment) @apparentlymart this is not what I observe (unless I misunderstand/misinterpret what you said).
|
The "shared cache" mentioned in this error message is the "read-through cache" I was talking about in my comment there, so I guess you have that enabled and thus what I wrote in that comment doesn't apply. That's a situation where currently we typically need to run |
We're also hitting this issue after upgrading to terraform 0.14 -- any time we update providers, we have to make sure to re-run It would be great if terraform automatically populated checksums for all available platforms with the "read-through cache" (or would that mean having to download the provider for all platforms too?). Option A from the original post would be fine too, or option B as long as it remembers the platforms that were initially selected and populates them automatically when updating a provider version. |
Yeah I just confirmed what @apparentlymart said in #27241 (comment) is not true... Here's what I did. I started with a simple resource "null_resource" "test" {} I have my local laptop and a linux container both having 0.14.0 installed.
TL;DR: So there's at least two layers to this issue. To further add context... both # This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/null" {
version = "3.1.0"
hashes = [
"h1:xhbHC6in3nQryvTQBWKxebi3inG5OCgHgc4fRxL0ymc=",
"zh:02a1675fd8de126a00460942aaae242e65ca3380b5bb192e8773ef3da9073fd2",
"zh:53e30545ff8926a8e30ad30648991ca8b93b6fa496272cd23b26763c8ee84515",
"zh:5f9200bf708913621d0f6514179d89700e9aa3097c77dac730e8ba6e5901d521",
"zh:9ebf4d9704faba06b3ec7242c773c0fbfe12d62db7d00356d4f55385fc69bfb2",
"zh:a6576c81adc70326e4e1c999c04ad9ca37113a6e925aefab4765e5a5198efa7e",
"zh:a8a42d13346347aff6c63a37cda9b2c6aa5cc384a55b2fe6d6adfa390e609c53",
"zh:c797744d08a5307d50210e0454f91ca4d1c7621c68740441cf4579390452321d",
"zh:cecb6a304046df34c11229f20a80b24b1603960b794d68361a67c5efe58e62b8",
"zh:e1371aa1e502000d9974cfaff5be4cfa02f47b17400005a16f14d2ef30dc2a70",
"zh:fc39cc1fe71234a0b0369d5c5c7f876c71b956d23d7d6f518289737a001ba69b",
"zh:fea4227271ebf7d9e2b61b89ce2328c7262acd9fd190e1fd6d15a591abfa848e",
]
} Note there's only one |
Further down - this actually also defeats the whole purpose of the lock. Even if I am not using cache - I am thinking all is fine and I am secured but in fact my TF in CI every time getting hash from remote and I don't even know about that. Meaning if remote is compromised - the lock file would not protect me even though I though it would. Now this smells like a security issue... I'm gonna ping [email protected] |
Exactly. Thanks @dee-kryvenko for this comprehensive list of actions to show this issue. It is really annoying especially for collegues who use terraform only. Right now our solution is to "whover wants to run |
This seems like a pretty big issue. Is there a timeline or ETA on a resolution? |
Yeah. Meantime I haven't heard back from [email protected] even though the auto reply said they ought to get back to me within 72 hours. Doesn't seem like they think it's a big deal. |
Any updates on this? |
This really kills the usage if a user (like me) has several Terraform configurations, and after any provider update any configuration after the first one fails on
|
To be exhaustive and for the sake of clarity, this issue affects the current version which is |
Facing the same issue, would be really helpful to either populate all hashes for all platforms by default or have a target platform configuration in the code somewhere so we can define on which platforms we are running. |
This just doesn't seem to be true, regardless of whether I'm on darwin_amd64. I don't have After I run |
If you are seeing The current design intent is that if you have no Let's keep this issue about the unfortunate interactions between the lock file and the alternate (non-default) installation options, because fixing a bug in the implementation of the current design is something different (and hopefully much less involved) than improving the design to better support the non-default installation configurations. |
without diving too deep in the thread, is there a recommended workaround? |
Possible Workaround is to generate a lock for all platforms
Update |
The proposed workaround in the previous comment does not work for me. Here's my repro sample. Having checksums for This workaround of disabling Also, I pulled the above-linked repro sample on a Linux amd64 platform, where no terraform providers lock -platform=darwin_amd64 -platform=darwin_arm64 -platform=linux_amd64
- Fetching hashicorp/aws 4.22.0 for darwin_amd64...
- Obtained hashicorp/aws checksums for darwin_amd64 (signed by HashiCorp)
- Fetching hashicorp/tls 3.4.0 for darwin_amd64...
- Fetching hashicorp/kubernetes 2.12.1 for darwin_amd64...
- Obtained hashicorp/kubernetes checksums for darwin_amd64 (signed by HashiCorp)
- Fetching hashicorp/cloudinit 2.2.0 for darwin_amd64...
╷
│ Error: Could not retrieve providers for locking
│
│ Terraform failed to fetch the requested providers for darwin_amd64 in order to calculate their checksums: some providers could not be installed:
│ - registry.terraform.io/hashicorp/cloudinit: the current package for registry.terraform.io/hashicorp/cloudinit 2.2.0 doesn't match any of the checksums previously recorded in the dependency lock
│ file
│ - registry.terraform.io/hashicorp/tls: the current package for registry.terraform.io/hashicorp/tls 3.4.0 doesn't match any of the checksums previously recorded in the dependency lock file. Linux env:
|
I hate to post a "me too" comment, but having lost the better part of the day to this issue I feel like I have to. From what I can see, there appears to be literally no way to generate lock files that are compatible with other platforms while retaining the advantages of the plugin cache: namely, to avoid having many copies of each provider and having to download them frequently. Additionally, it is not at all obvious from the error messages that the use of the plugin cache is what breaks |
We've made a change in the The previous workaround was to run In Terraform v1.4 something similar to this behavior will now happen automatically: when populating the lock file entry for the first time, This should therefore avoid the problem where running This new behavior is available for testing in Terraform v1.4.0-alpha20221109. We don't recommend using alpha releases in production, but since this behavior only affects
If you try this and have feedback, please let us know by opening a new GitHub issue in this repository. We'd prefer to have a separate issue for each area of feedback because GitHub issues are not suitable for many concurrent discussions in the same issue. Thanks! |
Current Terraform Version
Terraform Version
Use-cases
Since terraform v0.14,
terraform init
will generate a lock file which will only contain details about providers for the current platform.This means that, when running the same code from multiple platform, the
terraform init
command needs to be followed byterraform.sh providers lock -platform=linux_amd64 -platform=darwin_amd64
If not, when running on a different platform the following error will appear:
Proposal
Option A: Declare desired platforms in terraform code, and have init respect it
It would be nice if the code was to dictate which platform are expected to be initialised, so that the
terraform init
command would make sure all platform downloads are satisfied.Option B: Add
-platform=
flags toterraform init
Make
terraform init
recognise the platform flags, removing the need to runterraform.sh providers lock
The text was updated successfully, but these errors were encountered: