-
A problem we run into constantly is the following: You want to run some sort of automation on your code (e.g., run automated tests or Example 1: you have Terraform code in repo # foo/example/main.tf
module "example" {
# A reference to private repo bar. Note this is a Git/SSH URL.
source = "git::[email protected]:acme/bar.git//example-module"
} Example 2: You have a Bash script in repo # foo/example/build.sh
# A reference to private repo bar. Note this is an HTTPS URL.
git clone https://github.com/acme/bar.git Although most CI servers automatically give you access to the code in the repo where the build is running (e.g., So the question is: how do you securely give your CI server access to private Git repos?
So, how do you solve this? I'll share Gruntwork's recommendation below. Feedback, suggestions, and other ideas are very welcome! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Here's the approach we typically recommend. In the examples below, I'll use GitHub as the version control system and GitHub Actions as the CI server, but the same approach works with most other version control systems (e.g., GitLab, BitBucket, etc.) and CI servers (e.g., GitLab, CircleCI, etc.).
Try it out and let us know how it works for you! |
Beta Was this translation helpful? Give feedback.
Here's the approach we typically recommend. In the examples below, I'll use GitHub as the version control system and GitHub Actions as the CI server, but the same approach works with most other version control systems (e.g., GitLab, BitBucket, etc.) and CI servers (e.g., GitLab, CircleCI, etc.).
Create a machine user in GitHub. A machine user is a user account that isn't used by any individual person (i.e., it is not your personal GitHub account); instead, it's an account owned by your company that you use specifically for automation. Using a machine user ensures that (a) if any individual person leaves your company, all your automation doesn't suddenly break when that person loses acce…