I’m trying to access resources in another project on the same GitLab instance. In terraform, you reference like so:
module dynamo_terraform_lock_table {
source = "git::https://git.mycompany.com/infrastructure/resources/tf-modules/terraform-state-lock?ref=0.0.4"
...
}
When I try to run a terraform init
via CI/CD, the job errors out because it cannot access the target repository.
Executing "step_script" stage of the job script
$ git config --global user.name ctote_test
$ git config --global user.password my-hard-coded-token
$ cd terraform
$ terraform init
Initializing modules...
...
fatal: could not read Username for 'https://git.mycompany.com': No such device or address
I was thinking I could use deploy keys somehow to solve this, but I haven’t been able to figure them out. I created a token called gitlab-deploy-token
in both repos and then tried including git config
commands to set $CI_DEPLOY_USER
and $CI_DEPLOY_PASSWORD
but it still gives me errors.
Is there a guide to setting up cross-repo access for CI/CD runners that I’m missing? I think this just boils down to figuring out how I can access resources in another project from the CI/CD pipeline, without hard-coding static credentials.