Terraform cannot detect a supported external module source type

Hello,

From one day to the next, I encounter the following problem on my modules :

│ Error: Invalid module source address
│ 
│ Module "node-termination-handler" (declared at main.tf line 287) has invalid source address "x/x/aws-modules/node-termination-handler": Terraform cannot detect a
│ supported external module source type for x/x/aws-modules/node-termination-handler.

main.tf :

module "node-termination-handler" {
  source = "x/x/aws-modules/node-termination-handler"
  version = "0.1.3"
  [...] 

}

I’m using terraform registry of gitlab, my personnal token is good.

My version is well present in the registry.

My terraformrc file content my credential.

However, if I use the git reference like this :

git::https://x/terraform/aws-modules/node-termination-handler?ref=0.1.3

It works

Terraform version : v1.1.7

OS : MacOS

Hello,

The problem is always present and it is quite painful

Hi @quentin,

Is your module registry host literally “x” here, or did you just mask the real hostname for sharing in the forum?

Terraform expects to find a fully-qualified hostname in that position, and so if you are literally writing x then it may help to add to the end whatever domain this x belongs to, like x.example.com.

Hello,

Yes, I put X’s to hide the information.

To give a more concrete example, here is a module I use:

module "cluster-autoscaler" {
  source = "gitlab.example.fr/toto/aws-modules/cluster-autoscaler"
  version = "x.x.x"

  enabled = true
  region = var.region
  client_slug = var.client_slug
  project_name = var.project_name
 [...]
  tags = var.tags
}

Hello,

This appears to be the same question I replied to in an issue here. Does creating a module without the - characters in the final segment avoid the issue?

Ahh yes… in a later version of Terraform we’ve added a more specific error message for this situation, but older versions had only this generic error message for any failure to parse a registry module address.

Hello,

I have the latest version of terraform available.

However, I find it strange that terraform is not able to handle the - in names in a registry

Hi @quentin,

This constraint arises from the fact that the “target system” portion of the module address syntax – the last part – is conventionally the local name of a provider, and local names of providers can also not contain any dashes or underscores.

Looking back at your original question it looks like you are using the module registry hierarchy a little differently in your registry: you have the “name” portion set to aws-modules and the “system” portion set to “note-termination-handler”.

The intention of this naming scheme would be for you to name this module something like gitlab.example.fr/toto/cluster-autoscaler/aws, where that last part represents that this is a module intended for use with AWS which primarily (but not exclusively) uses the hashicorp/aws provider.

Although if you are exclusively using AWS this design won’t be of much benefit to you yet, the intent here is that if you are using modules to provide similar abstractions over multiple target systems then you might also have e.g. gitlab.example.fr/toto/cluster-autoscaler/azure for an Azure implementation of the same idea.

(I don’t know if it really makes sense to define a “cluster autoscaler” in Azure in particular, but this can be useful for provider-agnostic abstractions like e.g. a module representing a kubernetes cluster where the details of how to set one up vary by vendor but once set up the cluster itself behaves in a mostly-consistent way across vendors.)