サマリ
仕事では AWS をメインで使ってるのもあって、GCP を最近全然いじらなくなっていたのですが、久しぶりにいじるかと思い立ったので、 GCP の環境を1からセットアップします。
Set up for Google Cloud SDK
ドキュメント はこちら。
macOSでのクイックスタートは こちら
ドキュメント中に任意の場所に展開すればと記載してますが $HOME
がいいと思います。
$ mv Downloads/google-cloud-sdk ./ $ ./google-cloud-sdk/install.sh Welcome to the Google Cloud SDK! To help improve the quality of this product, we collect anonymized usage data and anonymized stacktraces when crashes are encountered; additional information is available at <https://cloud.google.com/sdk/usage-statistics>. This data is handled in accordance with our privacy policy <https://policies.google.com/privacy>. You may choose to opt in this collection now (by choosing 'Y' at the below prompt), or at any time in the future by running the following command: gcloud config set disable_usage_reporting false Do you want to help improve the Google Cloud SDK (y/N)?
あとはぽちぽち設定していきます。
途中で shell を更新してくるので、すべての設定が完了したら source
コマンドでシェルを再起動します。
which gcloud
$HOME/google-cloud-sdk/bin/gcloud
PATH が通ってることを確認したら gcloud init
でセットアップを開始します。
最初にどの Google アカウントでログインするのか確認されますので、自分のセットアップしたい Google アカウントを洗濯して、https://cloud.google.com/sdk/auth_success のページが出れば認証が完了します。
local にインストールした Google Cloud SDK に複数のプロジェクトと紐づけるときは再度 gcloud init
を叩いて
gcloud init Welcome! This command will take you through the configuration of gcloud. Settings from your current configuration [default] are: core: account: ema.hiro@gmail.com disable_usage_reporting: 'False' project: emahiro-dev Pick configuration to use: [1] Re-initialize this configuration [default] with new settings [2] Create a new configuration
このプロンプトが出てきた際に 2 を選択します。こうすれば別の Google アカウントとも紐づけることができます。
Google Cloud SDK を動かすための Credentials は$HOME/.config/gcloud/legacy_credentials/{$GoogleAcount}/adc.json
にあります。
予算のアラートを設定する
お支払い(Billing) -> 予算とアラートから設定します。デフォルトで All Resource Budgets があるのでこの予算設定を使います。
All Resource Budget で自プロジェクトで使う全ての GCP のサービスに予算のアラートをかけることができるので安全です。
僕は以下のように設定しました。
その他
何か思いついたら載せます。
とりあえずサクッと gcloud
コマンドが動いたのでこのエントリはこれでおしまい。