# Google Cloud Storage

- Updated on Nov 12, 2024
- Published on Nov 5, 2024

- 1 minute(s) read

In this article, you will learn how to configure Google Cloud Storage (GCS) if you are running Hyperscience on Google Cloud Platform (GCP).

## GCS Setup

The steps required to set up Google Cloud Storage depend on which version of Hyperscience you are using.

### v40.1 and later

1. Create a bucket in GCS, or designate a prefix in an existing bucket.

2. On the [Roles (opens in new tab)](https://console.cloud.google.com/iam-admin/roles) page of the Google Cloud console, create an IAM role with the following permissions:

```plaintext
storage.multipartUploads.abort
storage.multipartUploads.create
storage.multipartUploads.list
storage.objects.create
storage.objects.delete
storage.objects.get
storage.objects.list
```

3. On the [Service Accounts (opens in new tab)](https://console.cloud.google.com/projectselector2/iam-admin/serviceaccounts?supportedpurview=project) page of the Google Cloud console, create a service account to be used by the Hyperscience application.

4. Assign the role you created in step 2 to the service account with the following IAM conditions:

- **Condition type** — Name
   
   - **Operator** — Starts with
   
   - **Value** depends on whether you want to put files under a prefix or at the root of the bucket:
   
     - If files will be stored at bucket’s root:
       
       - _Value = projects/_/buckets//objects/_
     - If files will be stored under a prefix:
       
       - _Value = projects/_/buckets//objects//_

5. Generate and download the service account key in JSON format. Add the Base64 representation of the contents to the in the “.env” file by adding the following variable and value:

```bash
FILE_STORE_GOOGLE_CLOUD_KEY=<base_64_sa_json_file>
```

6. Add the following variables to the “.env” file:

```bash
FORMS_STORAGE_MODE=GCS
FILE_STORE_GCS_BUCKET=<bucket_name>
IMAGE_STORAGE_GCS_KEY_PREFIX=</parent_prefix_name/prefix_name/>
```

### v40.0 and earlier

Follow the steps below to set up your Google Cloud Storage.

1. Create a bucket in GCS, or designate a prefix in an existing bucket.

4. Assign the role you created in step 2 to the service account with the following IAM conditions:

5. Create an HMAC key for the service account.

- Learn more in Google’s [Manage HMAC keys for service accounts (opens in new tab)](https://cloud.google.com/storage/docs/authentication/managing-hmackeys).

6. Enter the created HMAC key’s Access Key and Secret in the “.env” file as values for _FILE_STORE_S3_ACCESS_ID_ and _FILE_STORE_S3_ACCESS_KEY,_ respectively.

- Note that the Access Key is **not** the value for _FILE_STORE_S3_ACCESS_KEY_.

7. Add the following variables to the “.env” file:

```bash
FORMS_STORAGE_MODE=S3
FILE_STORE_S3_BUCKET=<bucket_name>
FILE_STORE_S3_ENDPOINT_URL=https://storage.googleapis.com
```

8. If storing files under a prefix, add the following variable to the “.env” file:

```bash
FILE_STORE_S3_KEY_PREFIX=</parent_folder_name/folder_name/>
```
