> 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の設定

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 のオンボーディングウィザードの「Configure Access」ステップでオプションとして利用できます。

<figure><img src="/files/ebdd6e57e982cca06839d9daca1089db84df1d9e" 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_acocunt_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="/files/8cfd470bad356be86c6c2befa4b5ebbe83cc6916" alt="" width="563"><figcaption><p>直接アクセスを使用した Google Cloud WIF 設定ファイルの生成</p></figcaption></figure>

## よくある質問

* **すでに接続済みの GCP プロジェクトをサービスアカウントから WIF に移行できますか？**

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

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

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

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

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

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

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

<figure><img src="/files/118c80a6b37db88cf950eac7c93fda5cc45f5f95" 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.
