LoginSignup
5
3

More than 3 years have passed since last update.

コマンドラインでGCPのプロジェクトを作成

Last updated at Posted at 2020-02-26

環境

  • MacOS X 10.14.5 (Mojave)
  • Homebrew 2.2.5
  • Google Cloud SDK 281.0.0

GCPアカウント登録

【画像で説明】Google Cloud Platform (GCP)の無料トライアルでアカウント登録

Google Cloud SDKのインストール

Google Cloud SDKのインストール ~ 初期化

まずはSDK認証

ログインしていない場合は

$ gcloud auth login

他のアカウントにログインしている場合は、対象アカウントに切り替えてからログイン

$ gcloud config set account アカウントID
$ gcloud auth login

以下のコマンドでログインしているアカウントを確認できます

$ gcloud config list account

プロジェクト作成

$ gcloud projects create プロジェクトID --name プロジェクト名

プロジェクトの切り替え

作成したプロジェクトをアクティブにします。

$ gcloud config set project プロジェクトID

設定を確認

$ gcloud config list

# [core]
# account = example@gmail.com
# project = プロジェクトID

請求先アカウントの設定

ここから設定
スクリーンショット 2020-02-04 17.08.51.png

以下のポップアップが出なければ、請求先アカウント設定済みなのでスキップしてOKです。
スクリーンショット 2020-02-09 21.45.08.png

スクリーンショット 2020-02-09 21.45.42.png

請求先アカウントが未設定だったり、無料トライアルが終わってたりすると後々こんなエラーが出ることがあります。

AccessDeniedException: 403 The project to be billed is associated with an absent billing account.

リージョン / ゾーンの設定

上記のようにリージョンとゾーンが設定されていなければ以下のように設定。
設定値は任意です。

リージョン設定

$ gcloud config set compute/region us-central1

ゾーン設定

$ gcloud config set compute/zone us-central1-a

設定を確認

$ gcloud config list

# [compute]
# region = us-central1
# zone = us-central1-a
# [core]
# account = anata-no-address@gmail.com
# disable_usage_reporting = False
# project = project-id
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3