Onboard GCP projects and organizations with a Python script

You can use a custom Python script (onboard.py) to programmatically create and configure GCP resources required for Rapid7 to collect data from your environment. The script automates service account creation, IAM role configuration, and permission assignments. If you would prefer an alternative onboarding method, review GCP Overview & Support.

Prerequisites

CLI and software:

  • Python 3.10 or greater
  • GCP CLI installed and configured (gcloud command available)

General:

  • Appropriate GCP permissions:
    • Project scope:
      • Owner role or Editor, Project IAM Admin, and Service Account Admin roles
    • Organization scope:
      • Organization Admin role or Organization Viewer, Project IAM Admin, and Service Account Admin roles
  • Access to one or more GCP projects
  • Cloud Security Domain or Organization Admin permissions
  • Cloud Security administrative permissions
Not sure if you have the correct GCP permissions?

You can use the script to check your GCP permissions. Review Common script use cases for details.

Key script terminology

Before you begin, review the core concepts used in GCP onboarding:

  • Service Account: A service account is a special type of Google account intended to represent a non-human user that needs to authenticate and be authorized to access data in Google APIs.
  • IAM Custom Roles: Custom IAM roles allow you to bundle one or more supported permissions to meet your specific needs. Unlike predefined roles, custom roles are defined at the organization or project level.
  • Role Assignment Scope:
    • Project: Monitors a single GCP project
    • Organization: Monitors all projects within a GCP organization
  • JSON Key Files: Service account authentication uses JSON key files that contain credentials. These keys should be stored securely and rotated regularly.

Download the script and connect accounts

You can configure and download the script in the Cloud Security Add Cloud Account interface. Adjusting configuration details changes parameters inside the script, which affects role definitions, permissions, and deployment scope.

Need to adjust configuration details?

If you need a new configuration, Rapid7 recommends using the Add Cloud Account interface to generate and download a new script.

Script reference

The onboarding script includes multiple options to customize or validate deployments. Use the help flag for the most up-to-date options:

python onboard.py --help
Many script options are pre-configured

Some options (like --organization-harvesting) may be pre-configured using environment variables (CHOSEN_ parameters) when generated from the platform.

Common script use cases

The most common use cases for the script (Download the script and connect accounts) are as follows:

Advanced Usage

Troubleshooting