I have directory structure for my terraform project as below and i am trying to push this directory structure to gitlab terraform module registry.
stack
- vpc
- db
- dns
As per the Gitlab dicumentation i can download the terraform module like this.
module "my_module_name" {
source = "gitlab.com/xfinity/stack/local"
version = "1.0.0"
}
To authorize access to the Terraform registry:
credentials "gitlab.com" {
token = "<TOKEN>"
}
What i want to do is something like this.
module "my_module_name" {
source = "gitlab.com/xfinity/stack/local//vpc?ref=1.0.0"
}
But the problem i am facing is since my directory structure is nested, i am not able to reference a particular module like vpc or db in my source configuration.
I am unable to use Git or HTTPS source URLs to download a Terraform module from the GitLab registry because authentication with an SSH key is enforced when using an SSH URL. I prefer to use a Personal Access Token (PAT) for authentication instead.
Can you please suggest me how can i achieve this, without using a ssh or https source?