> 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/mashinsukyan/gcp-virtual-machine-scanning-configuration.md).

# Google Cloud仮想マシンスキャンの設定

### なぜ仮想マシンをスキャンする必要があるのですか？

仮想マシンスキャンでは、Aikido が Google Compute Engine の VM のディスクをスキャンし、脆弱なパッケージ、古いランタイム、リスクのあるライセンスを検出します。

### はじめに

Google Cloud インスタンスのスキャンを有効にするには、まず Google Cloud プロジェクトを Aikido に接続します。以下に示す手順に従ってください [こちら](https://help.aikido.dev/cloud-scanning/connect-your-cloud/gcp) まだ行っていない場合は。

クラウドが接続されたら、Virtual Machines ページに移動して **VM を接続**.

<figure><img src="/files/8a607d08827b8dfe91d4c97b6e2250de255925ec" alt=""><figcaption></figcaption></figure>

で **仮想マシンを接続する** モーダルで、選択 **Google Cloud** の下で **エージェントレススキャン**。Aikido が4つの手順をご案内します：

カスタムロールとサービス アカウントには必要最小限の権限のみが付与され、ストレージ権限はプロジェクト全体ではなくスナップショット バケットのみに限定されます。これにより、Aikido はリソースを意図せず変更するリスクなしにセキュリティチェックを実行できます。

{% stepper %}
{% step %}
**必要な Google Cloud API を有効にする**

Aikido がコンピュートインスタンスをスキャンするには、プロジェクトでいくつかの Google Cloud API を有効にする必要があります。

1. GCP コンソールで、次をクリックします： **Cloud Shell を有効化** 右上のアイコン。
2. 画面下部に開いたシェルで、セットアップページに表示されているコマンドを実行します。これにより、次の API が有効になります：
   * `compute.googleapis.com`
   * `iam.googleapis.com`
3. コマンドの実行が完了したら、次をクリックします： **続行**.
   {% endstep %}

{% step %}
**カスタムロールを作成**

Aikido は 2 つのカスタムロールを使用します：

1. インスタンスの一覧表示、ディスクの読み取り、スナップショットの作成、スナップショットの読み取りを行うメインロール
2. Aikido が作成したスナップショットを削除するための削除専用ロール

セットアップウィザードに表示されているコマンドを実行して、両方のロールを作成します。

メインロールに含まれるもの：

* `compute.instances.list`
* `compute.instanceGroups.get`
* `compute.instanceGroups.list`
* `compute.disks.createSnapshot`
* `compute.disks.get`
* `compute.snapshots.create`
* `compute.snapshots.get`
* `compute.snapshots.list`
* `compute.snapshots.setLabels`
* `compute.snapshots.useReadOnly`

2 つ目のロールに含まれるもの：

* `compute.snapshots.delete`

ロールを作成したら、その ID（`aikidoSecurityVmScannerRole` と `aikidoSecurityVmScannerSnapshotDeleteRole` を記録しておいてください（変更していない場合）。

押してください **続行**.

{% hint style="info" %}
**このロールのすべての権限を保持します。** これは、Aikido が VM スキャンを実行するために必要な最小限の権限です。いずれかを削除すると、スキャンは失敗します。
{% endhint %}
{% endstep %}

{% step %}
**アクセスを付与**

Aikido は、セットアップウィザードで管理対象の Google Cloud サービス アカウントのメールアドレスを表示します。手順 2 で作成したロールを、Aikido 管理のサービス アカウントに付与します：

* ウィザードに表示されているコマンドを使用して、そのサービス アカウントにメインのカスタムロールを付与します。
* 次に、ウィザードに表示されている 2 つ目のコマンドを使用して、削除専用ロールを付与します。そのバインディングには条件が含まれているため、Aikido が作成したスナップショットにのみ適用されます。これにより、Aikido は自分で作成したスナップショットだけを削除できます。
  {% endstep %}
  {% endstepper %}

### 仕組み

大まかな流れは次のとおりです：

{% stepper %}
{% step %}
Aikido が Google Cloud プロジェクト内の GCE インスタンスを検出します。
{% endstep %}

{% step %}
Aikido がプロジェクト内の対応するディスクのスナップショットを作成します。

{% hint style="info" %}
Aikido がそれらのスナップショットにラベルを付けるため、付与した削除権限は Aikido 管理のスナップショットにのみ適用されます。
{% endhint %}
{% endstep %}

{% step %}
その後、各スナップショットから Aikido 管理のプロジェクトに一時ディスクを作成します。

{% hint style="info" %}
ディスクは、元のディスクと同じリージョンの Aikido 管理プロジェクトで作成され、スキャンされます。
{% endhint %}
{% endstep %}

{% step %}
一時ディスクは、実際のスキャンを行う分離された一時ジョブにアタッチされます。
{% endstep %}

{% step %}
一時ディスクは Aikido 管理プロジェクトから削除されます。
{% endstep %}
{% endstepper %}

### VPC Service Controls とともに GCP VM スキャンを使用する

GCP プロジェクトが VPC Service Controls の境界で保護されている場合、説明した IAM 権限に加えて、さらに 1 つのクロスプロジェクト操作を許可する必要があるかもしれません [上記](#getting-started).

で説明されているように [「仕組み」セクション](#how-it-works)、Aikido はプロジェクト内にスナップショットを作成し、そのスナップショットから Aikido のスキャナープロジェクトに一時ディスクを作成します。ディスクの作成は VPC Service Controls によってブロックされる場合があります。

**許可する内容**

* サービス： `compute.googleapis.com`
* メソッド： `compute.v1.DisksService.Insert`
* 対象プロジェクト： `aikido-vm-scanning`
* サービス アカウント： `aikido-vm-scanner-batch@aikido-vm-scanning.iam.gserviceaccount.com`

### Domain-Restricted Sharing とともに GCP VM スキャンを使用する

organization policy の制約を使用している場合は、たとえば次のようなものです： `iam.managed.allowedPolicyMembers` または `iam.allowedPolicyMemberDomains`、Aikido の Google Workspace 顧客 ID は次のとおりです： `C016qe815`.


---

# 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/mashinsukyan/gcp-virtual-machine-scanning-configuration.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.
