LoginSignup
6
8

More than 5 years have passed since last update.

GCEで利用した静的内部IPの削除

Last updated at Posted at 2018-10-08

経緯

GCPでサブネットワークを作成し、GCEを静的内部IPを付与して作成。
サブネットワークを再作成する必要が出てきたため、コンソールからGCEをインスタンスを削除し、
サブネットワークも削除しようとしたところ、内部IPが存在するとのエラーが出力。

どうやらgcloudコマンドで作業をする必要があるため、備忘録としてメモ。
なお、gcloudコマンドはGCPコンソールからCloud Shellを起動して実行。

コマンド

現在の静的内部IP一覧を確認

$ gcloud compute addresses list
NAME            REGION           ADDRESS        STATUS
testip-1        asia-northeast1  10.10.10.1   RESERVED
testip-2        asia-northeast1  10.10.10.2   RESERVED

IPの削除

$ gcloud compute addresses delete testip-1 --region=asia-northeast1
The following addresses will be deleted:
 - [testip-1] in [asia-northeast1]
Do you want to continue (Y/n)?  Y
Deleted [https://www.googleapis.com/compute/v1/projects/<project name>/regions/asia-northeast1/addresses/testip-1].

こちらで削除成功。
あらかじめregionを変更しておくか、--regionを引数で設定しないと別リージョンのオブジェクトを削除しようとしてエラーになることがある。

$ gcloud compute addresses list
NAME            REGION           ADDRESS        STATUS
testip-2        asia-northeast1  10.10.10.2   RESERVED

補足

プロジェクト一覧の確認
$ gcloud projects list

デフォルトプロジェクトの確認
$ gcloud config list

デフォルトプロジェクトの変更
$ gcloud config set project <project name>

コマンド実行時プロジェクト指定でもよいらしい
$ gcloud --project <project id>

参考
https://cloud.google.com/sdk/gcloud/reference/?hl=ja

6
8
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
6
8