> For the complete documentation index, see [llms.txt](https://docs.stoik.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stoik.io/prevention-tools/cloud-scan/gcp.md).

# Setup: GCP

Give the Cloud scan read-only access to a Google Cloud project by creating a service account that Stoïk can use.

## Prerequisites

* An administrator account is required to perform this deployment.
* A technical advisor is required for ongoing supervision and vulnerability remediation.
* One person does the whole setup, from start to finish: a Stoïk Protect user allowed to edit prevention tools, who is also an administrator of the GCP project.

## Setup

{% stepper %}
{% step %}

### Select Google Cloud Platform

Go to `Cloud Scan` > `Settings`, click `New Provider`, and select `Google Cloud Platform`.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FDw2b46xxHQFAG4OCkigt%2FScreenshot%202026-04-07%20at%2018.57.56.png?alt=media&amp;token=72ccef3f-3cb8-4f54-b98b-6c748f5e3e92" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Open your Cloud Console

Go to the [Google Cloud Console](https://console.cloud.google.com/) and log in with your administrator account.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FUTcz9AktGTD9Cczz9KPB%2Fcloud-scan-google-cloud-console.png?alt=media&amp;token=4f6d18c5-3eec-4040-9d46-12ae365c6dd7" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Open the API library

Go to `APIs & Services` > `Library` in the left-hand menu.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FH7VRpz11JW2ppKogPQ4y%2Fcloud-scan-console-api-services-library.png?alt=media&amp;token=e0153ae0-5695-4746-b3bc-da256ee2d1bb" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Find the Cloud Resource Manager API

Search for `Cloud Resource Manager API` and click on it.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2F4f8FTY2S563Lm31xK7Np%2Fcloud-scan-cloud-resource-manager-api.png?alt=media&amp;token=0aafc7a8-1d1d-40fc-b08d-b6eb064cb3d1" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Enable the API

Click `Enable`.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FqHVrHGykLoST9s0PycrJ%2Fcloud-scan-resource-manager-api-enable.png?alt=media&amp;token=20c69a92-2c79-4568-a5c9-86c5806db366" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Open the service accounts

Go to `IAM & Admin` > `Service Accounts` in the left-hand menu.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FskzJLLEd9DokDw9pHIJF%2Fcloud-scan-iam-admin-service-accounts.png?alt=media&amp;token=c83333e7-9f3c-4fc9-9678-ff91daec5658" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Create the service account

Click `Create Service Account`.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FBTbAgGb6fSK20BVXuuSz%2Fcloud-scan-create-service-account.png?alt=media&amp;token=168d4f6e-46ff-4420-a503-9002c33b3f2a" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Name the service account

Enter `stoik-scanner` as the service account name, then click `Create and continue`.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2F6whuJGKh4PNGgftwZqLV%2Fcloud-scan-create-service-account-name.png?alt=media&amp;token=d00f2170-bd90-455f-a9f3-94da30e44b62" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Assign roles

Add the following 3 roles: `Viewer`, `Security Reviewer`, `Stackdriver Accounts Viewer`.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FCChwue8tVQSHKCpMIlCe%2Fcloud-scan-create-service-account-permissions.png?alt=media&amp;token=26b9ac91-e109-412d-8cd8-37548092f78b" alt=""><figcaption></figcaption></figure>

Leave step 3 empty and click `Done`.
{% endstep %}

{% step %}

### Open the service account

Click on the service account you just created, then click `Principals with access`.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2Ft4z2qlijQGNNDA4ISbLi%2Fcloud-scan-open-service-account.png?alt=media&amp;token=94f014b7-d982-4152-bfd9-8d3af5436de8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FiCKjOoUMiZUKJDD9lcDz%2Fcloud-scan-service-account-grant-access.png?alt=media&amp;token=362b9a8b-d905-4d37-ad5f-b8017951ebe0" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Grant access

1. Select your service account and click `Grant access`.
2. Enter `stoik-scanner@stoik-gcp-scan-prod.iam.gserviceaccount.com` in the `New principals` field.
3. Assign the `Service Account Token Creator` role, then click `Save`.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FtA2nkzIqHpx65ok06gqr%2Fcloud-scan-service-account-add-principals.png?alt=media&amp;token=f1c62da6-496e-4804-9afc-161d71df3c2b" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Copy the service account email

1. Click `Details` in GCP.
2. Copy the email address of the created service account.

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2FBbOUrFQXlScFI32CxLgR%2Fcloud-scan-service-account-copy-email.png?alt=media&amp;token=4fa17999-bb77-4764-bfff-99c2a20735f6" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Complete setup

<figure><img src="https://2582414397-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaDGGQ49Oui29Ft0kJjSm%2Fuploads%2F6yEDTO51V6cbdB8McEz4%2FScreenshot%202026-04-07%20at%2018.59.05.png?alt=media&amp;token=1568ad28-5e33-4283-8b3c-d415d7606fce" alt=""><figcaption></figcaption></figure>

1. Paste the service account email address into the `Service Account Email` field in Stoïk Protect.
2. Click `Complete setup`.

{% hint style="info" %}
Refresh the Stoïk Protect page if necessary.
{% endhint %}
{% endstep %}
{% endstepper %}

## Projects to scan

Set up the projects that hold your servers and databases: a project created just for Stoïk is empty, so there is nothing to scan. The API must be enabled one project at a time.

## Troubleshooting

<details>

<summary>The setup failed, then worked when I retried</summary>

New roles, permissions and APIs take a few minutes to apply. Wait 5 minutes and click again.

</details>

<details>

<summary>"role/stackdriver.accounts.viewer must be assigned"</summary>

`Stackdriver Viewer` and `Stackdriver Accounts Viewer` are two different roles. The service account needs exactly `Viewer`, `Security Reviewer` and `Stackdriver Accounts Viewer`.

</details>

<details>

<summary>"do not belong to a permitted customer"</summary>

Your organization policy **Domain restricted sharing** (`iam.allowedPolicyMemberDomains`) blocks the Stoïk service account. Your admin adds Stoïk's customer ID `C01isw1kw` to the allowed values, in `IAM & Admin` > `Organization Policies`. This requires the `Organization Policy Administrator` role at the organization level: being Owner of the project is not enough.

</details>

<details>

<summary>"Integration with GCP failed" / getAccessToken denied</summary>

Two usual causes:

* The Cloud Resource Manager API is not enabled, or was enabled only a few minutes ago.
* `stoik-scanner@stoik-gcp-scan-prod.iam.gserviceaccount.com` did not get the `Service Account Token Creator` role on your service account.

</details>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stoik.io/prevention-tools/cloud-scan/gcp.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
