> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/g/google-cloud-services.md).

# Google Cloud Services

Google Cloud Services collects resources of one project across several Google Cloud APIs. OctoXLabs adds each resource as a service with its type and deployment status.

## Use cases

* List every Google Cloud resource that OctoXLabs collected as a service.

```
Adapters = google-cloud-services
```

* Check what one Google Cloud Services connection collected.

```
Connections = YOUR_CONNECTION_NAME
```

## Before you begin

### Network

| Source              | Destination                                                                                                                                                                              | Port | Protocol |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | -------- |
| OctoXLabs connector | oauth2.googleapis.com                                                                                                                                                                    | 443  | HTTPS    |
| OctoXLabs connector | compute.googleapis.com, vpcaccess.googleapis.com, sqladmin.googleapis.com, cloudfunctions.googleapis.com, networkconnectivity.googleapis.com, logging.googleapis.com, iam.googleapis.com | 443  | HTTPS    |

The port is not set in the connector code; HTTPS URLs use the default port 443.

### Required permissions

| Scope or role                   | Permission | Needed for                                    |
| ------------------------------- | ---------- | --------------------------------------------- |
| compute.instances.list          | List       | Virtual machines                              |
| vpcaccess.connectors.list       | List       | VPC access connectors (virtual network links) |
| cloudsql.instances.list         | List       | Cloud SQL instances (databases)               |
| cloudfunctions.functions.list   | List       | Cloud Functions                               |
| networkconnectivity.spokes.list | List       | Network Connectivity spokes (network manager) |
| logging.buckets.list            | List       | Log buckets (object storage)                  |
| iam.serviceAccounts.list        | List       | Service accounts (identity)                   |

The connector requests the OAuth scope `https://www.googleapis.com/auth/cloud-platform`. A resource type that fails with an API error is logged and skipped, and the other types are still collected.

## Create credentials in Google Cloud Services

{% stepper %}
{% step %}

### Create a service account

Open [IAM & Admin > Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts), select the project, then use an existing service account or select **Create Service Account**. Copy the email shown in the list.
{% endstep %}

{% step %}

### Grant the permissions

Give the service account a role that includes the permissions in the table above, for example through a custom role.
{% endstep %}

{% step %}

### Create a JSON key

Open the service account, go to the **Keys** tab, select **Add key** > **Create new key**, choose **JSON** and select **Create**. Upload the file in the Service Account Key File parameter.
{% endstep %}

{% step %}

### Find the project ID

Copy the Project ID, not the project name, from the project picker or from **Home** > **Dashboard** > **Project info**.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
The key file is the only copy of the private key. Store it securely. If it is lost, create a new key.
{% endhint %}

## Connection parameters

| Parameter                | Required | Type   | Default | Description                                                                                                                  |
| ------------------------ | -------- | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| Service account email    | Yes      | String | None    | Email address of the service account.                                                                                        |
| Service account key file | Yes      | File   | None    | The JSON key file of the service account.                                                                                    |
| Zone                     | No       | String | None    | Compute Engine zone, for example `us-central1-a`. The connector code does not use it; resources are listed across all zones. |
| Project id               | Yes      | String | None    | The project ID, for example `my-prod-123456`.                                                                                |

## Troubleshooting

| Error message                                         | Cause                                                                               | Fix                                                                            |
| ----------------------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| 403 Forbidden (the connector raises the API response) | The service account lacks the list permission for a resource type.                  | Grant the permission from the table. Other resource types are still collected. |
| Error occurred during fetch services                  | An API call for one resource type failed. The connector logs the URL and continues. | Check the permission and that the API is enabled in the project.               |
| Unexpected error during fetch services                | Unexpected failure for one resource type.                                           | Check the connector log.                                                       |

## Change history
