LoginSignup
118
82

More than 5 years have passed since last update.

GCPのgcloudコマンドをインストールする

Posted at

はじめに

最近、gcloudコマンドをインストールすることがあったので備忘録として記す。本記事で記す方法は、インストールに際してrootで実行する必要はない。インストール中に幾つか質問が現れるので注意が必要である。rootになれる環境であれば、aptyumでインストールできるため、そっちを使ったほうが楽かもしれない。

インストール

このコマンドでダウンロードとインストールが実行される。

$ curl https://sdk.cloud.google.com | bash

インストール中の質問は、全てEnterキーを押し続けていれば問題ないはず。

Do you want to help improve the Google Cloud SDK (Y/n)?  y
Modify profile to update your $PATH and enable shell command
completion? (Y/n)?  y
Enter a path to an rc file to update, or leave blank to use [/home/test-user/.bashrc]:

インストールユーザの.bashrcが書き換えられているので、その内容を反映させる。すると、gcloudコマンドにパスが通るようになる。

$ exec -l $SHELL
$ which gcloud
~/google-cloud-sdk/bin/gcloud

認証

このコマンドで、自分のアカウントにログインする。

$ gcloud init

ここはEnterを押しておけばいい。

Your current configuration has been set to: [default]

URLが出力されるので、ブラウザで開いて、GCPで使っているメールアドレスでログインする。すると、認証キーが画面に現れるので、それをプロンプトにコピペする。

You must log in to continue. Would you like to log in (Y/n)?  y

Go to the following link in your browser:

  ¦ https://accounts.google.com/o/oauth2/XXXXXXXXXXXXXXXXXXXXXX


Enter verification code: YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

ここもEnterでいい。

You are logged in as: [your-email@address].

Your current project has been set to: [your-project-name].

Google Cloud Storageだけ使う場合などには、nで問題ない。yを選ぶと、regionの選択プロンプトが現れる。

Do you want to configure Google Compute Engine
(https://cloud.google.com/compute) settings (Y/n)?

以上。

Appendix

118
82
1

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
118
82