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でNew Relicプロバイダを指定しても正しいレジストリを読み込んでくれない

Posted at

エラー内容

╷
│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/newrelic: provider registry registry.terraform.io does not have a provider named
│ registry.terraform.io/hashicorp/newrelic
│ 
│ Did you intend to use newrelic/newrelic? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on
│ hashicorp/newrelic, run the following command:
│     terraform providers
╵

原因

required_providersを省略した場合、registry.terraform.io/hashicorp/を参照するそうです。
そのため、New Relicのプロバイダーとしてnewrelic/newrelicを使いたくても正しく指定されていない場合はhashicorp/newrelicが使われます。

以下のようなディレクトリ構造でmain.tfrequired_providersが指定されていれもmain.tfから読み込まれているexample.tfには影響が与えられません。

.
├── environment
│     └── dev
│          └── main.tf : ../../modules/example.tfを読み込んでいる。
└── modules
     └── example.tf

対応

modules ディレクトリに required_providersを記述したファイルを配置する。
example.tf にrequired_providersを追記しても構わない。

terraform {
  required_providers {
    newrelic = {
      source = "newrelic/newrelic"
    }
  }
}
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?