Kanji
・클라우드 엔지니어 / 프리랜서 ・1993년생 ・에히메현 출신 / 도쿄도 시부야구 거주 ・AWS 경력 5년 프로필 상세
목차
google-github-actions/auth@v3
attribute.condition
GitHub Secret의 장기 서비스 계정 JSON 키를 WIF(워크로드 아이덴티티 페더레이션)로 교체하는 것이 Cloud Run 및 Artifact Registry에 배포하기 위한 표준 관행이 되었습니다.하지만 google-github-actions/auth@v3 README를 여는 순간 아키텍처 분기점에 도달하게 됩니다. Direct Workload Identity Federation (Google에서 현재 선호 로 표시함)을 사용해야 할까요, 아니면 전통적인 서비스 계정 가장 을 사용해야 할까요?
gcloud ( 594.0.1 )를 사용하여 개인 Google Cloud 프로젝트에서 기존 워크로드 아이덴티티 풀을 검사했을 때 이전 설정이 여전히 문자열 기반 attribute.repository 조건에 의존하고 있음을 발견했습니다.’auth@v3’ 문서와 라이브 Google Cloud Discovery 스키마를 자세히 살펴보면 10분 토큰 제한, 서명된 URL 비호환성 등 무작정 Direct WIF를 선택할 경우 CI/CD 파이프라인이 중단될 수 있는 엄격한 경계가 드러났습니다.
gcloud
594.0.1
attribute.repository
이 가이드에서는 Direct WIF, 서비스 계정 가장, 서비스 계정 JSON 키를 나란히 비교하고 ‘attribute.condition’ 및 ’auth@v3’의 보안 트랩을 검사하고 Artifact Registry(Direct WIF) 및 Cloud Run(서비스 계정 가장) 구성을 모두 살펴봅니다.프로덕션에서 10분 단일 토큰 만료 경계를 트리거하기 위해 실시간 파괴 CI 테스트를 실행하지 않았습니다(프로덕션에서 확인되지 않음).아래 분석은 라이브 로컬 gcloud 594.0.1 검사, Google Cloud Discovery API 스키마( sts.googleapis.com , iam.googleapis.com , iamcredentials.googleapis.com ), 활성 풀의 읽기 전용 검사 및 공식 문서를 결합합니다.
gcloud 594.0.1
sts.googleapis.com
iam.googleapis.com
iamcredentials.googleapis.com
principalSet://
principal://
roles/iam.workloadIdentityUser
service_account
auth
signBlob
roles/iam.serviceAccountTokenCreator
두 페더레이션 모드 모두에서 GitHub Actions 실행기는 먼저 GitHub( id-token: write )에서 서명된 OIDC JWT를 요청하고 이를 Google Cloud Security Token Service( sts.googleapis.com )에서 페더레이션 토큰으로 교환합니다.발산은 교환 직후에 발생합니다.
id-token: write
Direct WIF를 사용하면 Google Cloud 프로젝트 또는 리소스에 있는 워크로드 아이덴티티 풀의 principalSet:// (또는 주제별 principal:// ) URI에 IAM 역할을 직접 할당할 수 있습니다.컨테이너 이미지를 Artifact Registry에 푸시하거나 Cloud Storage에 빌드 아티팩트를 업로드하는 등 Google Cloud의 ID 페더레이션: 제품 및 제한사항 매트릭스에 나열된 서비스의 경우 중간 서비스 계정을 삭제하면 IAM 감사가 단순화됩니다.
그러나 파이프라인이 다음 5가지 경계 중 하나에 도달하는 경우 서비스 계정 가장을 사용해야 합니다.
roles/iam.serviceAccountUser
iam.serviceAccounts.signBlob
token_format: "access_token"
token_format: "id_token"
constraints/iam.allowServiceAccountCredentialLifetimeExtension
현재 CLI 플래그와 API 계약을 확인하기 위해 STS( 개정: 20261106 ) 및 IAM( 개정: 20261126 )용 라이브 Discovery 문서와 함께 로컬에서 gcloud ( Google Cloud SDK 594.0.1 )를 확인했습니다.
개정: 20261106
개정: 20261126
Google Cloud SDK 594.0.1
gcloud --version | head -n 5 gcloud iam workload-identity-pools providers create-oidc --help | grep -E "attribute|issuer|allowed|discovery"
Google Cloud SDK 594.0.1 alpha 2026.11.21 beta 2026.11.21 bq 2.1.42 bundled-python3-unix 3.14.9 --attribute-mapping=[KEY=VALUE,...] --issuer-uri=ISSUER_URI [--allowed-audiences=[ALLOWED_AUDIENCES,...]] [--attribute-condition=ATTRIBUTE_CONDITION] [--description=DESCRIPTION] [--disabled] [--discovery-uri=DISCOVERY_URI]
sts.googleapis.com v1에서 GoogleIdentityStsV1ExchangeTokenRequest 는 audience , grantType , requestedTokenType , scope , subjectToken 및 subjectTokenType 을 정의하는 반면, iam.googleapis.com v1의 WorkloadIdentityPoolProvider 는 oidc 와 함께 attributeMapping 및 attributeCondition 을 노출합니다. aws , saml , x509 .
GoogleIdentityStsV1ExchangeTokenRequest
audience
grantType
requestedTokenType
scope
subjectToken
subjectTokenType
WorkloadIdentityPoolProvider
oidc
attributeMapping
attributeCondition
aws
saml
x509
이전에 개인 GCP 프로젝트에서 설정한 공급자를 다시 읽으면 다음 구성이 표시됩니다(자리 표시자로 가려진 프로젝트 번호 및 저장소 식별자).
attributeCondition: attribute.repository == "my-org/my-repo" attributeMapping: attribute.actor: assertion.actor attribute.repository: assertion.repository google.subject: assertion.sub oidc: issuerUri: https://token.actions.githubusercontent.com state: ACTIVE
언뜻 보면 attribute.repository 를 고정하는 것이 잠겨 있는 것처럼 보이지만 변경 가능한 저장소 이름을 사용하면 auth@v3 에 세 가지 일반적인 함정과 함께 미묘한 보안 허점이 발생합니다.
auth@v3
repository
repository_owner
모든 GitHub Actions 워크플로는 단일 글로벌 OIDC 발급자 https://token.actions.githubusercontent.com 을 공유합니다.’attributeCondition’이 없으면 전 세계 모든 공개 GitHub 저장소가 워크로드 아이덴티티 풀에 들어갈 수 있습니다.
https://token.actions.githubusercontent.com
조건을 추가하는 경우에도 assertion.repository == "my-org/my-repo" 또는 assertion.repository_owner == "my-org" 와 같은 문자열에서만 일치하면 조직이나 저장소의 이름이 변경되거나 삭제되고 나중에 외부 행위자(사이버 스쿼팅/타이포스쿼팅)에 의해 소유권을 주장하는 경우 창이 열려 있습니다.대신 GitHub의 변경할 수 없는 숫자 ID를 사용하세요.
assertion.repository == "my-org/my-repo"
assertion.repository_owner == "my-org"
# Fetch immutable numeric IDs via GitHub REST API curl -sfL -H "Accept: application/json" "https://api.github.com/orgs/my-org" | jq .id curl -sfL -H "Accept: application/json" "https://api.github.com/repos/my-org/my-repo" | jq .id
assertion.repository_owner_id == '12345678' && assertion.repository_id == '987654321'
프로덕션 배포 풀의 경우 해당 ID를 assertion.ref == 'refs/heads/main' 과 결합하면 기능 분기가 배포 토큰을 생성할 수 없습니다. assertion.environment == 'production' 만 확인하면 CEL의 assertion.ref 와 쌍을 이루거나 GitHub 환경 배포 분기 보호 규칙을 구성하지 않는 한 소스 분기가 제한되지 않습니다.또한 GitHub 저장소 이름은 대소문자를 구분하지 않지만 Google Cloud CEL 및 IAM 문자열 비교는 엄격하게 대소문자를 구분합니다.
assertion.ref == 'refs/heads/main'
assertion.environment == 'production'
assertion.ref
--attribute-condition 은 수신 JWT에서 직접 assertion.* 클레임을 평가할 수 있지만 IAM 바인딩( principalSet://.../attribute.<KEY>/<VALUE> )에서 참조하는 모든 속성은 반드시 --attribute-mapping 에 명시적으로 매핑되어야 합니다.매핑이 누락되면 ’OAuth 2.0 액세스 토큰 생성 실패’가 발생합니다.
--attribute-condition
assertion.*
principalSet://.../attribute.<KEY>/<VALUE>
--attribute-mapping
checkout
gsutil
google-github-actions/auth@v3 은 런타임을 노드 24 로 업그레이드했습니다.GitHub 호스팅 실행기는 이를 자동으로 처리하지만 이전 자체 호스팅 실행기는 ’v2’에서 ’v3’으로 변경하기 전에 업그레이드해야 합니다.
두 가지 워크플로 주문 세부정보도 팀을 구성합니다. - 생성된 자격 증명 파일( gha-creds-*.json )은 기본적으로 $GITHUB_WORKSPACE ( create_credentials_file: true ) 내에 있기 때문에 actions/checkout 은 google-github-actions/auth@v3 보다 먼저 실행되어야 하며 gha-creds-*.json 은 .gitignore 및 .dockerignore 에 나열되어야 합니다. - auth@v3 에 설명된 대로 기존 gsutil 명령은 이 작업으로 내보낸 자격 증명을 읽지 않습니다.스크립트를 gcloud Storage 로 마이그레이션합니다.
gha-creds-*.json
$GITHUB_WORKSPACE
create_credentials_file: true
actions/checkout
.gitignore
.dockerignore
gcloud Storage
google.subject
Google Cloud IAM은 매핑된 google.subject 주 구성원 식별자에 엄격한 127바이트 제한 을 적용합니다.긴 조직, 저장소 또는 분기 이름( repo:my-org/long-repo-name:ref:refs/heads/feature/long-branch )이 있는 저장소에서 google.subject=assertion.sub 를 사용하면 인증이 즉시 실패합니다.
repo:my-org/long-repo-name:ref:refs/heads/feature/long-branch
google.subject=assertion.sub
The size of mapped attribute exceeds the 127 bytes limit.
저장소와 분기 이름을 간결하게 유지하면 이를 방지할 수 있습니다. 또는 긴 분기 이름이 불가피할 경우 고정 길이 숫자 ID( assertion.repository_id + ":" + Assertion.run_id )를 중심으로 구축된 간단한 google.subject 매핑을 구성할 수 있습니다.
assertion.repository_id + ":" + Assertion.run_id
프로덕션 CI/CD 파이프라인에서 깔끔한 패턴은 Artifact Registry 이미지 푸시에 Direct WIF를 사용하고 Cloud Run 배포에 서비스 계정 가장을 사용하는 것입니다.다음은 gcloud 및 google-github-actions/auth@v3 을 사용한 엔드투엔드 설정입니다.
PROJECT_ID="my-gcp-project" PROJECT_NUMBER="123456789012" POOL_ID="github-actions-pool" PROVIDER_ID="github-actions-provider" REPO_OWNER_ID="12345678" REPO_ID="987654321" DEPLOY_SA="github-deploy@${PROJECT_ID}.iam.gserviceaccount.com" # 1. Create the pool gcloud iam workload-identity-pools create "${POOL_ID}" \ --project="${PROJECT_ID}" \ --location="global" \ --display-name="GitHub Actions Pool" # 2. Create the OIDC provider guarded by immutable IDs and main branch gcloud iam workload-identity-pools providers create-oidc "${PROVIDER_ID}" \ --project="${PROJECT_ID}" \ --location="global" \ --workload-identity-pool="${POOL_ID}" \ --display-name="GitHub Actions Provider" \ --issuer-uri="https://token.actions.githubusercontent.com" \ --attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.repository=assertion.repository,attribute.repository_id=assertion.repository_id,attribute.ref=assertion.ref" \ --attribute-condition="assertion.repository_owner_id == '${REPO_OWNER_ID}' && assertion.repository_id == '${REPO_ID}' && assertion.ref == 'refs/heads/main'"
Artifact Registry의 경우 중간 서비스 계정 없이 roles/artifactregistry.writer 를 principalSet:// 에 직접 바인딩합니다.Cloud Run 배포의 경우 배포 서비스 계정(‘DEPLOY_SA’)에 ’roles/iam.workloadIdentityUser’를 부여하고 해당 서비스 계정에 ’roles/run.developer’를 결합합니다.
roles/artifactregistry.writer
MEMBER="principalSet://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${POOL_ID}/attribute.repository_id/${REPO_ID}" # Pattern A: Direct WIF for Artifact Registry gcloud projects add-iam-policy-binding "${PROJECT_ID}" \ --member="${MEMBER}" \ --role="roles/artifactregistry.writer" # Pattern B: Service Account Impersonation for Cloud Run deployment gcloud iam service-accounts add-iam-policy-binding "${DEPLOY_SA}" \ --project="${PROJECT_ID}" \ --role="roles/iam.workloadIdentityUser" \ --member="${MEMBER}" gcloud projects add-iam-policy-binding "${PROJECT_ID}" \ --member="serviceAccount:${DEPLOY_SA}" \ --role="roles/run.developer"
name: Build and Deploy (WIF) on: push: branches: - main permissions: contents: read id-token: write jobs: push-image-direct-wif: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v7 - name: Authenticate via Direct WIF (Artifact Registry) uses: google-github-actions/auth@v3 with: project_id: ${{ vars.GCP_PROJECT_ID }} workload_identity_provider: ${{ vars.GCP_WIF_PROVIDER }} # Omit service_account for Direct WIF # Format: projects/123456789012/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider - name: Verify Artifact Registry access with federated token run: gcloud artifacts repositories list --project="${{ vars.GCP_PROJECT_ID }}" --location=asia-northeast1 deploy-cloud-run-impersonation: needs: push-image-direct-wif runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v7 - name: Authenticate via Service Account Impersonation (Cloud Run) uses: google-github-actions/auth@v3 with: workload_identity_provider: ${{ vars.GCP_WIF_PROVIDER }} service_account: ${{ vars.GCP_DEPLOY_SA }}
workload_identity_provider 가 문자열 프로젝트 ID가 아닌 숫자 프로젝트 번호 를 사용하고 전체 /providers/<provider> 접미사를 포함하는지 항상 다시 확인하세요.또한 ‘gcloud auth list’는 로컬로 구성된 계정만 인쇄하고 원격 승인을 테스트하지 않는다는 점에 유의하세요. 실제 대상 API(예: ’gcloud 유물 저장소 목록’)에 대한 액세스를 확인하세요.
workload_identity_provider
/providers/<provider>
google-github-actions/auth@v3 이 실패하면 오류 문구를 통해 어느 레이어가 요청을 거부했는지 정확하게 알 수 있습니다.
permissions.id-token: write
/providers/...
OAuth 2.0 액세스 토큰 생성 실패
매핑된 속성의 크기가 127바이트 제한을 초과했습니다.
assertion.sub
repository_id
Google Cloud에 새로운 GitHub Actions 배포를 설정할 때 Artifact Registry 또는 Cloud Storage와 같은 지원되는 서비스에 Direct WIF 를 사용하여 시작하고 Cloud Run에 배포하거나 Cloud Storage URL에 서명하거나 ID 토큰을 생성할 때 서비스 계정 가장 과 페어링하세요.어느 쪽이든, attribute.condition 을 변경할 수 없는 숫자 repository_owner_id 및 repository_id 값으로 잠그는 것은 첫날부터 수행할 가치가 있습니다.
repository_owner_id
여전히 변경 가능한 attribute.repository 문자열을 사용하는 오래된 풀의 경우 Terraform 상태 관리와 함께 이를 변경 불가능한 ID로 마이그레이션할 가장 명확한 시기를 결정해야 합니다.
Real-time AI quant analysis of corporate earnings reports.
실전 같은 AI 음성 모의 통화와 5축 정밀 피드백. 16강 인터랙티브 강의와 스튜디오급 AI 프로필 생성 지원.
영수증 촬영 즉시 Gemini AI가 품목과 금액을 자동 인식. 모임 및 여행 경비를 손쉽게 더치페이하고 정산합니다.
점술사, 집사, 바텐더 AI 캐릭터가 직접 게임을 진행하고 대화 주제를 던져 모임을 흥미진진하게 만듭니다.
人工甘味料や添加物のNG除外と有効成分あたりの実質単価比較データベース。