Using a registry module results in `cannot detect a supported external module source` errors

Hi Folks! I feel like this is a really basic question, but I’m not seeing a clear answer for it.

I’m trying to use Terraform Registry and it shows a very simple set of instructions, but I can’t get it to work. I have:

terraform {
  required_providers {
    google = {
      source = "hashicorp/google"
    }
  }
}

provider "google" {
}

module "mig" {
  source            = "terraform-google-modules/vm/google/modules/mig"
  version           = "7.7.0"
  project_id        = "test-project-123"
  region            = "us-central1-a"
  target_size       = 1
  hostname          = "testmig"
}

But I keep getting this error Terraform cannot detect a supported external module source type

$ terraform version
Terraform v1.1.9
on darwin_arm64

$ terraform init
Initializing modules...

│ Error: Invalid module source address
│ 
│ Module "mig" (declared at main.tf line 12) has invalid source address
│ "terraform-google-modules/vm/google/modules/mig": Terraform cannot detect a supported external module
│ source type for terraform-google-modules/vm/google/modules/mig.

The string you have used here:

is incorrect.

This part of the documentation should help: Module Sources | Terraform | HashiCorp Developer

I can’t tell what the module source docs are suggesting I use. They say:

Modules on the public Terraform Registry can be referenced using a registry source address of the form <NAMESPACE>/<NAME>/<PROVIDER> , with each module’s information page on the registry site including the exact address to use.

And that string is exactly what the registry page suggests I use.

Screen Shot 2022-05-06 at 17.03.48

Could you be more specific?

(edit: I posted the wrong screenshot)

Oh… I see… my guess is the problem is the special double-slash syntax described at Module Sources | Terraform by HashiCorp which unfortunately the registry web page seems to be missing :slightly_frowning_face:

1 Like

Oh that’s perfect! That’s just the hint I need. The correct syntax is
terraform-google-modules/vm/google//modules/mig

It looks like there’s probably awkward syntax using GitHub URLS, but that runs into weird auth requirements.

I’m going to see if I can figure out how to file this bug somewhere

Filed this as #31017.