GCloud plugin use cases

2 minute readExtensibilityDeveloper productivity

The following examples illustrate how you can replace gcloud CLI commands with the GCloud plugin.

Display information about the current Google Cloud environment

In the gcloud CLI tool, you can issue the gcloud info group of commands to display information about the current environment. For more information, refer to the gcloud documentation.

gcloud info --format="json(basic,tools)" --anonymize

If using the GCloud plugin to retrieve this information, add the following parameter values to the Run Custom Command procedure:

  • Group of commands: info

  • Options: --format="json(basic,tools)", --anonymize

    Figure 1. gcloud info parameters
    Figure 1. gcloud info parameters

    If successful, it should return an output similar to the following:

    {
      "basic": {
        "architecture": {
          "file_name": "x86_64",
          "id": "x86_64",
          "name": "x86_64"
        },
        "locale": [
          "en_US",
          "UTF-8"
        ],
        "operating_system": {
          "file_name": "linux",
          "id": "LINUX",
          "name": "Linux"
        },
        "python_location": "/usr/bin/python3",
        "python_version": "3.8.10 (default, Sep 28 2021, 16:10:42) \n[GCC 9.3.0]",
        "site_packages": false,
        "version": "366.0.0"
      },
      "tools": {
        "git_version": "git version 2.25.1",
        "ssh_version": "OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f  31 Mar 2020"
      }
    }

Describe a virtual machine instance

In the gcloud CLI tool, you can issue the gcloud compute group of commands to describe a virtual instance. For more information, refer to the gcloud documentation.

gcloud compute instances describe test-instance --format="yaml(name,status,disks)"

If using the GCloud plugin to retrieve this information, add the following parameter values to the Run Custom Command procedure:

  • Group of commands: compute

  • Command: instances

  • Sub-commands: describe, test-instance

  • Options: --format="yaml(name,status,disks)"

    Figure 2. gcloud compute parameters
    Figure 2. gcloud compute parameters

    If successful, it should return an output similar to the following:

    disks:
    - autoDelete: true
      boot: true
      deviceName: persistent-disk-0
      diskSizeGb: '10'
      guestOsFeatures:
      - type: UEFI_COMPATIBLE
      - type: VIRTIO_SCSI_MULTIQUEUE
      index: 0
      interface: SCSI
      kind: compute#attachedDisk
      licenses:
      - https://www.googleapis.com/compute/v1/projects/debian-cloud/global/licenses/debian-10-buster
      mode: READ_WRITE
      source: https://www.googleapis.com/compute/v1/projects/my-test-project/zones/us-east1-b/disks/test-instance
      type: PERSISTENT
    name: test-instance
    status: RUNNING