Hey everyone,
I am trying to follow this tutorial to create a custom terraform module.
Everything is fine up to the point where I need to locally install & verify the provider. It fails with:
The host "example.com" given in in provider source address "example.com/vladmiller/example" does not offer a Terraform provider registry.
Note: there is a typo in the error message in in
.
I have also tried doing tutorial 1-1 using their names, but it also fails.
Wondering if anyone have any ideas how to troubleshoot. Thank you in advance.
I apologize if this has already been covered, but I could’t find more info on the forum.
From logs it’s clear that terraform is trying to get registry details by making a request to example.com.
Service discovery for example.com at https://example.com/.well-known/terraform.json
Also, not sure if this means anything here
2022-11-10T16:39:54.255+0200 [TRACE] Selected provider installation method cliconfig.ProviderInstallationDirect with includes [] and excludes []
but this makes me wonder if terraform is even seeing this module.
Below is are full logs and examples of my setup.
➜ examples git:(main) ✗ TF_LOG=trace terraform init
2022-11-10T16:39:54.255+0200 [INFO] Terraform version: 1.3.4
2022-11-10T16:39:54.255+0200 [DEBUG] using github.com/hashicorp/go-tfe v1.9.0
2022-11-10T16:39:54.255+0200 [DEBUG] using github.com/hashicorp/hcl/v2 v2.14.1
2022-11-10T16:39:54.255+0200 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2
2022-11-10T16:39:54.255+0200 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
2022-11-10T16:39:54.255+0200 [DEBUG] using github.com/zclconf/go-cty v1.12.0
2022-11-10T16:39:54.255+0200 [INFO] Go runtime version: go1.19.3
2022-11-10T16:39:54.255+0200 [INFO] CLI args: []string{"terraform", "init"}
2022-11-10T16:39:54.255+0200 [TRACE] Stdout is a terminal of width 206
2022-11-10T16:39:54.255+0200 [TRACE] Stderr is a terminal of width 206
2022-11-10T16:39:54.255+0200 [TRACE] Stdin is a terminal
2022-11-10T16:39:54.255+0200 [DEBUG] Attempting to open CLI config file: /Users/vladi/.terraformrc
2022-11-10T16:39:54.255+0200 [INFO] Loading CLI configuration from /Users/vladi/.terraformrc
2022-11-10T16:39:54.255+0200 [DEBUG] Explicit provider installation configuration is set
2022-11-10T16:39:54.255+0200 [TRACE] Selected provider installation method cliconfig.ProviderInstallationDirect with includes [] and excludes []
2022-11-10T16:39:54.255+0200 [INFO] CLI command args: []string{"init"}
Initializing the backend...
2022-11-10T16:39:54.256+0200 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2022-11-10T16:39:54.256+0200 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2022-11-10T16:39:54.256+0200 [DEBUG] New state was assigned lineage "b3cc2d29-4dd2-a955-32f4-55d7481d5445"
2022-11-10T16:39:54.256+0200 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
2022-11-10T16:39:54.256+0200 [TRACE] Meta.Backend: instantiated backend of type <nil>
2022-11-10T16:39:54.256+0200 [DEBUG] Provider example.com/vladmiller/example is overridden by dev_overrides
2022-11-10T16:39:54.256+0200 [DEBUG] Provider example.com/vladmiller/example is overridden to load from /Users/vladi/go/bin
2022-11-10T16:39:54.256+0200 [DEBUG] checking for provisioner in "."
2022-11-10T16:39:54.263+0200 [DEBUG] checking for provisioner in "/opt/homebrew/bin"
2022-11-10T16:39:54.263+0200 [TRACE] Meta.Backend: backend <nil> does not support operations, so wrapping it in a local backend
2022-11-10T16:39:54.263+0200 [TRACE] backend/local: state manager for workspace "default" will:
- read initial snapshot from terraform.tfstate
- write new snapshots to terraform.tfstate
- create any backup at terraform.tfstate.backup
2022-11-10T16:39:54.263+0200 [TRACE] statemgr.Filesystem: reading initial snapshot from terraform.tfstate
2022-11-10T16:39:54.263+0200 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay
2022-11-10T16:39:54.263+0200 [TRACE] statemgr.Filesystem: read nil snapshot
2022-11-10T16:39:54.263+0200 [DEBUG] Provider example.com/vladmiller/example is overridden by dev_overrides
Initializing provider plugins...
- Finding latest version of example.com/vladmiller/example...
2022-11-10T16:39:54.263+0200 [DEBUG] Service discovery for example.com at https://example.com/.well-known/terraform.json
2022-11-10T16:39:54.263+0200 [TRACE] HTTP client GET request to https://example.com/.well-known/terraform.json
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│ - example.com/vladmiller/example in /Users/vladi/go/bin
│
│ Skip terraform init when using provider development overrides. It is not necessary and may error unexpectedly.
╵
╷
│ Error: Invalid provider registry host
│
│ The host "example.com" given in in provider source address "example.com/vladmiller/example" does not offer a Terraform provider registry.
╵
➜ examples git:(main) ✗ terraform version
Terraform v1.3.4
on darwin_arm64
➜ examples git:(main) ✗ cat ~/.terraformrc
provider_installation {
dev_overrides {
"example.com/vladmiller/example" = "/Users/vladi/go/bin/"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
➜ examples git:(main) ✗ tree /Users/vladi/go/bin
/Users/vladi/go/bin
└── terraform-provider-example
0 directories, 1 file
➜ bin ./terraform-provider-example
This binary is a plugin. These are not meant to be executed directly.
Please execute the program that consumes these plugins, which will
load any plugins automatically
➜ terraform-provider-example git:(main) ✗ cat main.go
package main
import (
"context"
"flag"
"log"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"terraform-provider-example/example"
)
var (
// these will be set by the goreleaser configuration
// to appropriate values for the compiled binary
version string = "dev"
// goreleaser can also pass the specific commit if you want
// commit string = ""
)
func main() {
var debug bool
flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse()
err := providerserver.Serve(context.Background(), example.New(version), providerserver.ServeOpts{
Address: "example.com/vladmiller/example",
Debug: debug,
})
if err != nil {
log.Fatal(err.Error())
}
}
➜ examples git:(main) ✗ cat provider-verification.tf
terraform {
required_providers {
example = {
source = "example.com/vladmiller/example"
}
}
}
provider "example" {}
➜ terraform-provider-example git:(main) ✗ cat go.mod
module terraform-provider-example
go 1.18
require github.com/hashicorp/terraform-plugin-framework v0.15.0
require (
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
// truncated
)