gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.03k stars 973 forks source link

TFR protocol with private gitlab registry - misleading error when missing auth #2899

Closed smills24 closed 1 month ago

smills24 commented 9 months ago

Took a lot of frustration/trial and error to finally figure out this was actually related to auth so wanted to document it somewhere. I couldn't find much in the official docs about how to use this functionality.

To Reproduce

terraform {
    source = "tfr://gitlab.com/<GITLAB GROUP>/<MODULE NAME>/<MODULE_SYSTEM>?version=<VERSION>"
}

Init/plan/apply:

terragrunt plan --terragrunt-working-dir <DIR>

As expected, this fails. But it fails like this:

ERRO[0000] 1 error occurred:
        * error downloading 'tfr://gitlab.com/<GITLAB GROUP>/<MODULE NAME>/<MODULE_SYSTEM>?version=<VERSION>': Error downloading module from https://gitlab.com/api/v4/packages/terraform/modules/v1/<GITLAB GROUP>/<MODULE NAME>/<MODULE_SYSTEM>/<VERSION>/download: error receiving HTTP data

Hmm "error receiving HTTP data". Bit vague.

It works as expected if you do this, though:

TG_TF_REGISTRY_TOKEN=<TOKEN> terragrunt plan --terragrunt-working-dir <DIR>

Expected behavior An error message that makes it clear the "error receiving HTTP data" was because you were not authorized to :)

Versions

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for raising this issue.