Google Cloud (GCP) Client Authorization Configuration
The Script Market supports collecting cloud resources/cloud monitoring Metrics from GCP service accounts and reporting them to Guance/TrueWatch. Users can complete authorization by configuring service accounts.
One, Preliminary Work
Ensure that the following APIs are enabled for each project to be monitored:
- Cloud Resource Manager API
- Google Cloud Billing API
- Cloud Monitoring API
- Compute Engine API
- Cloud Asset API
- IAM API
Two, Create a Service Account
To collect GCP resources via Dataflux Func Script Market, you need to create a GCP service account in advance on the GCP platform.
Open your Google Cloud Console and navigate to IAM & Admin
/ Service accounts
.
Click Create service account
, enter Service account name
, click Create and continue.
Grant access permissions to the service account for the project:
- Monitoring Viewer
- Compute Viewer
- Cloud Asset Viewer
- Browser
Click Done, at this point, the service account you created will have all the permissions required to collect resources under the current project.
If you want to use this service account to collect resources from all projects within an organization, you can select the organization and grant access permissions to the service account in IAM & Admin
/ IAM
(permissions as above).
Three, Create a Service Account Key (Optional)
If your service account allows key creation (disable organizational policy restriction: iam.disableServiceAccountKeyCreation
):
- Click on the service account you just created.
- Select the
Keys
tab, clickAdd Key
-Create new key
, choose key type asJSON
, export the key for backup.
If your service account does not allow key creation, refer to the next item Service Account Impersonation
.
Four, Service Account Impersonation (Optional)
Service Account Impersonation, which allows external GCP service accounts to impersonate the functions of service accounts created on your GCP platform. Here we define two service accounts:
- Sovereign Service Account: The service account created above (this service account has actual permissions but cannot create keys).
- External Service Account: A service account from another GCP organization (can create keys).
Authorize the external service account:
- Click on the service account (sovereign service account) created above.
- Select menu
Principals with access
and clickGrant access
: Add principals
Enter the email address of the external service account,Assign roles
ChooseService Account Token Creator
At this point, the external delegated account can simulate the permissions of the service account of the resource collection platform, and perform the collection work.
Next, create a key for the externally delegated service account for backup.
Five, Script Market Collector Configuration
In the previous steps, we created the private key for the service account, now we can log in to the Dataflux Func platform to complete the configuration of the collector.
Upload Key to Dataflux Func File Management
- Enable file management module: On the «Manage» page, click «Experimental Features» «Enable File Management», refresh the page, file management will appear under «Experimental Features»
- Click «File Management» to upload the private key file
Copy out the full name of the private key file (including .json
). You can also place it in other directories, in which case you need to copy the path, e.g., /a/b/key_file.json
Install/Deploy Collector
Install Collector
Search for the required GCP services in the official script market and click install.
Deploy Collector
A configuration input box will pop up.
Input box introduction:
GCP Service Account File Name
: The file address of the service account key configuration file (the key address in file storage).GCP Service Account Email
: The email of the service account.GCP Service Account Private Key
: The private key of the service account.Target Principal
: When using service account impersonation, specify the email of the account to be simulated.Your Account Name
: Define a name for the service account.
Please fill in the input box according to how the key file is stored.
GCP Service Account File Name
, GCP Service Account Email
, GCP Service Account Private Key
-
When using «File Storage» to store the key file (recommended):
-
GCP Service Account File Name
: Input the key file address in file management. GCP Service Account Email
: Ignore.-
GCP Service Account Private Key
: Ignore. -
If not using file storage, you can directly copy out
private_key
andclient_email
from the private key file: -
GCP Service Account Email
: Input the value ofclient_email
. GCP Service Account Private Key
: Input the value ofprivate_key
.-
GCP Service Account File Name
: Ignore. -
In the Dataflux Func platform, configure the environment variable
GOOGLE_SERVICE_ACCOUNT_INFO
, copy the key file data into it (save as JSON type). -
GCP Service Account File Name
: Ignore. GCP Service Account Email
: Ignore.GCP Service Account Private Key
: Ignore.
Environment variables can only store one service account key, and it takes effect globally.
Please fill in the input box based on whether the service account is a delegated service account or not.
Target Principal
: Specify the email of the account to be simulated, if not needed, ignore.
Common Issues:
- Collector error:
name 'service_account' is not defined
, your Dataflux Func does not havegoogle-auth==2.38.0
installed (Dataflux Func GSE new versions come with default configurations). You can manually install it by copying it into thePIP tool
, or upgrade the Dataflux Func service.