0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Terraform]Failed to load plugin schemas対応

Posted at

概要

Terraformでplanを実行したときに以下エラーが発生しました。

│ Error: Backend configuration changed
│ 
│ A change in the backend configuration has been detected, which may require migrating existing state.
│ 
│ If you wish to attempt automatic migration of the state, use "terraform init -migrate-state".
│ If you wish to store the current configuration with no changes to the state, use "terraform init -reconfigure".

エラーメッセージにあるとおりreconfigureすればいいのかなと思いreconfigureを実行

terraform -chdir=environments/staging init -reconfigure
Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.
Initializing modules...
Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
- Installing hashicorp/aws v5.82.2...
- Installed hashicorp/aws v5.82.2 (signed by HashiCorp)
Terraform has made some changes to the provider dependency selections recorded
in the .terraform.lock.hcl file. Review those changes and commit them to your
version control system if they represent changes you intended to make.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

再度planを実行したところ別のエラーになりました。

  • エラー内容
│ Error: Failed to load plugin schemas
│ 
│ Error while loading schemas for plugin components: Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/aws: failed to instantiate provider "registry.terraform.io/hashicorp/aws" to obtain schema:
│ Unrecognized remote plugin message: 
│ Failed to read any lines from plugin's stdout
│ This usually means
│   the plugin was not compiled for this architecture,
│   the plugin is missing dynamic-link libraries necessary to run,
│   the plugin is not executable by this process due to file permissions, or
│   the plugin failed to negotiate the initial go-plugin protocol handshake
│ 
│ Additional notes about plugin:
│   Path: .terraform/providers/registry.terraform.io/hashicorp/aws/5.82.2/darwin_arm64/terraform-provider-aws_v5.82.2_x5
│   Mode: -rwxr-xr-x
│   Owner: 501 [username] (current: 501 [username])
│   Group: 20 [staff] (current: 20 [staff])
│   MachO architecture: CpuArm64 (current architecture: arm64)

原因

わからない。。
terrafrom.lock.hclで指定されているバージョンを変更しても
状況変わらずでした。

対処方法

これで合っているかわからないですが、
~/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws配下にある
該当のバージョンを削除し再度initすると成功するようになりました。

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?