このページでは、インスタンス テンプレートを取得、一覧表示、および削除する方法について説明します。
始める前に
-
まだ設定していない場合は、認証を設定します。認証とは、 Google Cloud サービスと API にアクセスするために ID を確認するプロセスです。ローカル開発環境からコードまたはサンプルを実行するには、次のいずれかのオプションを選択して Compute Engine に対する認証を行います。
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
- Set a default region and zone.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
- Google Cloud コンソールで、[インスタンス テンプレート] ページに移動します。
- インスタンス テンプレートの名前をクリックして、テンプレートの詳細を表示します。
- Google Cloud コンソールで、[インスタンス テンプレート] ページに移動します。
- 削除するインスタンス テンプレートを選択します。
- [削除] をクリックします。
Go
ローカル開発環境でこのページの Go サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
詳細については Set up authentication for a local development environment をご覧ください。
Java
ローカル開発環境でこのページの Java サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
詳細については Set up authentication for a local development environment をご覧ください。
Node.js
ローカル開発環境でこのページの Node.js サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
詳細については Set up authentication for a local development environment をご覧ください。
Python
ローカル開発環境でこのページの Python サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
詳細については Set up authentication for a local development environment をご覧ください。
REST
このページの REST API サンプルをローカル開発環境で使用するには、gcloud CLI に指定した認証情報を使用します。
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
詳細については、 Google Cloud 認証ドキュメントの REST を使用して認証するをご覧ください。
インスタンス テンプレートについての情報の確認
コンソール
gcloud
リージョンまたはグローバルのインスタンス テンプレートに関する情報を取得するには、
instance-templates describe command
を使用します。リージョン インスタンス テンプレートの場合は、次のコマンドを使用します。
gcloud compute instance-templates describe INSTANCE_TEMPLATE_NAME \ --region=REGION
グローバル インスタンス テンプレートの場合は、次のコマンドを使用します。
gcloud compute instance-templates describe INSTANCE_TEMPLATE_NAME
Go
Java
Node.js
Python
REST
リージョン インスタンス テンプレートに関する情報を取得するには、次のように
regionInstanceTemplates.get
メソッドを使用します。GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceTemplates/INSTANCE_TEMPLATE_NAME
グローバル インスタンス テンプレートに関する情報を取得するには、次のように
instanceTemplates.get
を使用します。GET https://compute.googleapis.com/compute/v1/projects/[PROJECT_ID]/global/instanceTemplates/[INSTANCE_TEMPLATE]
インスタンス テンプレートの一覧取得
作成したインスタンス テンプレートの一覧を取得するには、次の手順に沿って操作します。
コンソール
[インスタンス テンプレート] ページには、プロジェクトのすべてのインスタンス テンプレートが一覧表示されます。
gcloud
すべてのリージョン インスタンス テンプレートのリストを取得するには、次のコマンドを使用します。
gcloud compute instance-templates list \ --regions
特定のリージョンのリージョン インスタンス テンプレートのリストを取得するには、次のコマンドを使用します。
gcloud compute instance-templates list \ --filter="region:(REGION)"
グローバル インスタンス テンプレートのリストを取得するには、次のコマンドを使用します。
gcloud compute instance-templates list \ --global
すべてのインスタンス テンプレートの一覧(リージョンとグローバルを含む)を取得するには、次のコマンドを使用します。
gcloud compute instance-templates list
Go
Java
Node.js
Python
REST
リージョン インスタンス テンプレートの一覧を取得するには、
regionInstanceTemplates.list
リクエストを行います。GET https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/REGION/instanceTemplates
グローバル インスタンス テンプレートの一覧を取得するには、
instanceTemplates.list
リクエストを行います。GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/instanceTemplates
インスタンス テンプレートの削除
インスタンス テンプレートを削除すると、そのテンプレートは一覧から消去されます。マネージド インスタンス グループがそのインスタンス テンプレートを参照している場合は、テンプレートを削除できません。
コンソール
gcloud
Google Cloud CLI を使用して、次を実行します:
gcloud compute instance-templates delete INSTANCE_TEMPLATE_NAME
リージョン インスタンス テンプレートの場合、INSTANCE_TEMPLATE_NAME にはテンプレートの完全な URL を含める必要があります。例:
https://www.googleapis.com/compute/v1/projects/example-project/regions/us-central1/instanceTemplates/example-regional-instance-template
Go
Java
Node.js
Python
REST
リージョン インスタンス テンプレートを削除するには、
regionInstanceTemplates.delete
リクエストを使用します。DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceTemplates/INSTANCE_TEMPLATE_NAME
グローバル インスタンス テンプレートを削除するには、
instanceTemplates.delete
リクエストを使用します。DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/instanceTemplates/INSTANCE_TEMPLATE_NAME
マネージド インスタンス グループの VM は時折、グループ内の他のインスタンスと同期しなくなり、他のインスタンスとは別のインスタンス テンプレートを使用してしまうことがあります。マネージド インスタンス グループの VM が、グループで指定されたものとは異なるテンプレートを使用している場合、そのテンプレートが削除されていても、その VM は引き続きそのテンプレートを修復に使用します。新しいインスタンス テンプレートの適用の詳細については、MIG で新しい VM 構成を適用するをご覧ください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-03 UTC。
-