LoginSignup
0
0

More than 5 years have passed since last update.

メモ:Google Cloud PlatformのGCEがエフェメラル設定の場合に外部IPを取得するコマンド

Posted at
  • gcp(google cloud platform)のGCE(Google Cloud Engine)を、固定IPではなくエフェメラルで使う場合、グローバルIPは起動毎に変わってしまう。
  • なので、sshでログインするときや、CiecleCIからansibleを走らせるといった時には、gcloudコマンドでIPアドレスを取得する必要がある。そういった時に、以下のようなコマンドで一発でIPアドレスだけ取れる。
  • gcloudコマンドが使えて、login設定済みであること、jqが使えることが前提である。
command
$ gcloud compute  instances list --filter="name=('server01')" --format=json | jq .[0].networkInterfaces[0].accessConfigs[0].natIP -r
  • もっと簡単な方法があるかもしれないが、とりあえずこれで取れたのでましな方法が見つかったら更新する。
0
0
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
0