Hi! I’m trying to use the plugin framework / template as described in the docs to start development work on a new Terraform provider. The code I’ve put together so far is available at GitHub - strickvl/terraform-provider-huggingface-spaces: A Terraform/OpenTofu provider for deploying Hugging Face Spaces, but the main things I’ve amended are the main.go
file and the provider.go
file.
I’m developing on a Mac, and my .terraformrc
file looks like this:
provider_installation {
dev_overrides {
"strickvl/huggingface-spaces" = "/Users/strickvl/go/bin/"
}
direct {}
}
And I’ve set up a test HCL file to try this out on which contains:
terraform {
required_providers {
huggingface-spaces = {
source = "strickvl/huggingface-spaces"
}
}
}
provider "huggingface-spaces" {
token = var.huggingface_token
}
variable "huggingface_token" {
type = string
description = "The Hugging Face API token."
sensitive = true
}
Now when I run terraform init, I get the following:
terraform init
2024-03-30T19:37:41.308+0100 [INFO] Terraform version: 1.5.7
2024-03-30T19:37:41.308+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.26.0
2024-03-30T19:37:41.308+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.16.2
2024-03-30T19:37:41.308+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.0
2024-03-30T19:37:41.308+0100 [DEBUG] using github.com/zclconf/go-cty v1.12.2
2024-03-30T19:37:41.308+0100 [INFO] Go runtime version: go1.21.1
2024-03-30T19:37:41.308+0100 [INFO] CLI args: []string{"terraform", "init"}
2024-03-30T19:37:41.308+0100 [DEBUG] Attempting to open CLI config file: /Users/strickvl/.terraformrc
2024-03-30T19:37:41.308+0100 [INFO] Loading CLI configuration from /Users/strickvl/.terraformrc
2024-03-30T19:37:41.308+0100 [INFO] Loading CLI configuration from /Users/strickvl/.terraform.d/credentials.tfrc.json
2024-03-30T19:37:41.309+0100 [DEBUG] checking for credentials in "/Users/strickvl/.terraform.d/plugins"
2024-03-30T19:37:41.309+0100 [DEBUG] checking for credentials in "/Users/strickvl/.terraform.d/plugins/darwin_amd64"
2024-03-30T19:37:41.309+0100 [DEBUG] Explicit provider installation configuration is set
2024-03-30T19:37:41.309+0100 [INFO] CLI command args: []string{"init"}
Initializing the backend...
2024-03-30T19:37:41.310+0100 [DEBUG] New state was assigned lineage "************************************"
2024-03-30T19:37:41.310+0100 [DEBUG] Provider registry.terraform.io/strickvl/huggingface-spaces is overridden by dev_overrides
2024-03-30T19:37:41.310+0100 [DEBUG] Provider registry.terraform.io/strickvl/huggingface-spaces is overridden to load from /Users/strickvl/go/bin
2024-03-30T19:37:41.310+0100 [DEBUG] checking for provisioner in "."
2024-03-30T19:37:41.321+0100 [DEBUG] checking for provisioner in "/usr/local/bin"
2024-03-30T19:37:41.321+0100 [DEBUG] checking for provisioner in "/Users/strickvl/.terraform.d/plugins"
2024-03-30T19:37:41.322+0100 [DEBUG] checking for provisioner in "/Users/strickvl/.terraform.d/plugins/darwin_amd64"
2024-03-30T19:37:41.322+0100 [DEBUG] Provider registry.terraform.io/strickvl/huggingface-spaces is overridden by dev_overrides
Initializing provider plugins...
- Finding latest version of strickvl/huggingface-spaces...
2024-03-30T19:37:41.322+0100 [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
2024-03-30T19:37:41.901+0100 [DEBUG] GET https://registry.terraform.io/v1/providers/strickvl/huggingface-spaces/versions
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│ - strickvl/huggingface-spaces in /Users/strickvl/go/bin
│
│ Skip terraform init when using provider development overrides. It is not necessary and may error unexpectedly.
╵
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider strickvl/huggingface-spaces: provider registry
│ registry.terraform.io does not have a provider named registry.terraform.io/strickvl/huggingface-spaces
│
│ 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 strickvl/huggingface-spaces, run the
│ following command:
│ terraform providers
╵
So clearly it appears to be still trying to query the registry. Running terraform providers
gives me:
terraform providers
2024-03-30T19:49:21.795+0100 [INFO] Terraform version: 1.5.7
2024-03-30T19:49:21.795+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.26.0
2024-03-30T19:49:21.795+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.16.2
2024-03-30T19:49:21.795+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.0
2024-03-30T19:49:21.795+0100 [DEBUG] using github.com/zclconf/go-cty v1.12.2
2024-03-30T19:49:21.795+0100 [INFO] Go runtime version: go1.21.1
2024-03-30T19:49:21.795+0100 [INFO] CLI args: []string{"terraform", "providers"}
2024-03-30T19:49:21.795+0100 [DEBUG] Attempting to open CLI config file: /Users/strickvl/.terraformrc
2024-03-30T19:49:21.795+0100 [INFO] Loading CLI configuration from /Users/strickvl/.terraformrc
2024-03-30T19:49:21.796+0100 [INFO] Loading CLI configuration from /Users/strickvl/.terraform.d/credentials.tfrc.json
2024-03-30T19:49:21.797+0100 [DEBUG] checking for credentials in "/Users/strickvl/.terraform.d/plugins"
2024-03-30T19:49:21.798+0100 [DEBUG] checking for credentials in "/Users/strickvl/.terraform.d/plugins/darwin_amd64"
2024-03-30T19:49:21.798+0100 [DEBUG] Explicit provider installation configuration is set
2024-03-30T19:49:21.798+0100 [INFO] CLI command args: []string{"providers"}
2024-03-30T19:49:21.799+0100 [DEBUG] New state was assigned lineage "************************************"
2024-03-30T19:49:21.799+0100 [DEBUG] Provider registry.terraform.io/strickvl/huggingface-spaces is overridden by dev_overrides
2024-03-30T19:49:21.799+0100 [DEBUG] Provider registry.terraform.io/strickvl/huggingface-spaces is overridden to load from /Users/strickvl/go/bin
2024-03-30T19:49:21.800+0100 [DEBUG] checking for provisioner in "."
2024-03-30T19:49:21.979+0100 [DEBUG] checking for provisioner in "/usr/local/bin"
2024-03-30T19:49:21.979+0100 [DEBUG] checking for provisioner in "/Users/strickvl/.terraform.d/plugins"
2024-03-30T19:49:21.979+0100 [DEBUG] checking for provisioner in "/Users/strickvl/.terraform.d/plugins/darwin_amd64"
Providers required by configuration:
.
└── provider[registry.terraform.io/strickvl/huggingface-spaces]
When I look into /Users/strickvl/Go/bin/
, there is indeed a binary file called: terraform-provider-huggingface-spaces
which I built from the main repo linked above.
I’m a bit unsure how to proceed here. The docs don’t really go into detail how this works and this is my first time creating a provider, so I’d appreciate if someone could explain how I can get this override set up.