エンジニアのひよこ_level10

毎日更新してた人。たまに記事書きます。

【GCP】GCPをコマンドラインで動かす。gcloudのインストール方法【384日目】

GCPって?

Googleが提供しているクラウドサービス。

クラウドでサーバー立てたり、いろんなことができるよ

gcloudって?

コマンドラインGCPを操作するためのもの

willow710kut$ gcloud init

みたいにコマンドが打てるようになるよ

これで、手元の端末でクラウドサーバーとかが操作できるようになるね。

インストール方法

基本的には公式参照

Cloud SDK のインストール  |  Cloud SDK のドキュメント  |  Google Cloud

公式読みたくない病のために、以下私がやったコマンドを。(macです)

手順

1.インストール

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

--いろいろ書かれてる--

Installation directory (this will create a google-cloud-sdk subdirectory) (/Users/willow710kut):y
Do you want to help improve the Google Cloud SDK (Y/n)? (おまかせ。googleを助けたいかどうか。お金かからないよ)

Modify profile to update your $PATH and enable shell command
completion?

Do you want to continue (Y/n)? y

The Google Cloud SDK installer will now prompt you to update an rc
file to bring the Google Cloud CLIs into your environment.

Enter a path to an rc file to update, or leave blank to use
[/Users/willow710kut/.bash_profile]:(空白なら左にある.bash_profileを書き換えるよ。私は空白にしたよ)

2.シェルの再起動

$ exec -l $SHELL

3.初期設定

$ gcloud init

You must log in to continue. Would you like to log in (Y/n) ? y (ここでログイン求められるよ)

--ここから、人によっては違う--

Pick cloud project to use:
 [1] xxxx
 [2] Create a new project
Please enter numeric choice or text value (must exactly match list item): 1 (すでにプロジェクト作ってたから、1選択。)

Do you want to configure a default Compute Region and Zone? (Y/n)? y (デフォルトリージョン決めるよ)

 [32] asia-northeast1-b
 [33] asia-northeast1-c
 [34] asia-northeast1-a

Did not print [6] options.
Too many options [56]. Enter "list" at prompt to print choices fully.
Please enter numeric choice or text value (must exactly match list
item):  34 (日本近くのasia-northeast1を選ぶよ。私はaを使ってるので34)

おしまい。これでgcloudのコマンド使えます。お疲れ様でした。