hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io
Other
43.16k stars 9.58k forks source link

Failing to verify provider checksum when .terraform directory uses a Windows Junctions to be located elsewhere after upgrading to 1.10 #36144

Open tylerohlsen opened 1 day ago

tylerohlsen commented 1 day ago

Terraform Version

Terraform v1.10.0
on windows_amd64
+ provider registry.terraform.io/hashicorp/azurerm v4.9.0

Terraform Configuration Files

terraform {
  backend "azurerm" {
  }
}

Debug Output

2024-12-02T09:57:51.259-0600 [INFO]  Terraform version: 1.10.0
2024-12-02T09:57:51.260-0600 [DEBUG] using github.com/hashicorp/go-tfe v1.70.0
2024-12-02T09:57:51.260-0600 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.0
2024-12-02T09:57:51.260-0600 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-12-02T09:57:51.260-0600 [DEBUG] using github.com/zclconf/go-cty v1.15.1-0.20241111215639-63279be090d7
2024-12-02T09:57:51.260-0600 [INFO]  Go runtime version: go1.23.3
2024-12-02T09:57:51.260-0600 [INFO]  CLI args: []string{"C:\\ProgramData\\chocolatey\\lib\\terraform\\tools\\terraform.exe", "plan"}
2024-12-02T09:57:51.261-0600 [TRACE] Stdout is a terminal of width 228
2024-12-02T09:57:51.261-0600 [TRACE] Stderr is a terminal of width 228
2024-12-02T09:57:51.261-0600 [TRACE] Stdin is a terminal
2024-12-02T09:57:51.264-0600 [DEBUG] Attempting to open CLI config file: C:\Users\MyUser\AppData\Roaming\terraform.rc
2024-12-02T09:57:51.265-0600 [INFO]  Loading CLI configuration from C:\Users\MyUser\AppData\Roaming\terraform.rc
2024-12-02T09:57:51.265-0600 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-12-02T09:57:51.265-0600 [DEBUG] ignoring non-existing provider search directory C:\Users\MyUser\AppData\Roaming\terraform.d\plugins
2024-12-02T09:57:51.266-0600 [DEBUG] ignoring non-existing provider search directory C:\Users\MyUser\AppData\Roaming\HashiCorp\Terraform\plugins
2024-12-02T09:57:51.266-0600 [INFO]  CLI command args: []string{"plan"}
2024-12-02T09:57:51.284-0600 [TRACE] Meta.Backend: built configuration for "azurerm" backend with hash value 3842662675
2024-12-02T09:57:51.284-0600 [TRACE] Meta.Backend: working directory was previously initialized for "azurerm" backend
2024-12-02T09:57:51.284-0600 [TRACE] Meta.Backend: using already-initialized, unchanged "azurerm" backend configuration
2024-12-02T09:57:51.285-0600 [INFO]  Testing if Service Principal / Client Certificate is applicable for Authentication..
2024-12-02T09:57:51.285-0600 [INFO]  Testing if Multi Tenant Service Principal / Client Secret is applicable for Authentication..
2024-12-02T09:57:51.285-0600 [INFO]  Testing if Service Principal / Client Secret is applicable for Authentication..
2024-12-02T09:57:51.285-0600 [INFO]  Testing if OIDC is applicable for Authentication..
2024-12-02T09:57:51.285-0600 [INFO]  Testing if Managed Service Identity is applicable for Authentication..
2024-12-02T09:57:51.285-0600 [INFO]  Testing if Obtaining a Multi-tenant token from the Azure CLI is applicable for Authentication..
2024-12-02T09:57:51.285-0600 [INFO]  Testing if Obtaining a token from the Azure CLI is applicable for Authentication..
2024-12-02T09:57:51.285-0600 [INFO]  Using Obtaining a token from the Azure CLI for Authentication
2024-12-02T09:57:53.135-0600 [INFO]  Getting OAuth config for endpoint https://login.microsoftonline.com/ with  tenant 3b44e60f-4990-4d4d-9d3b-d38b985be214
2024-12-02T09:57:53.135-0600 [DEBUG] Obtaining an MSAL / Microsoft Graph token for Resource Manager..
2024-12-02T09:57:54.422-0600 [TRACE] Meta.Backend: instantiated backend of type *azure.Backend
2024-12-02T09:57:54.425-0600 [TRACE] providercache.fillMetaCache: scanning directory .terraform\providers
2024-12-02T09:57:54.425-0600 [TRACE] getproviders.SearchLocalDirectory: failed to resolve symlinks for .terraform\providers: The system cannot find the path specified.
2024-12-02T09:57:54.430-0600 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/azurerm v4.9.0 for windows_amd64 at .terraform\providers\registry.terraform.io\hashicorp\azurerm\4.9.0\windows_amd64  
2024-12-02T09:57:54.438-0600 [TRACE] providercache.fillMetaCache: including .terraform\providers\registry.terraform.io\hashicorp\azurerm\4.9.0\windows_amd64 as a candidate package for registry.terraform.io/hashicorp/azurerm 4.9.0
2024-12-02T09:57:54.438-0600 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform\providers
2024-12-02T09:57:54.439-0600 [DEBUG] checking for provisioner in "."
2024-12-02T09:57:54.439-0600 [DEBUG] checking for provisioner in "C:\\ProgramData\\chocolatey\\lib\\terraform\\tools"
╷
│ 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/azurerm: failed to verify checksum of registry.terraform.io/hashicorp/azurerm 4.9.0 package cached in in .terraform\providers: The system cannot find the path specified.
│
│ Terraform uses external plugins to integrate with a variety of different infrastructure services. To download the plugins required for this configuration, run:
│   terraform init

Expected Behavior

Just as 1.9.8 and prior releases worked, allow for the .terraform directory to be redirected with a Windows Junction to another location.

Actual Behavior

Provider checksum fails

Steps to Reproduce

  1. Create a Windows Junction to create a local .terraform directory that points to a different location
  2. terraform init
  3. terraform plan

Additional Context

In a multi-environment configuration, I use Windows Junctions to redirect the .terraform directory to an environment specific location (e.g. environments\dev.terraform). And then switching environments need to just change the junction. This setup works with version 1.9.8 and prior releases.

To create a Junction in Windows:

New-Item -ItemType "Junction" -Name '.terraform' -Value 'environments\dev\.terraform'

References

No response

crw commented 1 day ago

Thanks for this report!