I want to work with contributing to development of plugins, but I’m having issues getting anything set up. (Using terraform v0.15.1).
I’m trying to use a 3rd party provider for Humio that I’ve used before with terraform v12 with relative ease. I followed the hashicup tutorial, and I think I’ve set it all up to mirror the setup tutorial but I keep on getting this error:
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider humio/local/humio: could not connect to humio: Failed to request discovery document: Get
│ "https://humio/.well-known/terraform.json": dial tcp: lookup humio on 127.0.0.1:53: no such host
╵
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/humio: provider registry registry.terraform.io does not have a provider named
│ registry.terraform.io/hashicorp/humio
│
│ Did you intend to use humio/local/humio? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending
│ on hashicorp/humio, run the following command:
│ terraform providers
I’ve placed the executable binary "terraform-provider-humio_v0.0.1 in three paths:
.terraform.d/plugins/humio.com/local/humio/0.0.1/linux_amd64
.terraform/plugins/humio.com/local/humio/0.0.1/linux_amd64
/usr/share/terraform/providers/humio.com/local/humio/0.0.1/linux_amd64
I’ve even added a provider_installation block, but terraform seems to be ignoring it:
terraform {
required_providers {
humio {
source = "humio/local/humio"
version = "0.0.1"
}
}
} # (sorry if the syntax isn't quite right - I have this part in tf.json for jinja templating
provider "humio" {
addr = local.humio_endpoint
api_token = local.humio_token
provider_installation {
filesystem_mirror {
path = "/usr/share/terraform/providers"
include = ["humio.com"]
}
}
}
Hi @kwcrook,
It looks like you’ve placed the provider_installation
block inside your provider
block, rather than in one of the CLI configuration files. Provider installation settings are global to all Terraform configurations on your system, because we assume them to be something specific to the system you’re running Terraform on (e.g. it doesn’t have internet access) rather than something specific to the current configuration.
Since you mentioned that you intend to develop this provider, I think you’ll find it most convenient to use Development Overrides rather than filesystem mirrors. That mechanism avoids any need to install the provider at all, because it forces Terraform to ignore the results of terraform init
and just use the specific local directory you’ve configured. You can set that up by writing something like the following in your CLI configuration file (not in a .tf
file):
provider_installation {
dev_overrides {
"humio/local/humio" = "/usr/share/terraform/providers/humio/local/humio"
}
}
Because development overrides ignores the usual cache directory altogether, it expects to be given the directory containing the contents of the hypothetical provider package; that is, the directory that contains a file like terraform-provider-humio
. With the above in place you can skip running terraform init
(because we’re telling Terraform to ignore what terraform init
would’ve installed anyway) and just run terraform apply
and you should see Terraform automatically use the plugin file in that given directory as the implementation of humio/local/humio
.
If you ultimately intend to upload this provider to the Terraform Registry then you can use the name it’ll eventually have in the registry: humio/humio
instead of this placeholder local name humio/local/humio
. humio/humio
is an alias for registry.terraform.io/humio/humio
, because registry.terraform.io
is the default registry hostname. If you do that then you’ll need to match the name in your CLI configuration with the name you wrote in your required_providers
block in the configuration: they’ll both be humio/humio
. Since we don’t run terraform init
to work with dev-override providers, it doesn’t matter that there’s no such provider in the registry yet.
If you don’t intend to publish this in the public registry then I expect you’ll eventually want to make it available to real Terraform runs, without dev_overrides
. That’s the point where you can start using filesystem mirrors as you originally tried, although since the directory you chose is one of the implied default search directories on Linux systems (assuming you haven’t overridden the XDG search directory environment variables) you won’t need to configure any special provider_installation
block, and can instead just drop the contents of the provider package into the location where Terraform will search for it:
/usr/share/terraform/providers/humio/local/humio
The above directory should at least contain the terraform-provider-humio
plugin executable file in order for Terraform to be able to run it.
1 Like