LoginSignup
0
0

背景

昨日まで正常に稼働していたTerraformがあるときを境に以下のエラーが発生するようになりました。
解消方法としては知見が深まるようなものではないのですが、同じような犠牲者が増えないように残しておきます。

│ Error: Failed to load plugin schemas
│
│ Error while loading schemas for plugin components: 2 problems:
│
│ - Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/external: failed to instantiate
│ provider "registry.terraform.io/hashicorp/external" to obtain schema: Unrecognized remote plugin message:
│
│ This usually means that the plugin is either invalid or simply
│ needs to be recompiled to support the latest protocol..
│ - Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/null: failed to instantiate provider
│ "registry.terraform.io/hashicorp/null" to obtain schema: Unrecognized remote plugin message:
│
│ This usually means that the plugin is either invalid or simply
│ needs to be recompiled to support the latest protocol...

切り分けしてみたところ、lambdaのmoduleを利用している
terraformでのみ発生している様子。

他lambdaのmoduleを利用していないTerraformは正常に稼働する。

Copilotに問い合わせ

.terraform.lock.hcl.terraformディレクトリを削除してterraform initを実行してみなとあったので
実施しても変わらず。

DEBUG ログ有効

DEBUGログを有効にして確認してみる。
有効にする方法はここに書いてある通り
TF_LOG変数設定するだけですね。

  • DEBUGレベルで設定
export TF_LOG=DEBUG
  • DEBUG ログ内容
2024-06-17T10:53:15.639+0900 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/external/2.3.3/darwin_arm64/terraform-provider-external_v2.3.3_x5 args=[".terraform/providers/registry.terraform.io/hashicorp/external/2.3.3/darwin_arm64/terraform-provider-external_v2.3.3_x5"]
2024-06-17T10:53:15.641+0900 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/external/2.3.3/darwin_arm64/terraform-provider-external_v2.3.3_x5 pid=64768
2024-06-17T10:53:15.641+0900 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/external/2.3.3/darwin_arm64/terraform-provider-external_v2.3.3_x5
2024-06-17T10:53:15.641+0900 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/external/2.3.3/darwin_arm64/terraform-provider-external_v2.3.3_x5 pid=64768 error="signal: killed"
2024-06-17T10:53:15.642+0900 [DEBUG] created provider logger: level=debug
2024-06-17T10:53:15.642+0900 [INFO]  provider: configuring client automatic mTLS
2024-06-17T10:53:15.644+0900 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.5.1/darwin_arm64/terraform-provider-local_v2.5.1_x5 args=[".terraform/providers/registry.terraform.io/hashicorp/local/2.5.1/darwin_arm64/terraform-provider-local_v2.5.1_x5"]
2024-06-17T10:53:15.645+0900 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.5.1/darwin_arm64/terraform-provider-local_v2.5.1_x5 pid=64769
2024-06-17T10:53:15.645+0900 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.5.1/darwin_arm64/terraform-provider-local_v2.5.1_x5
2024-06-17T10:53:15.646+0900 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.5.1/darwin_arm64/terraform-provider-local_v2.5.1_x5 pid=64769 error="signal: killed"
2024-06-17T10:53:15.646+0900 [DEBUG] created provider logger: level=debug
2024-06-17T10:53:15.646+0900 [INFO]  provider: configuring client automatic mTLS
2024-06-17T10:53:15.648+0900 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/null/3.2.2/darwin_arm64/terraform-provider-null_v3.2.2_x5 args=[".terraform/providers/registry.terraform.io/hashicorp/null/3.2.2/darwin_arm64/terraform-provider-null_v3.2.2_x5"]
2024-06-17T10:53:15.650+0900 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/null/3.2.2/darwin_arm64/terraform-provider-null_v3.2.2_x5 pid=64770
2024-06-17T10:53:15.650+0900 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/null/3.2.2/darwin_arm64/terraform-provider-null_v3.2.2_x5
2024-06-17T10:53:15.650+0900 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/null/3.2.2/darwin_arm64/terraform-provider-null_v3.2.2_x5 pid=64770 error="signal: killed"

pluginの読み込み時に失敗しているようだ。

ググってみる

エラーメッセージで検索をかけてみたところ
以下のクラスメソッドさんの記事がヒットしました。

エラーが発生しているlocalnullなどのVersionを指定していなかったため指定してみる。

  • 結果

解消せず。

どう解決したか

プラグインのライブラリのダウンロードも正常にされているし、
これはもうlambdaの公式モジュールを捨ててスクラッチで作成するしかないかと覚悟を決め、
ダメ元でmacを再起動かけてみたところ 解消 しました!

おそらくmacbookで色々プロセスを起動していた兼ね合いで
メモリが足りない状態になっていたのが原因と考えています。

そもそもローカルで実行するなという話題ではあるのですが、
ローカルterraform実行で何かしら挙動がおかしいことが起きた場合は
一度macbookの状態を疑ってみるのもいいかもしれません。

0
0
0

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