Self hosted on premise GitLab environment. I have a group of repositories, where each repository will contain a different terraform resource module. I have another repository that will host the “root module”. I have setup a “deploy token” for the resource module that has read access. How do I setup the root module that is running via Gitlab CI/CD to authenticate to the resource module using the deploy token?
I found the solution myself and figured I would post up here in case others in the future come across this issue:
- In your .gitlab-ci-yml file place this line in your “before script” section:
- git config --global url.“https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.example.com”.insteadOf https://gitlab.example.com"
- In the repo your reading from, make sure you adjust the “Token Access” to allow the CI/CD for the resource module to allow for the root module CI/CD to read it. Gitlab>Project(repo)>settings>CI/CD>Token Access