10
7

More than 3 years have passed since last update.

GCE startup/shutdown script 手順

Last updated at Posted at 2016-11-18

2016/11/18 現在
GCE はすぐ変わるので注意

ざっくりとした手順

1. instance に、script を仕込む。

実行中の instance の場合

対象の instance をぽちー

編集 ぽちー

カスタムメタデータ の キー と を入力
キー startup-script-url or shutdown-script-url
gcs のスクリプトのパスを記入 (下記URL)
[例]
公開リンク ✓
右クリック → リンクのアドレスをコピー
スクリーンショット_2016-11-18_20_14_27.png

一番下の 保存 クリック

これから作成する instance の場合

一番下の 管理 クリック

先ほどと同じように、 キー を記入する。
スクリーンショット_2016-11-18_20_20_30.png

以上

2. script の動作確認

下記コマンドにて script の動作確認ができる。

sudo google_metadata_script_runner --script-type <startup/shutdown>

まとめ

startup-script の場合

起動条件
- instance が起動した際に、起動します。
下記に、ログが吐かれる。
/var/log/startscript.log

shutdown-script の場合

起動条件
- stop/start した場合
- terminate した場合
下記にログが吐かれる。
/var/log/shutdownscript.log

忘れないようにmemo

10
7
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
10
7