我在詹基斯的工作中遇到了这个问题:
+ terraform --version
Terraform v0.15.5
+ rm -rf .terraform/
+ rm -f .terraform.lock.hcl
+ terraform init -upgrade -reconfigure
Upgrading modules...
...
Initializing the backend...
Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.
Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 3.0"...
- Using hashicorp/aws v3.75.2 from the shared cache directory
...
Terraform has been successfully initialized!
...
+ terraform plan -var-file qa-up.tfvars -out=tfplan
╷
│ Error: Could not load plugin
│
│
│ Plugin reinitialization required. Please run "terraform init".
│
│ Plugins are external binaries that Terraform uses to access and manipulate
│ resources. The configuration provided requires plugins which can't be
│ located,
│ don't satisfy the version constraints, or are otherwise incompatible.
│
│ Terraform automatically discovers provider requirements from your
│ configuration, including providers used in child modules. To see the
│ requirements and constraints, run "terraform providers".
│
│ failed to instantiate provider "registry.terraform.io/hashicorp/aws" to
│ obtain schema: the cached package for registry.terraform.io/hashicorp/aws
│ 3.75.2 (in .terraform/providers) does not match any of the checksums
│ recorded in the dependency lock file
script returned exit code 1提供者(当地):
$ terraform providers
Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/aws]
└── module.elasticache
└── provider[registry.terraform.io/hashicorp/aws] ~> 3.0
Providers required by state:
provider[registry.terraform.io/hashicorp/aws]但是,一旦在本地运行(假设terraform版本也是0.15.5),就没有这样的问题了。它的原因是什么以及如何解决它?
发布于 2022-11-02 11:28:10
当使用多个CPU架构时,往往会出现此问题。terraform init命令将下载底层CPU体系结构的提供程序二进制文件,并创建相应的.terraform.lock.hcl文件。为了使它在混合环境中工作,可以使用一个命令来避免问题1。
terraform providers lock \
-platform=windows_amd64 \ # 64-bit Windows
-platform=darwin_amd64 \ # 64-bit macOS
-platform=linux_amd64 # 64-bit Linux对于M1 MacOS来说,这将是-platform=darwin_arm64。由于似乎涉及到某种类型的缓存,因此删除旧的锁文件并使用新的锁文件会有所帮助。
https://stackoverflow.com/questions/74286434
复制相似问题