Skip to content

DeadmanXXXII/GCP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

GCP

Here is a comprehensive list of Google Cloud Platform (GCP) CLI commands using gcloud, organized by their functionality. This list covers a variety of GCP services and operations.

Google Cloud CLI Commands

General Commands

  • Authenticate to Google Cloud:

    gcloud auth login
  • List available projects:

    gcloud projects list
  • Set the active project:

    gcloud config set project PROJECT_ID
  • Get current project:

    gcloud config get-value project
  • List available regions and zones:

    gcloud compute regions list
    gcloud compute zones list
  • Get gcloud CLI version:

    gcloud --version

Compute Engine

  • List all instances:

    gcloud compute instances list
  • Create a new instance:

    gcloud compute instances create INSTANCE_NAME --zone=ZONE --image-family=IMAGE_FAMILY --image-project=IMAGE_PROJECT
  • Start an instance:

    gcloud compute instances start INSTANCE_NAME --zone=ZONE
  • Stop an instance:

    gcloud compute instances stop INSTANCE_NAME --zone=ZONE
  • Delete an instance:

    gcloud compute instances delete INSTANCE_NAME --zone=ZONE --quiet
  • List available machine types:

    gcloud compute machine-types list --zones=ZONE

Cloud Storage

  • List all buckets:

    gcloud storage buckets list
  • Create a new bucket:

    gcloud storage buckets create BUCKET_NAME --location=LOCATION
  • Delete a bucket:

    gcloud storage buckets delete BUCKET_NAME
  • List objects in a bucket:

    gcloud storage objects list --bucket=BUCKET_NAME
  • Upload a file to a bucket:

    gcloud storage cp LOCAL_FILE gs://BUCKET_NAME/
  • Download a file from a bucket:

    gcloud storage cp gs://BUCKET_NAME/REMOTE_FILE LOCAL_FILE

Networking

  • List all VPC networks:

    gcloud compute networks list
  • Create a new VPC network:

    gcloud compute networks create NETWORK_NAME --subnet-mode=auto
  • Delete a VPC network:

    gcloud compute networks delete NETWORK_NAME
  • List all firewall rules:

    gcloud compute firewall-rules list
  • Create a new firewall rule:

    gcloud compute firewall-rules create RULE_NAME --allow tcp:80,tcp:443 --source-ranges 0.0.0.0/0 --target-tags TARGET_TAG
  • Delete a firewall rule:

    gcloud compute firewall-rules delete RULE_NAME

Cloud SQL

  • List all Cloud SQL instances:

    gcloud sql instances list
  • Create a new Cloud SQL instance:

    gcloud sql instances create INSTANCE_NAME --database-version=VERSION --tier=TIER --region=REGION
  • Delete a Cloud SQL instance:

    gcloud sql instances delete INSTANCE_NAME
  • List databases in a Cloud SQL instance:

    gcloud sql databases list --instance=INSTANCE_NAME
  • Create a new database in Cloud SQL:

    gcloud sql databases create DATABASE_NAME --instance=INSTANCE_NAME
  • Delete a database from Cloud SQL:

    gcloud sql databases delete DATABASE_NAME --instance=INSTANCE_NAME

App Engine

  • List all App Engine services:

    gcloud app services list
  • Deploy an App Engine application:

    gcloud app deploy
  • Delete an App Engine service:

    gcloud app services delete SERVICE_NAME
  • List all App Engine versions:

    gcloud app versions list
  • Stop an App Engine version:

    gcloud app versions stop VERSION_ID
  • Start an App Engine version:

    gcloud app versions start VERSION_ID

IAM (Identity and Access Management)

  • List all IAM roles:

    gcloud iam roles list
  • Create a new IAM role:

    gcloud iam roles create ROLE_NAME --title="TITLE" --permissions="PERMISSIONS" --stage="GA"
  • Delete an IAM role:

    gcloud iam roles delete ROLE_NAME
  • List all IAM policies for a resource:

    gcloud projects get-iam-policy PROJECT_ID
  • Set an IAM policy binding:

    gcloud projects add-iam-policy-binding PROJECT_ID --member='user:EMAIL' --role='roles/ROLE'
  • Remove an IAM policy binding:

    gcloud projects remove-iam-policy-binding PROJECT_ID --member='user:EMAIL' --role='roles/ROLE'

Kubernetes Engine (GKE)

  • List all GKE clusters:

    gcloud container clusters list
  • Create a new GKE cluster:

    gcloud container clusters create CLUSTER_NAME --zone=ZONE
  • Delete a GKE cluster:

    gcloud container clusters delete CLUSTER_NAME --zone=ZONE
  • Get credentials for a GKE cluster:

    gcloud container clusters get-credentials CLUSTER_NAME --zone=ZONE
  • List all Kubernetes pods in a cluster:

    kubectl get pods

BigQuery

  • List all datasets:

    bq ls
  • Create a new dataset:

    bq mk DATASET_NAME
  • Delete a dataset:

    bq rm -r -f DATASET_NAME
  • List tables in a dataset:

    bq ls DATASET_NAME
  • Create a new table:

    bq mk --table DATASET_NAME.TABLE_NAME SCHEMA
  • Delete a table:

    bq rm -f DATASET_NAME.TABLE_NAME
  • Run a query:

    bq query --use_legacy_sql=false 'QUERY'

Cloud Functions

  • List all Cloud Functions:

    gcloud functions list
  • Deploy a new Cloud Function:

    gcloud functions deploy FUNCTION_NAME --runtime RUNTIME --trigger-http --entry-point ENTRY_POINT
  • Delete a Cloud Function:

    gcloud functions delete FUNCTION_NAME
  • Invoke a Cloud Function:

    gcloud functions call FUNCTION_NAME --data '{"key":"value"}'

Cloud Pub/Sub

  • List all Pub/Sub topics:

    gcloud pubsub topics list
  • Create a new Pub/Sub topic:

    gcloud pubsub topics create TOPIC_NAME
  • Delete a Pub/Sub topic:

    gcloud pubsub topics delete TOPIC_NAME
  • List all Pub/Sub subscriptions:

    gcloud pubsub subscriptions list
  • Create a new Pub/Sub subscription:

    gcloud pubsub subscriptions create SUBSCRIPTION_NAME --topic=TOPIC_NAME
  • Delete a Pub/Sub subscription:

    gcloud pubsub subscriptions delete SUBSCRIPTION_NAME

Cloud Run

  • List all Cloud Run services:

    gcloud run services list
  • Deploy a new Cloud Run service:

    gcloud run deploy SERVICE_NAME --image gcr.io/PROJECT_ID/IMAGE --platform managed
  • Delete a Cloud Run service:

    gcloud run services delete SERVICE_NAME

Cloud Monitoring

  • List all monitoring dashboards:

    gcloud monitoring dashboards list
  • Create a new monitoring dashboard:

    gcloud monitoring dashboards create --title "DASHBOARD_TITLE" --config-file "DASHBOARD_CONFIG_FILE"
  • Delete a monitoring dashboard:

    gcloud monitoring dashboards delete DASHBOARD_ID
  • List all alert policies:

    gcloud monitoring alert-policies list
  • Create a new alert policy:

    gcloud monitoring alert-policies create --notification-channels=CHANNEL_ID --condition="CONDITION" --display-name="ALERT_POLICY_NAME"
  • Delete an alert policy:

    gcloud monitoring alert-policies delete ALERT_POLICY_ID

Cloud Logging

  • List all logs:

    gcloud logging logs list
  • Read logs from a specific log:

    gcloud logging read "logName=\"projects/PROJECT_ID/logs/LOG_NAME\"" --limit=LIMIT
  • Create a log-based metric:

    gcloud logging metrics create METRIC_NAME --description="DESCRIPTION" --filter="FILTER_EXPRESSION"
  • Delete a log-based metric:

    gcloud logging metrics delete METRIC_NAME

Cloud Identity-Aware Proxy (IAP)

  • List all IAP-secured resources:

    gcloud iap resources list
  • Get IAP policy for a resource:

    gcloud iap web services describe SERVICE_NAME
  • Set IAP policy for a resource:

    gcloud iap web services add-iam-policy-binding SERVICE_NAME --member='user:EMAIL' --role='roles/iap.httpsResourceAccessor'
  • Remove IAP policy for a resource:

    gcloud iap web services remove-iam-policy-binding SERVICE_NAME --member='user:EMAIL' --role='roles/iap.httpsResourceAccessor'

Cloud Build

  • List all build triggers:

    gcloud builds triggers list
  • Create a new build trigger:

    gcloud builds triggers create CLOUD_BUILD_TRIGGER --name=TRIGGER_NAME --repo-name=REPO_NAME --branch-pattern="BRANCH_PATTERN"
  • Delete a build trigger:

    gcloud builds triggers delete TRIGGER_NAME
  • Submit a build:

    gcloud builds submit --tag gcr.io/PROJECT_ID/IMAGE_NAME .

Cloud Dataproc

  • List all Dataproc clusters:

    gcloud dataproc clusters list
  • Create a new Dataproc cluster:

    gcloud dataproc clusters create CLUSTER_NAME --region=REGION --zone=ZONE
  • Delete a Dataproc cluster:

    gcloud dataproc clusters delete CLUSTER_NAME --region=REGION
  • Submit a Spark job to Dataproc:

    gcloud dataproc jobs submit spark --cluster=CLUSTER_NAME --region=REGION --class=CLASS_NAME --jars=JAR_FILE
  • List jobs in Dataproc:

    gcloud dataproc jobs list --region=REGION
  • Cancel a Dataproc job:

    gcloud dataproc jobs cancel JOB_ID --region=REGION

Cloud AI and ML

  • List all AI Platform models:

    gcloud ai models list
  • Create a new AI Platform model:

    gcloud ai models create MODEL_NAME
  • Delete an AI Platform model:

    gcloud ai models delete MODEL_NAME
  • Deploy a version of a model:

    gcloud ai versions create VERSION_NAME --model=MODEL_NAME --origin=MODEL_DIR
  • Delete a version of a model:

    gcloud ai versions delete VERSION_NAME --model=MODEL_NAME

Bigtable

  • List all Bigtable instances:

    gcloud bigtable instances list
  • Create a new Bigtable instance:

    gcloud bigtable instances create INSTANCE_NAME --cluster=CLUSTER_NAME --cluster-zone=ZONE --display-name="DISPLAY_NAME"
  • Delete a Bigtable instance:

    gcloud bigtable instances delete INSTANCE_NAME
  • List tables in a Bigtable instance:

    gcloud bigtable tables list --instance=INSTANCE_NAME
  • Create a new table in Bigtable:

    gcloud bigtable tables create TABLE_NAME --instance=INSTANCE_NAME
  • Delete a table in Bigtable:

    gcloud bigtable tables delete TABLE_NAME --instance=INSTANCE_NAME

Cloud Spanner

  • List all Spanner instances:

    gcloud spanner instances list
  • Create a new Spanner instance:

    gcloud spanner instances create INSTANCE_NAME --config=CONFIG_NAME --display-name="DISPLAY_NAME" --nodes=NUM_NODES
  • Delete a Spanner instance:

    gcloud spanner instances delete INSTANCE_NAME
  • List databases in a Spanner instance:

    gcloud spanner databases list --instance=INSTANCE_NAME
  • Create a new database in Spanner:

    gcloud spanner databases create DATABASE_NAME --instance=INSTANCE_NAME
  • Delete a database in Spanner:

    gcloud spanner databases delete DATABASE_NAME --instance=INSTANCE_NAME

Cloud Memorystore

  • List all Redis instances:

    gcloud redis instances list
  • Create a new Redis instance:

    gcloud redis instances create INSTANCE_NAME --size=SIZE --region=REGION
  • Delete a Redis instance:

    gcloud redis instances delete INSTANCE_NAME

Cloud Tasks

  • List all task queues:

    gcloud tasks queues list
  • Create a new task queue:

    gcloud tasks queues create QUEUE_NAME --max-dispatches-per-second=RATE
  • Delete a task queue:

    gcloud tasks queues delete QUEUE_NAME
  • List tasks in a queue:

    gcloud tasks tasks list --queue=QUEUE_NAME
  • Create a new task in a queue:

    gcloud tasks tasks create --queue=QUEUE_NAME --payload="PAYLOAD" --schedule-time="SCHEDULE_TIME"
  • Delete a task from a queue:

    gcloud tasks tasks delete TASK_ID --queue=QUEUE_NAME

Cloud Build Triggers

  • List all build triggers:

    gcloud builds triggers list
  • Create a new build trigger:

    gcloud builds triggers create github --name=TRIGGER_NAME --repo-owner=OWNER --repo-name=REPO --branch-pattern=BRANCH_PATTERN --build-config=BUILD_CONFIG
  • Delete a build trigger:

    gcloud builds triggers delete TRIGGER_NAME

Cloud Scheduler

  • List all scheduler jobs:

    gcloud scheduler jobs list
  • Create a new scheduler job:

    gcloud scheduler jobs create pubsub JOB_NAME --schedule="SCHEDULE" --time-zone="TIME_ZONE" --topic=TOPIC_NAME --message-body="MESSAGE_BODY"
  • Delete a scheduler job:

    gcloud scheduler jobs delete JOB_NAME

Cloud Run

  • List all Cloud Run services:

    gcloud run services list --platform managed
  • Deploy a new Cloud Run service:

    gcloud run deploy SERVICE_NAME --image gcr.io/PROJECT_ID/IMAGE_NAME --platform managed
  • Delete a Cloud Run service:

    gcloud run services delete SERVICE_NAME --platform managed
  • Get the URL for a Cloud Run service:

    gcloud run services describe SERVICE_NAME --platform managed --format 'value(status.url)'
  • List all revisions of a Cloud Run service:

    gcloud run revisions list --service SERVICE_NAME --platform managed

Cloud BigQuery

  • List all BigQuery datasets:

    bq ls
  • Create a new BigQuery dataset:

    bq mk DATASET_NAME
  • Delete a BigQuery dataset:

    bq rm -r -f DATASET_NAME
  • List all tables in a dataset:

    bq ls DATASET_NAME
  • Create a new table in BigQuery:

    bq mk --table DATASET_NAME.TABLE_NAME SCHEMA
  • Delete a table in BigQuery:

    bq rm -f DATASET_NAME.TABLE_NAME
  • Run a SQL query in BigQuery:

    bq query --use_legacy_sql=false 'QUERY'
  • Export a BigQuery table to Cloud Storage:

    bq extract --destination_format=FORMAT gs://BUCKET_NAME/FILE_NAME DATASET_NAME.TABLE_NAME
  • Load data into BigQuery from Cloud Storage:

    bq load --source_format=FORMAT DATASET_NAME.TABLE_NAME gs://BUCKET_NAME/FILE_NAME

Cloud Dataflow

  • List all Dataflow jobs:

    gcloud dataflow jobs list
  • Run a Dataflow job:

    gcloud dataflow jobs run JOB_NAME --gcs-location=GCS_TEMPLATE_PATH --parameters PARAMS
  • Cancel a Dataflow job:

    gcloud dataflow jobs cancel JOB_ID

Cloud Data Fusion

  • List all Data Fusion instances:

    gcloud datafusion instances list
  • Create a new Data Fusion instance:

    gcloud datafusion instances create INSTANCE_NAME --type=TYPE --location=LOCATION
  • Delete a Data Fusion instance:

    gcloud datafusion instances delete INSTANCE_NAME

Cloud Asset Inventory

  • Export asset inventory:

    gcloud asset export --content-type=CONTENT_TYPE --output-path=OUTPUT_PATH
  • List all asset types:

    gcloud asset types list
  • Search assets:

    gcloud asset search-all-resources --query="QUERY"

Cloud Security Command Center

  • List all security sources:

    gcloud scc sources list
  • List all security findings:

    gcloud scc findings list --source=SOURCE_NAME
  • Create a new security source:

    gcloud scc sources create SOURCE_NAME --display-name="DISPLAY_NAME"
  • Delete a security source:

    gcloud scc sources delete SOURCE_NAME

Cloud Support

  • Create a new support case:

    gcloud support cases create --subject="SUBJECT" --description="DESCRIPTION"
  • List all support cases:

    gcloud support cases list
  • Get details about a support case:

    gcloud support cases describe CASE_ID
  • Update a support case:

    gcloud support cases update CASE_ID --status=STATUS --description="DESCRIPTION"

Cloud Deployment Manager

  • List all deployment configurations:

    gcloud deployment-manager deployments list
  • Create a new deployment:

    gcloud deployment-manager deployments create DEPLOYMENT_NAME --config CONFIG_FILE
  • Delete a deployment:

    gcloud deployment-manager deployments delete DEPLOYMENT_NAME
  • Update a deployment:

    gcloud deployment-manager deployments update DEPLOYMENT_NAME --config CONFIG_FILE
  • Get details about a deployment:

    gcloud deployment-manager deployments describe DEPLOYMENT_NAME

Cloud Resource Manager

  • List all organizations:

    gcloud organizations list
  • List all folders:

    gcloud resource-manager folders list
  • Create a new folder:

    gcloud resource-manager folders create --display-name="DISPLAY_NAME"
  • Delete a folder:

    gcloud resource-manager folders delete FOLDER_ID
  • List all projects:

    gcloud projects list
  • Create a new project:

    gcloud projects create PROJECT_ID --name="PROJECT_NAME"
  • Delete a project:

    gcloud projects delete PROJECT_ID
  • Get details about a project:

    gcloud projects describe PROJECT_ID
  • Add an IAM policy binding to a project:

    gcloud projects add-iam-policy-binding PROJECT_ID --member='user:EMAIL' --role='roles/ROLE'
  • Remove an IAM policy binding from a project:

    gcloud projects remove-iam-policy-binding PROJECT_ID --member='user:EMAIL' --role='roles/ROLE'

Cloud Network Security

  • List all SSL certificates:

    gcloud compute ssl-certificates list
  • Create a new SSL certificate:

    gcloud compute ssl-certificates create CERTIFICATE_NAME --certificate=CERT_FILE --private-key=KEY_FILE
  • Delete an SSL certificate:

    gcloud compute ssl-certificates delete CERTIFICATE_NAME
  • List all target HTTP proxies:

    gcloud compute target-http-proxies list
  • Create a new target HTTP proxy:

    gcloud compute target-http-proxies create PROXY_NAME --url-map=URL_MAP_NAME
  • Delete a target HTTP proxy:

    gcloud compute target-http-proxies delete PROXY_NAME

Cloud Endpoints

  • List all API services:

    gcloud endpoints services list
  • Deploy an API configuration:

    gcloud endpoints services deploy CONFIG_FILE
  • Delete an API service:

    gcloud endpoints services delete SERVICE_NAME
  • Get details about an API service:

    gcloud endpoints services describe SERVICE_NAME

Cloud Key Management Service (KMS)

  • List all key rings:

    gcloud kms keyrings list --location=LOCATION
  • Create a new key ring:

    gcloud kms keyrings create KEY_RING_NAME --location=LOCATION
  • Delete a key ring:

    gcloud kms keyrings delete KEY_RING_NAME --location=LOCATION
  • List all keys in a key ring:

    gcloud kms keys list --keyring=KEY_RING_NAME --location=LOCATION
  • Create a new key:

    gcloud kms keys create KEY_NAME --keyring=KEY_RING_NAME --location=LOCATION --purpose=PURPOSE
  • Delete a key:

    gcloud kms keys delete KEY_NAME --keyring=KEY_RING_NAME --location=LOCATION
  • List all key versions:

    gcloud kms keys versions list --key=KEY_NAME --keyring=KEY_RING_NAME --location=LOCATION
  • Create a new key version:

    gcloud kms keys versions create --key=KEY_NAME --keyring=KEY_RING_NAME --location=LOCATION
  • Destroy a key version:

    gcloud kms keys versions destroy VERSION_NAME --key=KEY_NAME --keyring=KEY_RING_NAME --location=LOCATION

This list covers a wide range of GCP services and operations, providing commands for managing various aspects of Google Cloud Platform using the gcloud CLI tool.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published