gcloud について
gcloud で Google Cloud リソースを管理するためのコマンドライン参照ガイドです。認証、コンピューティング、Cloud Run、ストレージなどのコマンド例を開発者向けに示します。
主な機能
- 01対話型認証とサービスアカウント認証
- 02Compute Engine インスタンスの一覧・管理
- 03Cloud Run サービスのデプロイと管理
- 04Cloud Storage バケットの作成と操作
- 05コマンド出力の整形とフィルタリング
活用シーン
- 01コマンドラインから Cloud Run サービスをデプロイ
- 02仮想マシンや GKE クラスターを管理
- 03CI/CD 用サービスアカウントを設定
- 04Cloud Storage リソースの確認や操作
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ dicklesworthstone/ agent_flywheel_clawdbot_skills_and_integrations --skill gcloudインストール後、Claude Code で/gcloudを入力して読み込まれたか確認します。
同梱ファイルreferences/IAM.mdreferences/SERVICES.md
詳細
GCloud CLI
主な機能: コマンドラインから Google Cloud Platform のリソースとサービスを管理します。
クイックスタート
# Install
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
# Verify
gcloud version
# Check auth
gcloud auth list
# Set project
gcloud config set project PROJECT_ID
# Show current config
gcloud config list
正確なプロンプト — 認証と設定
# Login interactively
gcloud auth login
# Service account auth
gcloud auth activate-service-account --key-file=key.json
# Application default credentials
gcloud auth application-default login
# Set project
gcloud config set project PROJECT_ID
# Set region/zone
gcloud config set compute/region us-central1
gcloud config set compute/zone us-central1-a
# Named configurations
gcloud config configurations create my-config
gcloud config configurations activate my-config
正確なプロンプト — Compute Engine
# List VMs
gcloud compute instances list
# Create VM
gcloud compute instances create my-vm \
--zone=us-central1-a \
--machine-type=e2-medium \
--image-family=debian-12 \
--image-project=debian-cloud
# SSH to VM
gcloud compute ssh my-vm --zone=us-central1-a
# Stop/start
gcloud compute instances stop my-vm --zone=us-central1-a
gcloud compute instances start my-vm --zone=us-central1-a
正確なプロンプト — Cloud Run
# List services
gcloud run services list
# Deploy from source
gcloud run deploy my-service --source . --region=us-central1
# Deploy container
gcloud run deploy my-service \
--image=gcr.io/PROJECT/IMAGE \
--region=us-central1 \
--allow-unauthenticated
# View logs
gcloud run services logs read my-service --region=us-central1
正確なプロンプト — Cloud Storage
# List buckets
gcloud storage buckets list
# Create bucket
gcloud storage buckets create gs://my-bucket --location=us-central1
# Upload/download
gcloud storage cp local-file.txt gs://my-bucket/
gcloud storage cp gs://my-bucket/file.txt ./
# Sync directory
gcloud storage rsync -r ./local-dir gs://my-bucket/remote-dir
基本コマンド
| サービス | 一覧表示 | 作成 | 削除 |
|---|---|---|---|
| Compute | gcloud compute instances list | gcloud compute instances create | gcloud compute instances delete |
| Cloud Run | gcloud run services list | gcloud run deploy | gcloud run services delete |
| Functions | gcloud functions list | gcloud functions deploy | gcloud functions delete |
| GKE | gcloud container clusters list | gcloud container clusters create | gcloud container clusters delete |
| Storage | gcloud storage buckets list | gcloud storage buckets create | gcloud storage rm |
出力形式
# JSON output
gcloud compute instances list --format=json
# Table with specific columns
gcloud compute instances list --format="table(name,zone,status)"
# Filter results
gcloud compute instances list --filter="status=RUNNING"
# Quiet mode (no prompts)
gcloud compute instances delete my-vm --quiet
クイックリファレンス
gcloud cheat-sheet # Built-in cheat sheet
gcloud interactive # Interactive shell
gcloud --help # General help
gcloud compute --help # Service-specific help
AGENTS.md 向けの説明
プロジェクトの AGENTS.md にコピーしてください。
### Google Cloud CLI (gcloud)
`gcloud` is installed and authenticated.
Auth:
\`\`\`bash
gcloud auth login
gcloud auth application-default login # For API libraries
\`\`\`
Project:
\`\`\`bash
gcloud config set project <PROJECT_ID>
\`\`\`
Enable APIs:
\`\`\`bash
gcloud services enable aiplatform.googleapis.com
gcloud services enable analyticsdata.googleapis.com
\`\`\`
Useful commands:
\`\`\`bash
gcloud projects list
gcloud services list --enabled
gcloud beta billing accounts list
\`\`\`
使用する場面
- Gemini、Vertex AI、その他の Google サービス向けの API を有効にする
- 課金とコストアラートを管理する
- CI/CD 用のサービスアカウントを作成する
- Cloud Run にコンテナをデプロイする
- GKE クラスターを管理する
参考資料
| トピック | 参考資料 |
|---|---|
| すべてのサービス | SERVICES.md |
| IAM とセキュリティ | IAM.md |
コメント
Markdown 対応