이 글을 이해하려면 AWS CodeBuild connection을 알고 있어야 합니다.
- AWS CodeBuild connection: https://malwareanalysis.tistory.com/939
풀어야 할 문제
CodeBuild로 clone한 repo 안에 쉘 스크립트가 있습니다. 이 쉘 스크립트가 또 다른 private repo를 임시 토큰으로 clone해야 합니다.

풀 수 있는 방법 중 한 개 - CodeBuild connection 임시 토큰을 그대로 사용
결국 임시 토큰만 발급받으면 되기 때문에, 임시 토큰을 발급받는 여러 방법 중 하나를 선택하면 됩니다.
이미 CodeBuild connection을 사용하고 있다면, CodeBuild connection이 발급받은 토큰을 그대로 사용해 git clone을 할 수 있습니다. 물론 CodeBuild connection GitHub App이 clone할 repo에 접근 권한을 가지고 있어야 합니다.

CodeBuild connection이 발급받은 임시 토큰을 사용하려면, buildspec에서 git-credential-helper 옵션을 yes로 설정합니다.
version: 0.2
env:
git-credential-helper: yes
이 옵션을 켜면 CodeBuild가 Git credential helper를 등록하기 때문에, HTTPS 프로토콜로 clone할 때 토큰을 직접 넣지 않아도 됩니다.
git clone https://github.com/<OWNER>/<REPOSITORY>.git
토큰을 직접 들고 있는 경우에는 URL에 x-access-token으로 넣는 방법도 있습니다.
git clone https://x-access-token:<TOKEN>@github.com/<OWNER>/<REPOSITORY>.git
git-credential-helper
Git credential helper는 HTTPS 프로토콜 Git 요청이 있을 때 인증 정보(username, password)를 제공하는 인터페이스입니다.

HTTPS 프로토콜로 git clone을 하면 credential helper가 우선순위에 따라 Git 인증 정보를 조회해 Git client에게 제공합니다.

CodeBuild는 CodeBuild를 위한 Git credential helper를 가지고 있고 AWS가 관리합니다. 다만 이 경로는 AWS 공식 문서에 나와 있지 않기 때문에, 직접 호출하는 방식으로 의존하지 않는 편이 좋습니다.
- /codebuild/readonly/bin/git-credential-helper
트레이드 오프
CodeBuild connection GitHub App은 org마다 1개만 설치할 수 있습니다. 그래서 org에 내 프로젝트가 아닌 다른 팀 프로젝트가 같이 있는 경우, 다른 팀이 CodeBuild connection GitHub App을 사용해 내 프로젝트 repo에 접근할 수 있습니다.
참고자료
'전공영역 공부 기록' 카테고리의 다른 글
| JVM 옵션 하나로 OOM 순간의 heap dump 남기기 (2) | 2026.07.19 |
|---|---|
| Claude Code 권한 관리 - deny, Auto mode, Skill 자동 호출 제어 (0) | 2026.07.17 |
| LiteLLM QuickStart - guardrail(가드레일) (0) | 2026.07.12 |
| LiteLLM QuickStart - Budget limit(비용제한) (0) | 2026.07.12 |
| LiteLLM QuickStart - 모델 등록하고 호출해보기 (0) | 2026.07.12 |