Google Cloud Asset Inventory is a powerful input component that enables the collection and ingestion of asset data from Google Cloud Platform environments. It provides comprehensive visibility into cloud resources across organizations, folders, and projects. The component supports scanning various asset types and can be configured to run on a scheduled basis. It is compatible with both organization and project-level scanning, making it suitable for both enterprise-wide and project-specific asset inventory needs.
Sync Type: Full Synchronisation
Requirements
Required Permissions
Cloud Asset Viewer role (roles/cloudasset.viewer)
Security Reviewer role (roles/iam.securityReviewer)
Organization Viewer role (optional, for org hierarchy information)
IAM permissions
Setting up IAM permissions in GCP can be complicated. However, we can greatly simplify the setup of a service account by using the gcloud cli tool, which is also available in the web console.
Code
# Set your variables#projectID is the full name of your project, including the numerical value if applicableexport PROJECT_ID="your-project-id"export SERVICE_ACCOUNT_NAME="asset-inventory-scanner"export SERVICE_ACCOUNT_DISPLAY_NAME="Cloud Asset Inventory Scanner"export ORGANIZATION_ID="your-org-id"# Create the service accountgcloud iam service-accounts create $SERVICE_ACCOUNT_NAME \ --project=$PROJECT_ID \ --display-name="$SERVICE_ACCOUNT_DISPLAY_NAME" \ --description="Service account for Cloud Asset Inventory scanning"# Get the service account emailexport SERVICE_ACCOUNT_EMAIL="${SERVICE_ACCOUNT_NAME}@${PROJECT_ID}.iam.gserviceaccount.com"# Grant required rolesgcloud organizations add-iam-policy-binding ${ORGANIZATION_ID} \ --member="serviceAccount:${SERVICE_ACCOUNT_EMAIL}" \ --role="roles/cloudasset.viewer"gcloud organizations add-iam-policy-binding ${ORGANIZATION_ID} \ --member="serviceAccount:${SERVICE_ACCOUNT_EMAIL}" \ --role="roles/iam.securityReviewer"gcloud organizations add-iam-policy-binding ${ORGANIZATION_ID} \ --member="serviceAccount:${SERVICE_ACCOUNT_EMAIL}" \ --role="roles/resourcemanager.organizationViewer"# Create and download the keygcloud iam service-accounts keys create asset-inventory-key.json \ --project=$PROJECT_ID \ --iam-account=${SERVICE_ACCOUNT_EMAIL}
Configuration Options
Settings
Setting
Type
Required
Description
resource_names
[]string
Yes
The names of the resources to scan (organizations, projects or folders). resource names must be in the follow format "organizations/[organization-number]" (such as "organizations/123"), "projects/[project-id]" (such as "projects/my-project-id"), "projects/[project-number]" (such as "projects/12345"), or "folders/[folder-number]" (such as "folders/12345")