Currently having an issue pulling my own module from a gitlab terraform module registry. Gone through the gitlab documentation but still struggling. Gone with the instructions and using the following config:
module "ResourceGroup" {
source = "gitlab.com/<myuser>/resourcegroupmodule/mysystem"
version = "0.0.1"
base_name = "TerraformExample01"
location = "West US"
}
When i try and run terraform init, I get the following error:
│ Error: Error accessing remote module registry
│
│ Failed to retrieve available versions for module "ResourceGroup" (main.tf:25) from gitlab.com: error looking up module versions:
│ 401 Unauthorized.
Tried to add a credential block as per the instructions but no success either. Added this block to the main.tf file:
credentials "gitlab.com" {
token = "<myAPIkey>"
}
Any help greatly appreciated. Feels like kind of got the credentials section/api token in the wrong place.
I used environment variable TF_TOKEN_gitlab_whatever_domain_com= Access toke with read_api permission. I have a hosted gitlab solution on gitlab.whatever.domain.com This approach worked for me.
The answer is above from @lyzlisa.
Just created the ~/.terraformrc file with the credentials block
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With