⚒️
gcloud CLIで新しいGCPプロジェクトを作る際によく使うコマンド
Google Cloud Platform(GCP)で新しいプロジェクトを作成する際、gcloud CLIを使うことで、組織配下のフォルダ管理や請求先アカウントのリンクまで一括で実施できます。本記事では、よく使うコマンドとその流れをまとめます。
1. 必要な権限
- フォルダ管理者:
roles/resourcemanager.folderAdmin - プロジェクト作成:
roles/resourcemanager.projectCreator - 請求アカウントリンク:
roles/billing.user
2. 認証
まずは認証情報を更新・ログインします。
gcloud auth login
3. 組織・フォルダの作成
組織IDを確認し、必要なフォルダを作成します。
gcloud organizations list
gcloud resource-manager folders create --display-name=<display-name> --organization=<organization-id>
gcloud resource-manager folders list --organization=<organization-id>
# フォルダの削除
gcloud resource-manager folders delete <folder-id>
4. プロジェクト作成
フォルダIDを取得後、プロジェクトを作成します。
gcloud projects create <project-id> --folder=<folder-id>
5. 請求先アカウントのリンク
請求先アカウントIDを取得し、プロジェクトに紐付けます。
請求先アカウントはGCPコンソール上でしか作成できません。
gcloud billing accounts list
gcloud billing projects link <project-id> --billing-account=<billing-account-id>
6. よく使う補助コマンド
# 組織一覧
gcloud config configurations list
# Google Cloud CLIで指定した設定プロファイルを有効にする
gcloud config configurations activate <config-name>
# プロジェクト一覧
gcloud projects list
# GCPプロジェクトを指定したフォルダに移動する
gcloud beta projects move <project-id> --folder=<folder-id>
本記事執筆時点でのgcloudバージョンは次の通りです。
$ gcloud -v
Google Cloud SDK 536.0.1
beta 2025.08.27
bq 2.1.22
core 2025.08.27
gcloud-crc32c 1.0.0
gsutil 5.35
log-streaming 0.3.1
GCPのプロジェクト作成や管理に取り組む方々の一助となれば幸いです。今後も現場で使えるノウハウや最新の情報を発信していきますので、ぜひご活用ください。ご不明点やご要望があれば、コメント欄からお気軽にご連絡ください。
Discussion