terraform-provider-scaffolding
terraform-provider-scaffolding copied to clipboard
Developing the Provider
Hey, I cannot find any information about actually using this provider in my configuration files. For ex. after building the binary what should I do now to use that provider in my terraform config without actually publishing it into registry?
https://github.com/hashicorp/terraform/issues/25906 https://github.com/hashicorp/terraform/issues/26123 https://discuss.hashicorp.com/t/easiest-way-to-use-a-local-custom-provider-with-terraform-0-13/12691
Place in your .terraformrc file this config:
provider_installation {
filesystem_mirror {
path = "/usr/share/.terraform.d/providers"
include = ["terraform.local/*/*"]
}
direct {
exclude = ["terraform.local/*/*"]
}
}
Place your binary (depending on your OS and ARCH) in /usr/share/.terraform.d/providers/terraform.local/local/myplugin/1.0.0/windows_amd64/terraform-provider-myplugin_v1.0.0.exe
Use in terraform config:
terraform {
required_providers {
myplugin= {
source = "terraform.local/local/myplugin"
version = "~> 1.0.0"
}
}
}
Keep in mind you may encounter unknown errors while using a module that points to provider with the same name but different binary (even if they're exactly same binaries even with matching checksum/hash).
Thanks @bukowa ! That's just the info I was looking for.
Would be super useful to get that added to the bottom of the README if you're up for PR-ing it :) https://github.com/hashicorp/terraform-provider-scaffolding/blob/main/README.md
(I'm part of Hashi, but this ain't my team)
Hey there's also nice Makefile example that worked out of the box for me while using Linux (my question was asked while i were working on windows):
https://github.com/kreuzwerker/terraform-provider-docker/blob/bdaec499d829c7b7d351109191e04767b123c570/GNUmakefile#L23
Hi folks 👋
In addition to manually copying the provider binary for local installation into a conventional directory, you can also use the dev_overrides provider installation configuration. This allows you to build and put the binary in any directory, such as GOBIN if you would like to just run go install in your provider codebase.
Additional references:
- https://www.terraform.io/plugin/debugging#terraform-cli-development-overrides
- https://learn.hashicorp.com/tutorials/terraform/providers-plugin-framework-provider?in=terraform/providers-plugin-framework#prepare-terraform-for-local-provider-install (this is part of the new terraform-plugin-framework based Learn collection, however it is also applicable to terraform-plugin-sdk based providers as well)
I was looking at dev_overrides a while ago, but wasn't sure quite how it works.
If I'm understanding your comment, and that second link, then it's as simple as...
provider_installation {
dev_overrides {
"local/foo" = "<insert ${GOBIN} here>"
}
}
Nice! That makes things MUCH easier :D
(I'd seen https://www.terraform.io/plugin/debugging, but I'd not seen the https://learn.hashicorp.com link before. That's super helpful)
So then, I think it makes sense for us to reference that page in this repo's README file