Google Cloud JSM Assets

Google Cloud JSM Assets

Google Cloud to JSM Assets Integration Guide

This guide explains how to use OnLink to import Google Cloud resources into JSM Assets, so anyone raising a JSM request can pick the affected project, VM or service account. It covers Google Cloud authentication, the API request, sample data, pagination, field mapping, validation, and import execution.

Overview

OnLink reads Google Cloud resources from the Cloud Asset Inventory API https://docs.cloud.google.com/asset-inventory/docs/reference/rest . One call returns every resource of a given type across the whole Google Cloud organization, so you don't need a separate request per project or zone.

Create one OnLink Assets Data Source per object type. All of them use the same service account and the same endpoint; only the assetTypes value changes. The examples in this guide use Service accounts and VM instances.

The integration uses OnLink mapping statements such as key: and map:, for values nested inside the Google Cloud response.

Google Cloud hierarchy and object types

Google Cloud organizes resources as Organization → Folders → Projects → resources. Build the Assets schema the same way and link each object to its parent with a reference attribute.

Resource hierarchy diagram

gcp-resource-hierarchy.png

 

The left side is the Google Cloud resource hierarchy, and the right side is the Assets object type each resource becomes. Users come from the Google Workspace or Cloud Identity account linked to the organization, and connect to projects through IAM role bindings.

Object types

Assets object type

Google Cloud resource

Source (assetTypes value or API)

References

Assets object type

Google Cloud resource

Source (assetTypes value or API)

References

GCP Organization

Organization

cloudresourcemanager.googleapis.com/Organization

None

GCP Folder

Folder

cloudresourcemanager.googleapis.com/Folder

Parent folder, Organization

GCP Project

Project

cloudresourcemanager.googleapis.com/Project

Folder, Organization, Billing account

GCP Service Account

Service account

iam.googleapis.com/ServiceAccount

Project

GCP Host

Sole-tenant node group

compute.googleapis.com/NodeGroup

Project

GCP VM Instance

Compute Engine instance

compute.googleapis.com/Instance

Project, Service account, Host

GCP Billing Account

Billing account

Cloud Billing API (billingAccounts.list)

None (projects reference it)

GCP User

Google Workspace or Cloud Identity user

Admin SDK Directory API (users.list)

Projects with access

Import parents before children: Organization, Folders, Billing accounts, Projects, then Service accounts, Hosts and VM instances. These are recommendations, you can define your asset schema and map only the objects you need from Google Cloud.

Prerequisites

  • Access to OnLink with permission to create or edit Assets Data Sources.

  • A JSM Assets schema with the object types above. The examples need at least GCP Project, GCP Service Account and GCP VM Instance.

  • A Google Cloud organization, and an administrator who can create a service account in a project and grant IAM roles at the organization level.

  • Google Cloud organization ID (see step 1.5).

Step 1: Set up Google Cloud authentication

OnLink authenticates as a Google Cloud service account. It signs a short-lived JWT with the service account's private key and exchanges it for an OAuth access token. Create the service account once and reuse it for every Google Cloud data source.

1.1 Choose a project and enable the APIs

  1. In the Google Cloud console, select an existing admin project or create one, for example onlink-assets-sync.

  2. Go to APIs & Services > Library and enable:

    • Cloud Asset API (cloudasset.googleapis.com)

    • Cloud Resource Manager API (cloudresourcemanager.googleapis.com)

    • Compute Engine API, only if you will import hosts

The APIs must be enabled in the project that owns the service account, even though the data comes from the whole organization.

1.2 Create the service account

  1. Go to IAM & Admin > Service Accounts and click Create service account.

  2. Set the name to onlink-assets-sync and the description to Read-only inventory sync for JSM Assets.

  3. Skip the optional project role grant and click Done. Access is granted at the organization in the next step.

  4. Copy the service account email, for example onlink-assets-sync@onlink-assets-sync.iam.gserviceaccount.com.

1.3 Grant read access at the organization

  1. In the console resource picker, select your organization, not a project.

  2. Go to IAM & Admin > IAM and click Grant access.

  3. Under New principals, enter the service account email.

  4. Add these roles:

    • Cloud Asset Viewer (roles/cloudasset.viewer): reads every resource type through Cloud Asset Inventory.

    • Browser (roles/browser): looks up the organization, folders and projects.

    • Compute Viewer (roles/compute.viewer): only if you will import hosts.

  5. Click Save. New grants can take a few minutes to apply.

The same grants with the gcloud CLI:

gcloud organizations add-iam-policy-binding ORG_ID \ --member="serviceAccount:onlink-assets-sync@PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/cloudasset.viewer" gcloud organizations add-iam-policy-binding ORG_ID \ --member="serviceAccount:onlink-assets-sync@PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/browser"

1.4 Create a JSON key

  1. Open the service account and go to the Keys tab.

  2. Click Add key > Create new key, select JSON, and click Create. The browser downloads the key file once.

  3. Keep the file open for step 2. OnLink uses client_email, private_key_id and private_key.

{ "type": "service_account", "project_id": "onlink-assets-sync", "private_key_id": "3f9c1e0b7d...", "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBg...\n-----END PRIVATE KEY-----\n", "client_email": "onlink-assets-sync@onlink-assets-sync.iam.gserviceaccount.com", "client_id": "104857362910283746512", "token_uri": "https://oauth2.googleapis.com/token" }

If key creation is blocked, the organization enforces the iam.managed.disableServiceAccountKeyCreation constraint. Google enforces it by default on organizations created on or after May 3, 2024. Ask an Organization Policy Administrator to allow key creation for the sync project, then retry.

Store the key only in OnLink, delete the downloaded file afterwards, and rotate the key according to your security policy.

1.5 Find the organization ID

Open the console resource picker and select the All tab; the ID appears next to the organization name. Or run:

gcloud organizations list

Use the numeric ID value, for example 34739118321, in the request URL.

1.6 How OnLink gets an access token

OnLink uses Google's JWT bearer flow. It builds the JWT below, signs it with the private key, posts it to the token URL, and receives an access token that it sends as Authorization: Bearer on each request.

Setting

Value

Setting

Value

Token URL

https://oauth2.googleapis.com/token

Grant type

urn:ietf:params:oauth:grant-type:jwt-bearer

Signing algorithm

RS256 with private_key; private_key_id goes in the kid header

iss

The service account email (client_email)

scope

https://www.googleapis.com/auth/cloud-platform

aud

https://oauth2.googleapis.com/token

iat / exp

Issue and expiry time in Unix seconds; exp can be at most one hour after iat

The token response includes access_token and expires_in (typically 3600 seconds). OnLink requests a new token when the current one expires.

Optional: test the service account before configuring OnLink

gcloud auth activate-service-account --key-file=onlink-key.json curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudasset.googleapis.com/v1/organizations/ORG_ID/assets?assetTypes=iam.googleapis.com/ServiceAccount&contentType=RESOURCE&pageSize=5"

A JSON response with an assets array confirms that the key, roles and API are set up. Switch gcloud back to your own account afterwards with gcloud config set account you@example.com.

Step 2: Configure the OnLink data source

  1. In OnLink, create a new Assets Data Source.

  2. Select the Google Cloud template.

  3. Enter the values from the JSON key file:

    • Client email: client_email

    • Private key ID: private_key_id

    • Private key: private_key, including the BEGIN and END lines

    • Token URL: https://oauth2.googleapis.com/token

  4. Set the scope to https://www.googleapis.com/auth/cloud-platform.

  5. Save the data source configuration.

Cloud Asset Inventory only accepts the cloud-platform scope. Read-only access comes from the IAM roles granted in step 1.3, not from the scope.

 

Step 3: Configure the API request

Configure a GET request to the Cloud Asset Inventory assets.list method. Each data source uses the same URL with its own assetTypes value.

  1. Set Method to GET.

  2. Set URL to the endpoint below, replacing {ORG_ID} with your organization ID.

  3. Set Response data path to assets.

  4. Add the query parameters listed below.

# Service accounts GET https://cloudasset.googleapis.com/v1/organizations/{ORG_ID}/assets?assetTypes=iam.googleapis.com/ServiceAccount&contentType=RESOURCE&pageSize=1000 # VM instances GET https://cloudasset.googleapis.com/v1/organizations/{ORG_ID}/assets?assetTypes=compute.googleapis.com/Instance&contentType=RESOURCE&pageSize=1000

Query parameter

Value

Purpose

Query parameter

Value

Purpose

assetTypes

iam.googleapis.com/ServiceAccount or compute.googleapis.com/Instance

The resource type this data source imports. Use the values from the object type table for other types.

contentType

RESOURCE

Returns the full resource metadata in resource.data. Without it, the API returns asset names only.

pageSize

1000

Maximum records per page. The default is 100.

readTime

Optional, RFC 3339 timestamp

Takes the snapshot at an earlier time, up to 35 days back.

 

Each record has the same shape for every type: name (the full resource name), assetType, resource.data (the same JSON the service's own API returns), resource.location, ancestors (project, folders, organization) and updateTime.

Step 4: Fetch and review sample data

  1. Save the connection.

  2. Run the data source to fetch sample values from Google Cloud.

  3. Confirm that the response contains the expected assets array.

  4. Review the returned JSON fields and compare them with your target JSM Assets attributes.

Sample response: Service account

{ "readTime": "2026-10-21T21:30:12.418Z", "assets": [ { "name": "//iam.googleapis.com/projects/acme-web-prod/serviceAccounts/105273648812345678901", "assetType": "iam.googleapis.com/ServiceAccount", "resource": { "version": "v1", "discoveryName": "ServiceAccount", "parent": "//cloudresourcemanager.googleapis.com/projects/464036093014", "location": "global", "data": { "name": "projects/acme-web-prod/serviceAccounts/web-runtime@acme-web-prod.iam.gserviceaccount.com", "projectId": "acme-web-prod", "uniqueId": "105273648812345678901", "email": "web-runtime@acme-web-prod.iam.gserviceaccount.com", "displayName": "Web runtime", "description": "Runs the storefront VMs", "oauth2ClientId": "105273648812345678901", "disabled": false } }, "ancestors": [ "projects/464036093014", "folders/634792535758", "organizations/34739118321" ], "updateTime": "2026-10-18T14:02:55.118Z" } ], "nextPageToken": "CiAKGjBpNDd2Nmlz..." }

Sample response: VM instance

{ "readTime": "2026-10-21T21:30:12.418Z", "assets": [ { "name": "//compute.googleapis.com/projects/acme-web-prod/zones/us-east1-b/instances/web-frontend-01", "assetType": "compute.googleapis.com/Instance", "resource": { "version": "v1", "discoveryName": "Instance", "parent": "//cloudresourcemanager.googleapis.com/projects/464036093014", "location": "us-east1-b", "data": { "id": "7415528837051936214", "name": "web-frontend-01", "status": "RUNNING", "zone": "https://www.googleapis.com/compute/v1/projects/acme-web-prod/zones/us-east1-b", "machineType": "https://www.googleapis.com/compute/v1/projects/acme-web-prod/zones/us-east1-b/machineTypes/e2-standard-4", "cpuPlatform": "Intel Broadwell", "creationTimestamp": "2026-04-02T09:14:51.203-07:00", "networkInterfaces": [ { "name": "nic0", "networkIP": "10.20.4.17", "accessConfigs": [ { "name": "External NAT", "type": "ONE_TO_ONE_NAT", "natIP": "34.73.112.45" } ] } ], "serviceAccounts": [ { "email": "web-runtime@acme-web-prod.iam.gserviceaccount.com", "scopes": ["https://www.googleapis.com/auth/cloud-platform"] } ], "labels": { "env": "prod", "team": "storefront" } } }, "ancestors": [ "projects/464036093014", "folders/634792535758", "organizations/34739118321" ], "updateTime": "2026-10-21T18:42:09.551Z" } ], "nextPageToken": "CiAKGjBpNDd2Nmlz..." }

Step 5: Configure pagination

Cloud Asset Inventory uses token-based pagination. Configure it in OnLink before running a full import so every record is retrieved.

  1. Open the pagination settings for the data source.

  2. Set the response field that holds the next page token to nextPageToken.

  3. Set the request query parameter that sends it back to pageToken. Keep all other query parameters the same on every page.

  4. Pagination stops when the response has no nextPageToken.

  5. Test the request with a small pageSize, such as 5, to confirm that OnLink fetches more than one page, then set it back to 1000.

 

Step 6: Configure the Assets import and mapping

After the data source connection is working, create the Assets import by following the JSM Assets Data Synchronization guide.

Use the fetched sample data to map Google Cloud fields to JSM Assets attributes. Each mapping uses the top-level name as the key:, because it is unique across Google Cloud. Values inside resource and ancestors use the jsonpath__ prefix, with .0 for the first array element.

6.1 Service account mapping (GCP Service Account)

OnLink mapping

Assets attribute

Attribute type

Description

OnLink mapping

Assets attribute

Attribute type

Description

key:name=Resource Name

Resource Name

Text

Full Cloud Asset name, such as //iam.googleapis.com/projects/acme-web-prod/serviceAccounts/1052…. Used to match and update existing objects.

map:resource.data.email=Email

Email

Text (label)

Service account email. Set it as the object label so it shows on requests.

map:resource.data.displayName=Display Name

Display Name

Text

Friendly name set by the account owner.

map:resource.data.uniqueId=Unique ID

Unique ID

Text

Numeric ID. It changes if the account is deleted and recreated with the same email.

map:resource.data.projectId=Project ID

Project ID

Text

Project ID as text, useful for searching.

map:resource.data.description=Description

Description

Textarea

Owner's description of what the account is for.

map:updateTime=Last Changed

Last Changed

DateTime

When Cloud Asset Inventory last recorded a change.

6.2 VM instance mapping (GCP VM Instance)

OnLink mapping

Assets attribute

Attribute type

Description

OnLink mapping

Assets attribute

Attribute type

Description

key:name=Resource Name

Resource Name

Text

Full Cloud Asset name, such as //compute.googleapis.com/projects/acme-web-prod/zones/us-east1-b/instances/web-frontend-01.

map:resource.data.name=Name

Name

Text (label)

VM name shown on requests.

map:resource.data.id=Instance ID

Instance ID

Text

Numeric instance ID assigned by Compute Engine.

map:resource.data.status=Status

Status

Status

Values include RUNNING, STOPPING, TERMINATED (stopped) and SUSPENDED.

map:resource.location=Zone

Zone

Text

Short zone name, such as us-east1-b.

map:resource.data.machineType=Machine Type

Machine Type

Text

Returned as a URL that ends in the machine type, such as …/machineTypes/e2-standard-4.

map:resource.data.cpuPlatform=CPU Platform

CPU Platform

Text

CPU platform reported by Compute Engine.

map:resource.data.labels.env=Environment

Environment

Text

Example label. Add one line per label key you want in Assets, such as team or owner.

map:updateTime=Last Changed

Last Changed

DateTime

When Cloud Asset Inventory last recorded a change.

The mapping tables list example fields. You can map any field in the response, as long as the corresponding Assets attribute exists.

Mapping guidance

  • Start with one unique key: mapping so OnLink can decide whether to create a new Assets object or update an existing one.

  • Run the Project import first, then Service accounts, then VM instances, so every reference finds its target.

  • A VM deleted and recreated with the same name keeps the same Resource Name, so it updates the existing object. Key on Instance ID instead if you want a new object each time.

  • GKE nodes and managed instance group VMs also appear as VM instances and change often. GKE nodes carry a goog-gke-node label, which you can use to filter or group them.

  • Confirm that every target Assets attribute exists and that spelling and case match the object type configuration.

Step 7: Validate and run the import

  1. Use Get Data to preview the records returned by Google Cloud.

  2. Confirm that the preview contains the expected service accounts or VMs and field values.

  3. Review the object type mapping and verify each target attribute name.

  4. Fix any missing fields, spelling differences, or data type issues.

  5. Run the import after the preview data and mappings are correct.

Troubleshooting checklist

  • If the token request fails with invalid_grant, verify the client email and private key (the full value with its BEGIN and END lines), confirm the key has not been deleted or disabled, and check that the OnLink server clock is correct.

  • If requests fail with PERMISSION_DENIED, confirm the roles were granted on the organization, not a project, and allow a few minutes for new grants to apply.

  • If the error says the Cloud Asset API has not been used or is disabled, enable it in the project that owns the service account.

  • If you cannot create a key, see the organization policy note in step 1.4.

  • If no records are returned, check the organization ID, the assetTypes spelling, contentType=RESOURCE, and the assets response data path.

  • If only the first 1,000 records arrive, review the nextPageToken and pageToken pagination settings.

  • If Assets objects are duplicated, confirm that key:name=Resource Name is configured.

  • If a Project or Runs As reference is empty, confirm the target object was imported first and that its Project Path or Email value matches.

  • If values do not appear in Assets, verify that each map: statement points to an existing Assets attribute.