LoginSignup
0
1

More than 3 years have passed since last update.

gcloud 事始め

Last updated at Posted at 2021-03-05

いざgcloudの世界へ

まず、どこのプロジェクトを使っているのかを調べることが重要です

gcloud auth list

でどこのプロジェクトがアクティブになっているか確認してください。

次は、サービスアカウントでログインします。個別でログインするgcloud auth loginでログインする方法もありますが、プロジェクトで複数人で開発するかつ、自分でサービス権限を制御できる環境であれば、サービスアカウント推奨です。ちなみにサービスのjsonキーを取得するには、
「左メニュー>APIとサービス>認証情報>サービスアカウント」より発行できます。

gcloud auth activate-service-account <サービスアカウント> --key-file=<サービスのキー>.json

もう一度 gcloud auth listを入力して、設定したサービス名に「*」がついていれば、対象のアカウントに入れたことになります。

次にプロジェクトです

gcloud config set project <プロジェクト名>

で設定できます。

設定後は、設定以下で確認しましょう

gcloud config configurations list

bigqueryなどにアクセスする場合(macなどの場合)

export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/my-key.json"
0
1
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
0
1