Terraform private registry, modules not downloading

Hi,

We are working on creating a private registry which will be hosted on our servers.

We have created the required APIs and now trying to use the private registry modules to create resources.

While terraform init, we are getting error:

│ Error: Module not found

│ The module address “app.example.com/namespace/aws/s3_bucket” could not be resolved.

│ If you intended this as a path relative to the current module, use “./app.example.com/namespace/aws/s3_bucket” instead. The “./” prefix indicates that the address is a
│ relative filesystem path.

Here are the implementation details:

Download API:
https://xxxxxxxx.execute-api.eu-west-1.amazonaws.com/prod/modules.v1/namespace/aws/s3_bucket/0.0.2/download
This url returns the “X-Terraform-Get” header as well.

Module source download url: s3::https://examplebucket.s3.eu-west-1.amazonaws.com/aws-s3-bucket.zip

OS: Windows

terraform.rc path: %APP_DATA%

terraform.rc content:

host "app.example.com" {
  services = {
     "modules.v1" = "https://xxxxxxxx.execute-api.eu-west-1.amazonaws.com/prod/"
  }
}

credentials "app.example.com" {
  token = "token"
}

main.tf content:

terraform {
  required_version = ">= 0.12.0"
}

module "s3bucket" {
  source = "app.example.com/namespace/aws/s3_bucket"

  bucket = "sometestbucketname"
  acl    = "private"
}

We have token based authentication in place.

Can someone help with this??

Hi @prashant.masuria,

If you run terraform init with the environment variable TF_LOG=trace set then it should give some more information about what Terraform tried when resolving the source address you specified. It’ll hopefully give a clue about what step in the process isn’t working.

It looks like you are aiming to create a module registry on Amazon API Gateway, in which case you might find my (experimental) Terraform module apparentlymart/tf-registry/aws useful as a reference. I can’t promise that the result of that module is production-ready, because I’ve not actually used it in production, but I have seen it work in local testing and so I’m suggesting it here mainly as a second example you could compare yours with to see what might be different.

Yes, the private registry was developed with the help of mentioned github library.

The issue is resolved now. We were following the incorrect notation of module naming.

Instead of namespace/aws/s3_bucket, it should be namespace/s3_bucket/aws.