Execute Google Cloud CLI Command
Overview
The Execute Google Cloud CLI Command action enables users to execute Google Cloud CLI commands directly from a bot workflow, providing streamlined access to Google Cloud resources. Users can input Google Cloud CLI commands manually or leverage AI to generate commands tailored to specific tasks.
Prerequisites
Linux Agent:
- Google Cloud SDK Installation: The Google Cloud SDK (
gcloud
) must be installed on the agent machine. - Configuration Profile: A configuration profile must be created in the agent's
config.yaml
file, withGOOGLE_APPLICATION_CREDENTIALS
set to the path of the Google service account JSON key file. - Installation Guide: Refer to the Google Cloud SDK installation guide for installation details.
How to Use This Action?
To use the Execute Google Cloud CLI Command action, follow these steps:
-
In the bot workflow, navigate to Linux Actions and select Library.
-
Search for or locate the Execute Google Cloud CLI Command action and drag it into your workflow.
-
Select the Linux integration connected to the agent configured with the Google Cloud CLI.
-
Under the Parameters section, enter the required values as described in the Parameter Details section.
-
In the
gcloud_cli_command
field, you can:- Manually Enter the Google Cloud CLI command you want to execute.
- Generate with AI: Click "Generate with AI" and input a prompt, such as "retrieve all storage buckets."
- Manually Enter the Google Cloud CLI command you want to execute.
-
Save or update the bot, then click Run to execute the bot or the Run button inside the action node. After execution, view results in the execution details.
Parameter Details
Parameter | Required | Description |
---|---|---|
gcloud_cli_command | Yes | The Google Cloud CLI command to execute. |
gcp_config_profile | Yes | Specifies the profile for loading Google Cloud credentials from config.yaml . This profile must include GOOGLE_APPLICATION_CREDENTIALS , pointing to the service account key path. For more information on the agent configuration file, refer to the Agent Installation Guide. |
run_as_user | Yes | Specifies the user under which the command runs (defaults to "ubuntu"). Set this to another user if needed. Ensure gcloud SDK is configured for the specified user. |
execution_timeout | Yes | Maximum time (in seconds) allowed for command execution, defaulting to 60 seconds. |
Example Use Case
Scenario: Listing Storage Buckets and Their Details
As a cloud administrator, you manage Google Cloud storage buckets across projects. You want a quick, organized list of all storage buckets in a project to review metadata like location, creation date, and labels.
Command to List All Storage Buckets with Details: Use the following command to retrieve a structured JSON list of all storage buckets in a specified project:
gcloud storage buckets list --project=my-gcp-project-id