> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/kuraudosukyan/connect-your-cloud/gcp/google-cloud-workload-identity-federation-setup.md).

# Google Cloud Workload Identity Federation のセットアップ

このページでは、Workload Identity Federation を使用して Aikido に GCP プロジェクトへのアクセス権を付与する方法を説明します。もう 1 つの方法はサービス アカウントを使用することです。

Google Cloud Workload Identity Federation（WIF）を使用すると、サービス アカウント キーやその他のシークレットなしで Aikido が Google Cloud プロジェクトをスキャンできるようになります。

Workload Identity Federation のプールとプロバイダを設定すると、Aikido は独自の認証情報を、GCP 環境で有効な認証情報に交換できます。これらは短期間のみ有効で、どこにも保存されないため、この方法ははるかに安全で、さまざまなコンプライアンス要件にも対応できます。

WIF については、 [Google Cloud のドキュメント](https://docs.cloud.google.com/iam/docs/workload-identity-federation-with-other-clouds).

## **なぜ Workload Identity Federation なのか？**

* 長期間有効なサービス アカウント キーを不要にします。
* キーのローテーションとシークレット管理を簡素化します。
* より厳しいコンプライアンスおよびセキュリティ要件を満たします。

## はじめに

Workload Identity Federation は、Google Cloud のオンボーディング ウィザードの「アクセスの構成」ステップでオプションとして利用できます。

<figure><img src="https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-22682ddba01591aa36563d85d8b4659f4c635c2b%2Fimage.png?alt=media" alt="" width="563"><figcaption><p>Aikido の GCP オンボーディングにおける Service Account と Workload Identity Federation の選択</p></figcaption></figure>

Aikido が、Google Cloud プロジェクトで workload identity pool と provider を設定するために必要な CLI コマンドを提供します。

他の方法で WIF を設定したい場合は、必要な詳細は次のとおりです。

### プロバイダの詳細

{% hint style="info" %}
これらの値は、アプリ内で Aikido が提供する CLI コマンドから取得することを強く推奨します。
{% endhint %}

* プロバイダ: **AWS** （これにより、Aikido は AWS IAM の認証情報を GCP の認証情報に交換できます）
* AWS アカウント ID: **881830977366** （これは、Aikido が認証情報の交換を開始する AWS アカウントです）
* 属性マッピング（AWS では、これらがデフォルトのマッピングである必要があります）:
  * `google.subject` = `assertion.arn`
  * `attribute.aws_role` = `assertion.arn.contains('assumed-role') ? assertion.arn.extract('{account_arn}assumed-role/') + 'assumed-role/' + assertion.arn.extract('assumed-role/{role_name}/') : assertion.arn`

### IAM 権限

アクセスを付与します **ただ** Aikido の AWS アカウント内のすべてのプリンシパルではなく、必要な特定の Aikido IAM ロールに対して。

Aikido の IAM ロール用のプリンシパルを組み立てる方法は次のとおりです。

`principalSet://iam.googleapis.com/projects/` + `<your_project_number>` + `/locations/global/workloadIdentityPools/` + `<your_wif_pool>` + `/attribute.aws_role/arn:aws:sts::` + `<aikido_aws_account_id>` + `:assumed-role/` + `<aikido_aws_role_name>`

Aikido には、プロジェクトまたは [組織](https://help.aikido.dev/cloud-scanning/connect-your-cloud/gcp/connect-google-cloud-organization) レベルで次の権限が必要です。

* **Viewer/Reader** （利用可能であれば Reader のほうが望ましい）および **セキュリティ レビュアー** Aikido ロールに対して `lambda-gcp-cloud-findings-role-1muvqxle`.
* **Artifact Registry Viewer** 対象:
  * Aikido ロールで Artifact Registry のコンテナ イメージを Aikido にスキャンさせたい場合 `lambda-container-image-scanner-role-pb0qotst`.
  * または、Aikido ロールで Artifact Registry Vulnerability Scanning の結果のみを Aikido に取り込みたい場合 `lambda-gcp-cloud-findings-role-1muvqxle`.

{% hint style="info" %}
プロジェクトまたは組織の IAM ポリシーにすでに **条件付きバインディング**, `gcloud` では、新しいバインディングごとに明示的に条件を指定する必要があります。

Aikido 用の IAM バインディングを適用する際は、必ず **条件を明示的に無効にし**てください。これは、 `--condition=None` を `gcloud` コマンドを追加するか、CLI からプロンプトされたときに **なし** を選択することで行えます。
{% endhint %}

Workload Identity Federation のプールとプロバイダ、および IAM 権限を設定したら、Aikido にアップロードする設定ファイルを生成します。推奨される、より簡単な方法は **直接アクセス** （サービス アカウントの偽装ではなく）です。

<figure><img src="https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-e87f6d0f73411effc5485ef72c6f682b8cf111b2%2Fimage.png?alt=media" alt="" width="563"><figcaption><p>直接アクセスを使用した Google Cloud WIF 設定ファイルの生成</p></figcaption></figure>

{% hint style="warning" %}
スキャン対象が **App Engine**の場合は、直接アクセスの代わりにサービス アカウントの偽装を使用してください。App Engine の Google Cloud API は、 [直接 WIF アクセスをサポートするサービスの一覧](https://docs.cloud.google.com/iam/docs/federated-identity-supported-services)に含まれていないため、直接アクセスは認証エラーで失敗します。詳しくは [サービス アカウントの偽装](https://docs.cloud.google.com/iam/docs/workload-download-cred-and-grant-access#impersonation) および以下の FAQ を参照してください。
{% endhint %}

## よくある質問

* **すでに接続済みの GCP プロジェクトを Service Account から WIF に移行できますか？**

はい。アプリ内の手順に従ってプロジェクトで WIF を設定し、オンボーディングを完了する代わりに、生成された設定ファイルで既に接続済みの GCP プロジェクトの認証情報を更新できます。

* **既存の WIF プールを使用できますか？**

はい。WIF プールのいずれかに新しいプロバイダを追加できます。CLI コマンドは、既存のプール名を使うように調整する必要があります。

* **WIF プロバイダに属性条件も設定すべきですか？**

すでに特定の Aikido プリンシパルにのみアクセスを付与しているため（WIF プール全体ではなく）、 [属性条件](https://docs.cloud.google.com/iam/docs/workload-identity-federation#conditions) の重要性は低くなります。ただし、ポリシーで必須とされている場合は、上記の 2 つの IAM ロールに条件を追加できます。

* **直接ではなく、サービス アカウントの偽装を通じてアクセスを設定できますか？**

はい。ただし、直接アクセスのほうが簡単です。組織で、すべての外部 ID はサービス アカウント経由で動作することが義務付けられている場合、または **App Engine**をスキャンしている場合は、偽装を使用してください。これは API が直接 WIF アクセスをサポートしていないためです。サービス アカウントを作成し、上記の Aikido プリンシパルがそれを偽装できるようにし（`roles/iam.workloadIdentityUser`）、必要な IAM 権限を付与して、サービス アカウント用の設定ファイルを生成できます。

<figure><img src="https://715870456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-59fba576331b85b1c28bf2b7f0fd820d2a2543ba%2Fimage.png?alt=media" alt="" width="375"><figcaption><p>サービス アカウント用の設定ファイルの生成</p></figcaption></figure>

* **これ用の Terraform モジュールはありますか？**

はい！こちらで利用できます: <https://github.com/AikidoSec/gcp-onboarding-terraform-module>。プロジェクトと組織のオンボーディングという 2 つのバリエーションがあります。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.aikido.dev/docs/docs-ja/kuraudosukyan/connect-your-cloud/gcp/google-cloud-workload-identity-federation-setup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
