# Google Bucket

### Requirements <a href="#id-1-requirements" id="id-1-requirements"></a>

1. A Google Cloud Platform project that you can administer.
2. A Valohai project or organization to link Google Storage to.
3. A Google Bucket

### Create a Service Account <a href="#id-2-create-a-service-account" id="id-2-create-a-service-account"></a>

Next, we’ll create a new service account using the GCP console. The service account is “an account” that Valohai workers use to access this particular GCP bucket.

<figure><img src="https://docs.valohai.com/hc/article_attachments/30486446805905" alt=""><figcaption></figcaption></figure>

Navigate to IAM & admin > Service accounts > Create service account.

<figure><img src="https://docs.valohai.com/hc/article_attachments/30486500378641" alt=""><figcaption></figcaption></figure>

Name your service account so that you can later remember what it’s meant for (here we are using “my-valohai-bucket-admin”) and press “Create.”

<figure><img src="https://docs.valohai.com/hc/article_attachments/30486446842641" alt=""><figcaption></figcaption></figure>

On the next screen, you don’t need to add any roles as we will configure more limited access rights later. Just press “Continue.”

<figure><img src="https://docs.valohai.com/hc/article_attachments/30486399263377" alt=""><figcaption></figcaption></figure>

Press the “Create Key” button and select JSON format. This will automatically download a JSON file that we’ll be using later.

The resulting JSON file will look something like this:

```json
{
  "type": "...",
  "project_id": "...",
  "private_key_id": "...",
  "private_key": "...",
  "client_email": "my-valohai-bucket-admin@chubby.iam.gserviceaccount.com",
  "client_id": "...",
  "auth_uri": "...",
  "token_uri": "...",
  "auth_provider_x509_cert_url": "...",
  "client_x509_cert_url": "..."
}
```

Also, take note of the `client_email` value; we’ll be using that later.

You can later find the service account email in the Service Accounts listing:

<figure><img src="https://docs.valohai.com/hc/article_attachments/30486462243217" alt=""><figcaption></figcaption></figure>

### Permissions <a href="#id-3-permissions" id="id-3-permissions"></a>

Next, we permit the new service account to access files in the bucket.

<figure><img src="https://docs.valohai.com/hc/article_attachments/30486446974609" alt=""><figcaption></figcaption></figure>

Navigate to Storage > Browse > “your-bucket” > Permissions > Add member.

<figure><img src="https://docs.valohai.com/hc/article_attachments/30486484110097" alt=""><figcaption></figcaption></figure>

* New members: Copy-and-paste the service account email into the field; it will validate it. We got the service account email in the previous section.
* Role: Select “Storage Object Admin,” this allows download and uploading files.
* Press the “Save” button.

### CORS <a href="#id-4-cors" id="id-4-cors"></a>

* Click on “Activate Google Cloud Shell” in the top-right corner.
* Create a new CORS configuration file:

```sh
echo '[{"origin": ["*"],"responseHeader": ["Content-Type", "x-ms-*"],"method": ["GET", "HEAD", "OPTIONS"],"maxAgeSeconds": 3600}, {"origin": ["https://app.valohai.com"],"responseHeader": ["Content-Type", "x-ms-*"],"method": ["POST", "PUT"],"maxAgeSeconds": 3600}]' > cors-config.json
```

* Update the CORS settings for your bucket:

```sh
gsutil cors set cors-config.json gs://<your-bucket-name>
```

* Check the CORS settings:

```sh
gsutil cors get gs://<your-bucket-name>
```

### Link the Store to Valohai <a href="#id-5-link-the-store-to-valohai" id="id-5-link-the-store-to-valohai"></a>

You can connect this data store either to a single project or create it on the organization level.

#### Link to a Valohai Organization <a href="#id-6-link-to-a-valohai-organization" id="id-6-link-to-a-valohai-organization"></a>

* Navigate to `Hi, <name>` (the top-right menu) > `Manage <organization>`
* Open the “Data Stores” tab and add your store’s details. The data store can be shared with everyone in the organization, or you can expose the data store only to certain teams.

#### Link the Store to a Valohai Project <a href="#id-7-link-the-store-to-a-valohai-project" id="id-7-link-the-store-to-a-valohai-project"></a>

1. Navigate to **Project** -> **Settings** -> **Data Stores** > **Add Google Storage**
2. **Name**: usually makes sense to use the same name as the bucket name.
3. **Bucket**: the bucket name; “my-valohai-bucket” in this example.
4. **Service Account JSON**: copy-and-paste the contents of the JSON file we downloaded earlier.
5. When you create the store, the credentials provided will be checked by creating a small test file in the bucket. If the creation succeeds, you are good to go.
6. Once the data store is linked, you can set it as your project’s default upload store under **Settings** -> **General** -> **Default upload store.** This ensures that uploaded outputs will be stored in this particular GCP bucket by default.


---

# Agent Instructions: 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:

```
GET https://docs.valohai.com/data/configure-data-stores/google-bucket.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
