GCP リファレンス

目次

基本コマンド

# クライアントの更新
$ gcloud components update

# プロジェクト一覧
$ gcloud projects list

# デフォルトプロジェクトの確認
$ gcloud config list

# デフォルトプロジェクトの切り替え
$ gcloud config set project project_id

# 実行時プロジェクト指定
$ gcloud --project project_id

# Project毎のクォータ
$ gcloud compute regions list

# 今使えるコンポーネントの確認
$ gcloud components list

# サービスアカウントの認証
$ gcloud auth activate-service-account <service account 名>@<project-name>.iam.gserviceaccount.com --key-file <IAM画面で発行したキーjsonファイル> --project <project-name>

GCE

# インスタンスのimage一覧
$ gcloud compute images list

# インスタンスの一覧
$ gcloud compute instances list

# インスタンスの作成
$ gcloud compute instances create test-instance --project test_pj --zone asia-east1-a

# インスタンスの起動
$ gcloud compute instances start nstance-name

# インスタンスの停止
$ gcloud compute instances stop nstance-name

# インスタンスに接続
$ gcloud compute instances ssh nstance-name

# ssh接続の設定
$ gcloud compute config-ssh

# インスタンスへローカルのファイルをコピーする
$ gcloud compute copy-files local_path instance_name:remote_path --zone zone

# インスタンスにあるファイルをローカルにコピーする
$ gcloud compute copy-files instance_name:remote_path local_path --zone zone

# Firewallのルール参照
$ gcloud compute routes list

GCS

# パケットの一覧表示
$ gsutil ls

# バケット内のオブジェクト一覧表示
$ gsutil ls gs://bucket_name

# バケット内のオブジェクトの内容憑依
$ gsutil cat gs://bucket_name/file_name

# 新しくバケットを作成
$ gsutil mb -c class_name -l location -p project_id gs://xxxx

# バケットを削除
$ gsutil rb -r gs://bucket_name

# オブジェクトを削除
$ gsutil rm gs://bucket_name1/file

# オブジェクトのコピー
$ gsutil cp gs://bucket_name1/file gs://bucket_name2/

# オブジェクトの移動
$ gsutil mv gs://bucket_name1/file gs://bucket_name2/