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?

More than 3 years have passed since last update.

[terraform]Error: Failed to query available provider packages の解決例

Posted at

 出現したエラー文

% terraform init                  

Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- terraform.io/builtin/terraform is built in to Terraform
- Finding latest version of hashicorp/teraform...
- Finding hashicorp/aws versions matching "3.42.0"...
- Installing hashicorp/aws v3.42.0...
- Installed hashicorp/aws v3.42.0 (signed by HashiCorp)
╷
│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/teraform: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/teraform
│ 
│ All modules should specify their required_providers so that external consumers will get the correct providers when using a module. To see which modules are currently depending on hashicorp/teraform, run the following command:
│     terraform providers
╵

原因

エラー文を見るとproviderの指定が間違っているように見えるが、実際はdata.tfの中身のタイプミスによるエラーだった。

data.tf
# ↓この行をミスしていた。正しくは"terraform_remote_state"だった。
data "teraform_remote_state" "network_main" { 
  backend = "s3"

  config = {
    buket  = "social-game-tfstate"
    key    = "${local.system_name}/${local.env_name}/network/main=v1.0.0.tfstate"
    region = "ap-northeast-1"
  }
}

解決方法

terraformのファイル(.tfファイル)のミスを修正し、再度terraform initを実行する。

調査で見つけた今回以外の例

バージョンアップに伴う題名のエラーの場合は下記の方法で直ることがあるようです。
https://discuss.hashicorp.com/t/terraform-0-13-terraform-init-fails-because-of-provider-required-by-state/13132

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?