MatthewJohn / terrareg

Open source Terraform module registry with UI, optional Git integration and deep analysis
https://gitlab.dockstudios.co.uk/pub/terrareg
GNU General Public License v3.0
268 stars 20 forks source link

dowload module fail #27

Closed QloudXee closed 9 months ago

QloudXee commented 9 months ago

Hi John

I have a problem about download module file when run 'terraform init' ,the console shows that the url of module source.zip is invaild image

however , I have found the source.zip in docker contianer image

the docker logs shows this may be an 204 http error image

how should I fix it thanks a lot

MatthewJohn commented 9 months ago

Hey @QloudXee,

Thank you for raising this - it's very interesting - could you let me know which version of Terraform you're using at all?

I'll start testing to see if I can reproduce it

Many thanks Matt

QloudXee commented 9 months ago

image the version is 1.5.3

MatthewJohn commented 9 months ago

Ah, I think I have a suspicion! Would you be able to send across the "source" argument of the module call in your terraform? Have you put a full URL, e.g. https://example.com:5000/modules/my-tf-application__sbx/vnet1/azurerm/1.0.0 in there? If so, this is just telling Terraform to use it as an HTTP source, as opposed to a registry. If you change to:

module "test" {
  source  = "example.com:5000/my-tf-application__sbx/vnet1/azurerm"
  version = "1.0.0"
}

does it work any better? :)

Having said that, downloading via http does require this methology and it should work using the URL format that you supplied, so I'll investigate that and get it fixed :) I've managed to reproduce it:

➜  terraform git:(main) ✗ terraform-1.5.3 init -upgrade

Initializing the backend...
Upgrading modules...
Downloading https://local-dev.dock.studio/modules/adgadg__test/local-module3/aws/1.1.0 for local-module3...
╷
│ Error: Failed to download module
│ 
│   on main.tf line 21:
│   21: module "local-module3" {
│ 
│ Could not download module "local-module3" (main.tf:21) source code from "https://local-dev.dock.studio/modules/adgadg__test/local-module3/aws/1.1.0": error downloading
│ 'https://local-dev.dock.studio/modules/adgadg__test/local-module3/aws/1.1.0': invalid source string: /v1/terrareg/modules/test/local-module3/aws/1.1.0/source.zip
╵

Many thanks Matt

QloudXee commented 9 months ago

Okay ,that is work Thank you for your patient support image

MatthewJohn commented 9 months ago

Hey @QloudXee ,

No problem at all - glad it's working

I've fixed the issue you were having in this PR: https://gitlab.dockstudios.co.uk/pub/terrareg/-/merge_requests/373 I'll get it merged ASAP :)

Thanks Matt

MatthewJohn commented 6 months ago

Created gitlab issue: https://gitlab.dockstudios.co.uk/pub/terrareg/-/issues/505 gitlab-issue-id:505