Terraform init error

Linode Staff

I am trying to spin some more servers using Terraform and your plugin, following this guide, however when I issue:

terraform init

I get this error:

Error: provider.linode: multiple configurations present; only one configuration is allowed per provider

Is this caused by your plugin or am I doing something wrong here?

2 Replies

I've gone over this, read through the guide, and built a Terraform configuration to replicate the issue, and what I found is that the error you're receiving occurs when I specify Linode as the provider in more than one of my configuation files. The guide touches on this briefly in the following passage:

You may notice that the Terraform provider is not specified in this file as it was in linode-terraform-web.tf. Terraform loads into memory and concatenates all files present in the working directory which have a .tf extension. This means you don’t need to define the provider again in new .tf files.

I can't see your files, so it is hard for me to say for sure, but if more than one of your config files contains an entry like the following, you should remove it from all but one of the files:

provider "linode" {
  token = "YOUR_LINODE_API_TOKEN"
}

It is possible to use multiple provider blocks if the intent is to use resources from two different API tokens (for example two restricted users on the same account, or users on entirely different accounts).

provider "linode" {
  alias = "user_foo"
  token = "FOO_TOKEN"
}

provider "linode {
  alias = "user_bar"
  token = "BAR_TOKEN"
}

resource "linode_instance" "foonode" {
  provider = linode.user_foo
  ...
}

resource "linode_instance" "barnode" {
  provider = linode.user_bar
  ...
}

This is covered in detail in the Terraform docs:

https://www.terraform.io/docs/configuration/providers.html#alias-multiple-provider-instances

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct