gcloud init
考試
初始化 gcloud CLI,設定帳號和專案
gcloud init
依場景分類的 Google Cloud 命令列工具快查
gcloud [GROUP] [SUBGROUP] [ACTION] [RESOURCE] [--flags] gcloud compute instances create my-vm --zone=us-central1-a | Flag | 說明 |
|---|---|
--project=PROJECT_ID | 指定目標專案 |
--region=REGION | 指定區域(如 us-central1) |
--zone=ZONE | 指定可用區(如 us-central1-a) |
--format=FORMAT | 輸出格式:json / yaml / table / csv / value |
--filter=EXPRESSION | 篩選結果(如 "name:my-*") |
--quiet / -q | 跳過所有互動提示,適合腳本自動化 |
--verbosity=LEVEL | 日誌等級:debug / info / warning / error |
--account=ACCOUNT | 指定操作使用的帳號 |
gcloud init
考試
初始化 gcloud CLI,設定帳號和專案
gcloud init
gcloud auth login
考試
以互動方式登入 Google 帳號
gcloud auth login --no-launch-browser
--no-launch-browser 適用於無 GUI 環境(SSH 連線) gcloud auth application-default login
考試
設定 Application Default Credentials (ADC)
gcloud auth application-default login
gcloud config set
考試
設定 gcloud CLI 預設屬性
gcloud config set project my-project-id
gcloud config list 列出當前所有設定值
gcloud config list --format='table(core.project, compute.region, compute.zone)'
--all 列出所有屬性(含未設定的) gcloud config configurations create
考試
建立新的命名設定檔
gcloud config configurations create my-dev-config
gcloud config configurations activate
考試
切換到指定的設定檔
gcloud config configurations activate my-prod-config
gcloud config configurations list 列出所有設定檔及其啟用狀態
gcloud config configurations list
gcloud components install 安裝額外的 gcloud CLI 元件
gcloud components install kubectl
gcloud components update 更新所有已安裝的 gcloud CLI 元件
gcloud components update
gcloud info 顯示 gcloud CLI 安裝資訊和環境診斷
gcloud info --format='value(config.account)'
gcloud projects create
考試
建立新的 GCP 專案
gcloud projects create my-new-project --name="My Project" --folder=123456789
--name 專案顯示名稱 --folder 放置在指定資料夾下 --organization 放置在指定組織下 gcloud projects list 列出你有存取權限的所有專案
gcloud projects list --filter='lifecycleState=ACTIVE' --format='table(projectId, name)'
--filter 篩選條件 gcloud projects describe 檢視特定專案的詳細資訊
gcloud projects describe my-project-id
gcloud projects delete
考試
刪除專案(30 天內可復原)
gcloud projects delete my-old-project
gcloud services enable
考試
啟用指定的 API 服務
gcloud services enable compute.googleapis.com container.googleapis.com
gcloud services disable 停用指定的 API 服務
gcloud services disable compute.googleapis.com
--force 強制停用(即使有相依資源) gcloud services list 列出已啟用的 API 服務
gcloud services list --enabled --filter='name:compute'
--enabled 只列出已啟用的 --available 列出所有可用的 gcloud billing accounts list
考試
列出你可存取的帳單帳戶
gcloud billing accounts list
gcloud billing projects link
考試
將專案連結到帳單帳戶
gcloud billing projects link my-project --billing-account=0X0X0X-0X0X0X-0X0X0X
--billing-account 帳單帳戶 ID gcloud compute instances create
考試
建立 Compute Engine VM 執行個體
gcloud compute instances create my-vm --zone=us-central1-a --machine-type=e2-medium --image-family=debian-12 --image-project=debian-cloud
--machine-type 機型(e2-micro, n2-standard-4 等) --image-family OS 映像檔家族 --boot-disk-size 開機碟大小(如 50GB) --tags 網路標記(用於防火牆規則) --preemptible / --spot 建立搶佔式 / Spot VM --service-account 指定服務帳號 gcloud compute instances list 列出所有 VM 執行個體
gcloud compute instances list --filter='status=RUNNING' --format='table(name, zone, machineType.basename(), status)'
--filter 篩選條件 --zones 限定特定 zone gcloud compute instances describe 檢視特定 VM 的詳細資訊
gcloud compute instances describe my-vm --zone=us-central1-a
gcloud compute instances start 啟動已停止的 VM
gcloud compute instances start my-vm --zone=us-central1-a
gcloud compute instances stop
考試
停止執行中的 VM
gcloud compute instances stop my-vm --zone=us-central1-a
gcloud compute instances delete 刪除 VM 執行個體
gcloud compute instances delete my-vm --zone=us-central1-a --delete-disks=all
--delete-disks 連同刪除的磁碟類型:all / boot / data --keep-disks 保留的磁碟類型 gcloud compute instances add-tags
考試
為 VM 新增網路標記
gcloud compute instances add-tags my-vm --tags=http-server,https-server --zone=us-central1-a
--tags 逗號分隔的標記清單 gcloud compute instances remove-tags 移除 VM 的網路標記
gcloud compute instances remove-tags my-vm --tags=http-server --zone=us-central1-a
gcloud compute ssh
考試
SSH 連線到 VM
gcloud compute ssh my-vm --zone=us-central1-a --tunnel-through-iap
--tunnel-through-iap 透過 IAP 通道連線(不需外部 IP) --command 連線後直接執行命令 --ssh-key-file 指定 SSH 金鑰 gcloud compute scp 在本地和 VM 之間傳輸檔案
gcloud compute scp local-file.txt my-vm:~/remote-file.txt --zone=us-central1-a
--recurse 遞迴複製目錄 gcloud compute disks create
考試
建立獨立磁碟
gcloud compute disks create my-disk --size=100GB --type=pd-ssd --zone=us-central1-a
--size 磁碟大小 --type 磁碟類型:pd-standard / pd-balanced / pd-ssd gcloud compute disks snapshot
考試
建立磁碟快照
gcloud compute disks snapshot my-disk --snapshot-names=my-snap --zone=us-central1-a
--snapshot-names 快照名稱 gcloud compute images create
考試
從磁碟或快照建立自訂映像檔
gcloud compute images create my-image --source-disk=my-vm --source-disk-zone=us-central1-a
--source-disk 來源磁碟 --source-snapshot 來源快照 --family 映像檔家族名稱 gcloud compute instance-templates create
考試
建立執行個體範本
gcloud compute instance-templates create my-template --machine-type=e2-medium --image-family=debian-12 --image-project=debian-cloud --tags=http-server
--machine-type 機型 --image-family OS 映像檔家族 --metadata-from-file 啟動腳本等 metadata gcloud compute instance-groups managed create
考試
建立受管理的執行個體群組 (MIG)
gcloud compute instance-groups managed create my-mig --template=my-template --size=3 --zone=us-central1-a
--template 使用的執行個體範本 --size 初始執行個體數量 --health-check 健康檢查 gcloud compute instance-groups managed set-autoscaling
考試
設定 MIG 自動擴展策略
gcloud compute instance-groups managed set-autoscaling my-mig --max-num-replicas=10 --min-num-replicas=2 --target-cpu-utilization=0.6 --zone=us-central1-a
--max-num-replicas 最大執行個體數 --min-num-replicas 最小執行個體數 --target-cpu-utilization 目標 CPU 使用率(0~1) --cool-down-period 冷卻期秒數 gcloud container clusters create
考試
建立 GKE 叢集
gcloud container clusters create my-cluster --zone=us-central1-a --num-nodes=3 --machine-type=e2-medium --enable-autoscaling --min-nodes=1 --max-nodes=5
--num-nodes 每個 zone 的節點數 --machine-type 節點機型 --enable-autoscaling 啟用節點自動擴展 --enable-ip-alias 啟用 VPC-native(建議) --mode=autopilot 建立 Autopilot 叢集 gcloud container clusters get-credentials
考試
取得叢集憑證並設定 kubectl
gcloud container clusters get-credentials my-cluster --zone=us-central1-a
gcloud container clusters list 列出所有 GKE 叢集
gcloud container clusters list
gcloud container clusters resize 調整叢集節點數量
gcloud container clusters resize my-cluster --num-nodes=5 --zone=us-central1-a
--num-nodes 目標節點數 --node-pool 指定節點池 gcloud container clusters update 更新叢集設定
gcloud container clusters update my-cluster --enable-autoscaling --min-nodes=1 --max-nodes=10 --zone=us-central1-a
--enable-autoscaling 啟用節點自動擴展 --enable-network-policy 啟用網路政策 gcloud container clusters delete 刪除 GKE 叢集
gcloud container clusters delete my-cluster --zone=us-central1-a --quiet
gcloud container node-pools create
考試
建立新的節點池
gcloud container node-pools create gpu-pool --cluster=my-cluster --machine-type=n1-standard-4 --accelerator=type=nvidia-tesla-t4,count=1 --num-nodes=1 --zone=us-central1-a
--cluster 目標叢集 --machine-type 節點機型 --accelerator GPU 加速器設定 --enable-autoscaling 啟用自動擴展 gcloud container node-pools delete 刪除節點池
gcloud container node-pools delete gpu-pool --cluster=my-cluster --zone=us-central1-a
gcloud container images list 列出 Container Registry 中的映像檔
gcloud container images list --repository=gcr.io/my-project
--repository 指定倉庫路徑 gcloud container clusters create-auto
考試
建立 Autopilot 叢集(簡化指令)
gcloud container clusters create-auto my-autopilot --region=us-central1
--region 區域(Autopilot 叢集是區域性的) gcloud run deploy
考試
部署容器到 Cloud Run
gcloud run deploy my-service --image=gcr.io/my-project/my-app:latest --region=us-central1 --allow-unauthenticated
--image 容器映像檔路徑 --region 部署區域 --allow-unauthenticated 允許未驗證的存取(公開) --port 容器監聽的 port --memory 記憶體上限(如 512Mi) --cpu CPU 數量(如 1, 2) --min-instances 最小實例數(0 = 可縮到零) --max-instances 最大實例數 --set-env-vars 設定環境變數 gcloud run services list 列出 Cloud Run 服務
gcloud run services list --region=us-central1
--platform 平台:managed / gke gcloud run services describe 檢視 Cloud Run 服務詳細資訊
gcloud run services describe my-service --region=us-central1 --format='value(status.url)'
gcloud run services delete 刪除 Cloud Run 服務
gcloud run services delete my-service --region=us-central1
gcloud run services update-traffic
考試
調整 Cloud Run 流量分配
gcloud run services update-traffic my-service --to-revisions=my-service-00002=50,my-service-00001=50 --region=us-central1
--to-revisions 指定修訂版本和流量百分比 --to-latest 全部流量導向最新版本 gcloud run jobs create
考試
建立 Cloud Run Job
gcloud run jobs create my-job --image=gcr.io/my-project/my-batch:latest --region=us-central1 --tasks=10
--tasks 任務數量 --parallelism 最大並行數 --task-timeout 單一任務逾時 gcloud run jobs execute 執行 Cloud Run Job
gcloud run jobs execute my-job --region=us-central1
--wait 等待執行完成 gcloud run deploy (from source) 直接從原始碼部署到 Cloud Run
gcloud run deploy my-service --source=. --region=us-central1
--source 原始碼目錄路徑 gcloud app deploy
考試
部署應用程式到 App Engine
gcloud app deploy app.yaml --version=v2 --no-promote
--version 版本名稱 --no-promote 部署但不接收流量(用於測試) --stop-previous-version 停止前一個版本 gcloud app browse 在瀏覽器中開啟 App Engine 應用
gcloud app browse --service=api
--service 指定服務名稱 gcloud app logs tail 即時串流 App Engine 日誌
gcloud app logs tail --service=default
--service 指定服務 --level 日誌等級:debug / info / warning / error / critical gcloud app versions list 列出 App Engine 所有版本
gcloud app versions list --service=default
gcloud app versions delete 刪除 App Engine 版本
gcloud app versions delete v1 v2 --service=default
gcloud app services set-traffic
考試
設定 App Engine 服務的流量分配
gcloud app services set-traffic default --splits=v2=0.5,v1=0.5
--splits 版本和流量比例 --split-by 分割方式:cookie / ip / random --migrate 漸進式遷移流量 gcloud app describe 檢視 App Engine 應用的設定
gcloud app describe
gcloud app instances list 列出 App Engine 執行中的實例
gcloud app instances list --service=default --version=v1
gcloud functions deploy (1st gen)
考試
部署 Cloud Functions 第 1 代函數
gcloud functions deploy my-function --runtime=nodejs20 --trigger-http --entry-point=helloWorld --region=us-central1 --allow-unauthenticated
--runtime 執行環境(nodejs20, python312, go122 等) --trigger-http HTTP 觸發器 --trigger-topic Pub/Sub topic 觸發 --trigger-bucket Cloud Storage bucket 觸發 --entry-point 函數進入點名稱 --memory 記憶體上限(如 256MB) gcloud functions call 直接呼叫 Cloud Function
gcloud functions call my-function --data='{"name": "World"}' --region=us-central1
--data 傳入的 JSON 資料 gcloud functions logs read 讀取 Cloud Function 的執行日誌
gcloud functions logs read my-function --region=us-central1 --limit=20
--limit 最多顯示的日誌筆數 --min-log-level 最低日誌等級 gcloud functions list 列出所有 Cloud Functions
gcloud functions list --regions=us-central1
gcloud functions delete 刪除 Cloud Function
gcloud functions delete my-function --region=us-central1
gcloud run functions deploy (2nd gen)
考試
部署 Cloud Functions 第 2 代函數(基於 Cloud Run)
gcloud run functions deploy my-function --runtime=nodejs20 --trigger-http --entry-point=helloWorld --region=us-central1 --allow-unauthenticated
--runtime 執行環境 --trigger-http HTTP 觸發器 --concurrency 每個實例的最大並行請求數 --max-instances 最大實例數 gsutil mb
考試
建立 Cloud Storage Bucket
gsutil mb -l us-central1 -c standard gs://my-unique-bucket
-l Bucket 位置(region 或 multi-region) -c 儲存類別:standard / nearline / coldline / archive -b on 啟用 Uniform Bucket-Level Access gsutil cp
考試
上傳、下載或複製檔案
gsutil cp -r ./local-dir gs://my-bucket/remote-dir
-r 遞迴複製目錄 -m 多線程平行傳輸(大量檔案時顯著加速) -z 上傳時壓縮指定副檔名 gsutil mv 移動或重新命名物件
gsutil mv gs://my-bucket/old-name.txt gs://my-bucket/new-name.txt
gsutil rm 刪除物件或 Bucket
gsutil rm -r gs://my-bucket
-r 遞迴刪除(含所有物件) -a 刪除所有版本(含歷史版本) gsutil ls 列出 Bucket 或物件
gsutil ls -la gs://my-bucket/path/
-l 長格式(含大小和更新時間) -a 包含歷史版本 -r 遞迴列出 gsutil rsync
考試
同步本地目錄和 Bucket
gsutil -m rsync -r -d ./local-dir gs://my-bucket/backup
-r 遞迴同步子目錄 -d 刪除目的地多餘的檔案 -n 乾跑模式(只顯示不執行) gsutil iam ch
考試
修改 Bucket 或物件的 IAM 權限
gsutil iam ch user:reader@example.com:objectViewer gs://my-bucket
gsutil lifecycle set
考試
設定物件生命週期管理規則
gsutil lifecycle set lifecycle.json gs://my-bucket
gsutil versioning set on/off
考試
啟用或停用物件版本控制
gsutil versioning set on gs://my-bucket
gcloud storage cp 新一代 Cloud Storage CLI(取代 gsutil cp)
gcloud storage cp -r ./local-dir gs://my-bucket/remote-dir
-r 遞迴複製 gcloud sql instances create
考試
建立 Cloud SQL 執行個體
gcloud sql instances create my-sql --database-version=MYSQL_8_0 --tier=db-n1-standard-2 --region=us-central1 --availability-type=REGIONAL
--database-version 資料庫版本(MYSQL_8_0, POSTGRES_15 等) --tier 實例規格 --availability-type ZONAL 或 REGIONAL(HA) --storage-auto-increase 自動擴增儲存空間 gcloud sql instances list 列出所有 Cloud SQL 執行個體
gcloud sql instances list
gcloud sql instances delete 刪除 Cloud SQL 執行個體
gcloud sql instances delete my-sql
gcloud sql connect 連線到 Cloud SQL 執行個體
gcloud sql connect my-sql --user=root
--user 資料庫使用者名稱 gcloud sql databases create 在 Cloud SQL 實例中建立資料庫
gcloud sql databases create my-database --instance=my-sql
--instance Cloud SQL 實例名稱 --charset 字元集(如 utf8mb4) gcloud sql databases list 列出實例中的所有資料庫
gcloud sql databases list --instance=my-sql
gcloud sql users create 建立 Cloud SQL 使用者
gcloud sql users create my-user --instance=my-sql --password=my-secure-password --host=%
--instance Cloud SQL 實例名稱 --password 使用者密碼 --host 允許連線的主機(MySQL 專用) gcloud spanner instances create
考試
建立 Cloud Spanner 執行個體
gcloud spanner instances create my-spanner --config=regional-us-central1 --nodes=1 --description='My Spanner'
--config 實例設定(regional-* 或 multi-region) --nodes 節點數 --processing-units 處理單元(比 nodes 更細粒度) gcloud firestore databases create
考試
建立 Firestore 資料庫
gcloud firestore databases create --location=us-central --type=firestore-native
--location 資料庫位置 --type firestore-native 或 datastore-mode bq query
考試
執行 BigQuery SQL 查詢
bq query --use_legacy_sql=false 'SELECT COUNT(*) FROM `my-project.my_dataset.my_table`'
--use_legacy_sql=false 使用標準 SQL(建議) --format 輸出格式:json / csv / prettyjson --max_rows 最大回傳列數 --dry_run 只估算掃描量,不實際執行 bq load
考試
載入資料到 BigQuery 表格
bq load --source_format=CSV --autodetect my_dataset.my_table gs://my-bucket/data.csv
--source_format CSV / JSON / AVRO / PARQUET / ORC --autodetect 自動偵測 schema --replace 取代整張表格 --append_table 追加到現有表格 gcloud compute networks create
考試
建立 VPC 網路
gcloud compute networks create my-vpc --subnet-mode=custom
--subnet-mode auto(自動建立子網路)或 custom(手動) --bgp-routing-mode regional 或 global gcloud compute networks list 列出所有 VPC 網路
gcloud compute networks list
gcloud compute networks subnets create
考試
建立子網路
gcloud compute networks subnets create my-subnet --network=my-vpc --range=10.0.1.0/24 --region=us-central1 --enable-private-ip-google-access
--network 所屬 VPC 網路 --range IP CIDR 範圍 --enable-private-ip-google-access 私有 Google 存取(推薦) --secondary-range 次要 IP 範圍(GKE 用) gcloud compute networks subnets list 列出所有子網路
gcloud compute networks subnets list --network=my-vpc
--network 篩選特定 VPC 的子網路 gcloud compute firewall-rules create
考試
建立防火牆規則
gcloud compute firewall-rules create allow-http --network=my-vpc --allow=tcp:80,tcp:443 --target-tags=http-server --source-ranges=0.0.0.0/0
--network 套用到的 VPC --allow 允許的協定和 port --deny 拒絕的協定和 port --target-tags 目標 VM 的網路標記 --source-ranges 來源 IP 範圍 --source-tags 來源 VM 的網路標記 --priority 優先順序(0-65535,數字越小優先越高) gcloud compute firewall-rules list 列出所有防火牆規則
gcloud compute firewall-rules list --filter='network:my-vpc' --format='table(name, direction, priority, allowed)'
gcloud compute firewall-rules delete 刪除防火牆規則
gcloud compute firewall-rules delete allow-http
gcloud compute addresses create
考試
預留靜態 IP 位址
gcloud compute addresses create my-static-ip --region=us-central1
--region 區域(外部區域 IP) --global 全球靜態 IP(用於全球 LB) --subnet 子網路(內部靜態 IP) gcloud compute addresses list 列出所有預留的 IP 位址
gcloud compute addresses list
gcloud compute forwarding-rules create
考試
建立轉發規則(Load Balancer 前端)
gcloud compute forwarding-rules create my-lb-frontend --global --target-http-proxy=my-proxy --ports=80
--global 全球轉發規則 --target-http-proxy 目標 HTTP Proxy --target-pool 目標 Pool(L4 LB) --ports 監聽的 port gcloud iam roles create
考試
建立自訂 IAM 角色
gcloud iam roles create myCustomRole --project=my-project --title='My Custom Role' --permissions=compute.instances.list,compute.instances.get
--project / --organization 建立在專案或組織層級 --title 角色顯示名稱 --permissions 權限清單(逗號分隔) --file 從 YAML/JSON 檔案載入角色定義 gcloud iam roles list 列出可用的 IAM 角色
gcloud iam roles list --filter='name:compute' --format='table(name, title)'
--project 列出專案的自訂角色 gcloud iam service-accounts create
考試
建立服務帳號
gcloud iam service-accounts create my-sa --display-name='My Service Account' --description='For app authentication'
--display-name 顯示名稱 --description 描述 gcloud iam service-accounts list 列出專案中的服務帳號
gcloud iam service-accounts list --format='table(email, displayName, disabled)'
gcloud iam service-accounts keys create
考試
建立服務帳號金鑰
gcloud iam service-accounts keys create key.json --iam-account=my-sa@my-project.iam.gserviceaccount.com
--iam-account 服務帳號 email gcloud projects add-iam-policy-binding
考試
為使用者/服務帳號綁定 IAM 角色
gcloud projects add-iam-policy-binding my-project --member='serviceAccount:my-sa@my-project.iam.gserviceaccount.com' --role='roles/storage.objectViewer'
--member 成員(user: / serviceAccount: / group:) --role IAM 角色 --condition 條件式綁定(如時間限制) gcloud projects get-iam-policy
考試
取得專案的完整 IAM 政策
gcloud projects get-iam-policy my-project --format=json > policy.json
gcloud kms keyrings create
考試
建立 KMS 金鑰環
gcloud kms keyrings create my-keyring --location=us-central1
--location 金鑰環位置 gcloud kms keys create
考試
建立 KMS 加密金鑰
gcloud kms keys create my-key --keyring=my-keyring --location=us-central1 --purpose=encryption --rotation-period=90d
--keyring 金鑰環名稱 --purpose 用途:encryption / asymmetric-signing 等 --rotation-period 自動輪替週期 gcloud secrets create
考試
建立 Secret Manager 機密
gcloud secrets create my-secret --replication-policy='automatic'
--replication-policy automatic 或 user-managed gcloud secrets versions add 新增機密值的版本
echo -n 'my-secret-value' | gcloud secrets versions add my-secret --data-file=-
--data-file 機密值的來源檔案(- 表示 stdin) gcloud secrets versions access 存取機密值
gcloud secrets versions access latest --secret=my-secret
gcloud logging read
考試
讀取 Cloud Logging 日誌
gcloud logging read 'resource.type="gce_instance" severity>=ERROR' --limit=20 --format=json
--limit 最多顯示的日誌筆數 --format 輸出格式 --freshness 時間範圍(如 1h, 1d) --order 排序:asc / desc gcloud logging sinks create
考試
建立日誌匯出目的地
gcloud logging sinks create my-sink bigquery.googleapis.com/projects/my-project/datasets/logs_dataset --log-filter='severity>=WARNING'
--log-filter 篩選要匯出的日誌 gcloud monitoring dashboards create 建立 Cloud Monitoring 監控儀表板
gcloud monitoring dashboards create --config-from-file=dashboard.json
--config-from-file 儀表板設定 JSON 檔案 gcloud monitoring channels create 建立告警通知頻道
gcloud monitoring channels create --type=email --display-name='Ops Team Email' --channel-labels=email_address=ops@example.com
--type 頻道類型:email / slack / pagerduty / webhook 等 --display-name 頻道顯示名稱 gcloud logging metrics create
考試
建立日誌指標
gcloud logging metrics create error-count --description='Count of error logs' --log-filter='severity>=ERROR'
--log-filter 指標的日誌篩選條件 --description 指標描述 gcloud logging write 寫入自訂日誌條目
gcloud logging write my-custom-log '{"message": "Deployment completed"}' --payload-type=json
--payload-type json 或 text --severity 日誌等級 --format=json / yaml / table / csv / value
考試
控制命令輸出格式
gcloud compute instances list --format='table(name, zone.basename(), machineType.basename(), status)'
gcloud compute instances list --format=json
gcloud compute instances list --format='value(name)'
--filter=EXPRESSION
考試
篩選命令輸出結果
gcloud compute instances list --filter='name:web-* AND status=RUNNING'
gcloud compute instances list --filter='zone:(us-central1-a us-central1-b)'
gcloud projects list --filter='lifecycleState=ACTIVE'
--quiet (-q) 跳過所有互動確認提示
gcloud compute instances delete my-vm --zone=us-central1-a --quiet
gcloud config configurations
考試
多專案/多帳號切換管理
gcloud config configurations create dev && gcloud config set project dev-project
gcloud config configurations create prod && gcloud config set project prod-project
gcloud config configurations activate dev
--impersonate-service-account
考試
模擬服務帳號執行命令
gcloud compute instances list --impersonate-service-account=my-sa@my-project.iam.gserviceaccount.com
gcloud compute project-info describe 查看專案的配額和預設值
gcloud compute project-info describe --format='value(commonInstanceMetadata.items)'
gcloud auth print-access-token 取得目前帳號的 OAuth2 Access Token
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" https://storage.googleapis.com/...
gcloud beta / gcloud alpha 使用 Beta 或 Alpha 版本命令
gcloud beta run deploy my-service --image=... --region=...
找不到符合的指令,試試其他關鍵字?