Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Latest commit

 

History

History

90_more_commands

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Commands

A few commands that will help you with your work.

Images

List all Google Compute Engine images:

gcloud compute images list

Filter family:

gcloud compute images list --filter='family ~ debian-10$'
gcloud compute images list --filter='family ~ sles-15$'
gcloud compute images list --filter='family ~ sles-15-sp3-sap$'
gcloud compute images list --filter='family ~ windows-2019$'

Services

Help

Return the services which the project has enabled:

gcloud services list --enabled

Return the services available to the project to enable. This list will include any services that the project has already enabled:

gcloud services list --available

Example:

compute.googleapis.com               Compute Engine API
dns.googleapis.com                   Cloud DNS API
logging.googleapis.com               Cloud Logging API
monitoring.googleapis.com            Cloud Monitoring API
storage.googleapis.com               Cloud Storage API

Roles

Help

List the roles defined at a parent organization or a project:

gcloud iam roles list

Example:

---
description: Full control of Compute Engine networking resources.
etag: AA==
name: roles/compute.networkAdmin
stage: GA
title: Compute Network Admin

IAM policy

Help

Get IAM policy (roles) for service account:

gcloud projects get-iam-policy <MY_GCP_PROJECT> \
  --flatten='bindings[].members' \
  --format='table(bindings.role)' \
  --filter=bindings.members:<MY_GCP_SA_ID>

Example for service account sa-sap-cal-demo-1@sap-sandbox-demo-1.iam.gserviceaccount.com in project sap-sandbox-demo-1:

gcloud projects get-iam-policy sap-sandbox-demo-1 \
  --flatten='bindings[].members' \
  --format='table(bindings.role)' \
  --filter=bindings.members:sa-sap-cal-demo-1@sap-sandbox-demo-1.iam.gserviceaccount.com

Example:

ROLE
roles/compute.instanceAdmin.v1
roles/compute.networkAdmin
roles/compute.securityAdmin

Compute Engine disk types

To list all disk types in a project in table form, run:

gcloud compute disk-types list

To list all disk types in the europe-north1-c zone, run:

gcloud compute disk-types list \
  --filter="zone:europe-north1-c"