Looking here https://developer.hashicorp.com/terraform/internals/module-registry-protocol#module-addresses, how can one have multi-level paths for namespace or name for module publishing within registry.
We have module sources like /modules/aws/ec2/s3, /modules/aws/ec2/asg etc and would want to have same paths within terraform registry. We are currently external implementation of terraform registry.
When we include this paths within terraform .tf file it fails
source = <registry-url>/aws/ec2/s3/aws
this works
source = <registry-url>/aws/ec2/aws
Hi @geek8761,
The module registry address scheme requires exactly four parts, as described in that documentation. There is no option to introduce additional parts.
If you want to represent additional hierarchy in your module addresses then you will need to use multiple segments inside one of the four parts, such by as using example.com/aws/ec2-s3/aws in this case.
Thanks @apparentlymart .
Can I ask how is something like this handled within the registry protocol ?
module "iam_account" {
source = "terraform-aws-modules/iam/aws//modules/iam-account"
That address is an example of sources in subdirectories.
In that case, Terraform follows the following steps:
-
Use the registry to resolve terraform-aws-modules/iam/aws into something like git::https://github.com/terraform-aws-modules/terraform-aws-iam
(the exact address is decided by the registry at registry.terraform.io, so might use slightly different syntax but the same Git repository)
-
git clone that Git repository.
-
Use the module in the modules/iam-account subdirectory of the repository.
In this case the registry is only involved in the first step. Everything else is handled client-side by Terraform’s module installer. The registry does not know that Terraform will eventually use a subdirectory of the selected module package.
1 Like