Skip to content

Terragrunt (Cache server) fails when absolute URLs used in registry's self-discovery (modules.v1) #5156

@t3hG04T

Description

@t3hG04T

Describe the bug

When using Cache Server and trying to pull a sub-module from a Terraform registry that uses absolute URLs in it's self discovery the module will fail to retrieve with a message:

  │ Error: Error accessing remote module registry
  │ 
  │   on my-module.tf line 1:
  │    1: module "my-module" {
  │ 
  │ Failed to retrieve available versions for module "my-module"
  │ (my-module.tf:1) from private.registry.url: the request failed after
  │ 2 attempts, please try again later: Get
  │ "https://<hostname><absolute-url>/registry/my-module/aws/versions":
  │ dial tcp: lookup <hostname>https on <IP>:<PORT>: no such
  │ host.

Steps To Reproduce

  1. Use a registry that uses absolute paths in it's self-discovery, e.g.:
$ curl https://packages.syncron.team/.well-known/terraform.json
{
  "modules.v1" : "https://<hostname>/somepath/modules/",
}
  1. Pull the module within a .tf file:
module "my-module" {
  source = "<hostname>/registry/my-module/aws"
  version = "= 1.0.0"
}
  1. Try to run terragrunt plan
  2. Observe the error

Expected behavior

Terragrunt pulls the module

Versions

  • Terragrunt version: 0.93.11
  • OpenTofu/Terraform version: 1.8.5
  • Environment details (Ubuntu 20.04, Windows 10, etc.): Ubuntu 24.04

Additional information

I've traced the root of the problem to https://github.com/gruntwork-io/terragrunt/blob/main/internal/providercache/provider_cache.go#L322

It seems that the Cache Server is naively assuming relative URLs without double checking (and DiscoveryURL is also just a container for the contents present in the file).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions