サービスの依存関係を一覧表示する
階層型サービスのアクティベーションを使用すると、 Google Cloud リソース階層を介して継承されるサービスの有効化を管理できます。詳細については、概要をご覧ください。
多くの Google Cloud サービスは、機能するために他のサービスを必要とします。階層型サービス アクティベーションを使用してサービスを有効にすると、必要な依存関係が ConsumerPolicy に自動的に追加されます。サービス依存関係グループには、これらの依存サービスが含まれています。これらを一覧表示して、よりよく理解し、管理できます。
このドキュメントでは、Google Cloud CLI を使用してプロジェクト、フォルダ、組織のサービス依存関係を一覧表示する方法について説明します。
始める前に
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
Install the Google Cloud CLI.
-
外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。
-
gcloud CLI を初期化するには、次のコマンドを実行します。
gcloud init -
Create or select a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_IDwith a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_IDwith your Google Cloud project name.
-
このガイドで既存のプロジェクトを使用する場合は、このガイドを完了するために必要な権限があることを確認します。新しいプロジェクトを作成した場合は、必要な権限がすでに付与されています。
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Service Usage API:
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.gcloud services enable serviceusage.googleapis.com
-
Install the Google Cloud CLI.
-
外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。
-
gcloud CLI を初期化するには、次のコマンドを実行します。
gcloud init -
Create or select a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_IDwith a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_IDwith your Google Cloud project name.
-
このガイドで既存のプロジェクトを使用する場合は、このガイドを完了するために必要な権限があることを確認します。新しいプロジェクトを作成した場合は、必要な権限がすでに付与されています。
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Service Usage API:
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.gcloud services enable serviceusage.googleapis.com
- 管理する Google Cloud リソースを指定しない場合、このドキュメントのコマンドはデフォルトで現在のプロジェクトになります。たとえば、
gcloud beta services groups list-members bigquery.googleapis.com dependenciesは現在のプロジェクトのメンバーを一覧表示します。現在のプロジェクト ID を取得できます。
gcloud config list --format='text(core.project)'
-
依存関係グループのメンバーを一覧表示します。
serviceusage.groups.listMembers -
展開された依存関係グループのメンバーを一覧表示します。
serviceusage.groups.listExpandedMembers SERVICE: メンバーを一覧表示するサービスの名前。GROUP: メンバーを一覧表示するサービス依存関係グループの名前。サポートされている主なグループはdependenciesです。PROJECT_ID: Google Cloud プロジェクト ID。または、フラグを省略して、デフォルトで現在のプロジェクトを使用します。SERVICE: メンバーを一覧表示するサービスの名前。GROUP: メンバーを一覧表示するサービス依存関係グループの名前。サポートされている主なグループはdependenciesです。FOLDER_ID: 実際の Google Cloud フォルダ ID。SERVICE: メンバーを一覧表示するサービスの名前。GROUP: メンバーを一覧表示するサービス依存関係グループの名前。サポートされている主なグループはdependenciesです。ORGANIZATION_ID: Google Cloud 組織リソース ID。SERVICE: メンバーを一覧表示するサービスの名前。GROUP: メンバーを一覧表示するサービス依存関係グループの名前。サポートされている主なグループはdependenciesです。PROJECT_ID: Google Cloud プロジェクト ID。または、フラグを省略して、デフォルトで現在のプロジェクトを使用します。SERVICE: メンバーを一覧表示するサービスの名前。GROUP: メンバーを一覧表示するサービス依存関係グループの名前。サポートされている主なグループはdependenciesです。FOLDER_ID: 実際の Google Cloud フォルダ ID。SERVICE: メンバーを一覧表示するサービスの名前。GROUP: メンバーを一覧表示するサービス依存関係グループの名前。サポートされている主なグループはdependenciesです。ORGANIZATION_ID: Google Cloud 組織リソース ID。- 現在のプロジェクトの BigQuery サービスの直接依存関係を一覧表示します。
gcloud beta services groups list-members bigquery.googleapis.com dependencies
出力:
NAME: services/analyticshub.googleapis.com REASON: BigQuery depends on this group to allow users to exchange data and analytics assets. NAME: services/bigquery.googleapis.com REASON: The service representing BigQuery which owns this dependency group and depends on the other members of this group. NAME: services/bigqueryconnection.googleapis.com REASON: BigQuery depends on this group to allow users to manage connections to external data sources. NAME: services/bigquerydatapolicy.googleapis.com REASON: BigQuery depends on this group to allow users to manage their data policies. ...
- 対応するサービス依存関係グループなしで API キー サービスの依存関係を一覧表示しようとしています。
gcloud beta services groups list-members apikeys.googleapis.com dependencies --project=test-project
出力:
Listed 0 items. - 現在のプロジェクトの BigQuery サービスの拡張依存関係のリストを取得します。
gcloud beta services groups list-expanded-members bigquery.googleapis.com dependencies
出力:
services/analyticshub.googleapis.com services/bigquery.googleapis.com services/bigqueryconnection.googleapis.com services/bigquerydatapolicy.googleapis.com services/bigquerydatatransfer.googleapis.com services/bigquerymigration.googleapis.com services/bigqueryreservation.googleapis.com services/bigquerystorage.googleapis.com services/cloudresourcemanager.googleapis.com services/dataform.googleapis.com services/dataplex.googleapis.com
- サービスを有効または無効にするには、サービスの有効化を管理するをご覧ください。
- ポリシーを管理するには、消費者向けポリシーを管理するをご覧ください。
必要なロール
サービス依存関係の一覧表示に必要な権限を取得するには、ターゲット リソースに対するサービス使用状況閲覧者 (roles/serviceusage.serviceUsageViewer)IAM ロールを付与するよう管理者に依頼してください。ロールの付与については、プロジェクト、フォルダ、組織に対するアクセス権の管理をご覧ください。
この事前定義ロールには、サービス依存関係を一覧表示するために必要な権限が含まれています。必要とされる正確な権限については、「必要な権限」セクションを開いてご確認ください。
必要な権限
サービスの依存関係を一覧表示するには、次の権限が必要です。
カスタムロールや他の事前定義ロールを使用して、これらの権限を取得することもできます。
依存関係グループのメンバーを一覧表示する
プロジェクト、フォルダ、または組織のサービス依存関係グループの直接メンバーを一覧表示するには、gcloud beta services groups list-members コマンドを使用します。
プロジェクト
gcloud beta services groups list-members SERVICE GROUP \
--project=PROJECT_ID
次のように置き換えます。
フォルダ
gcloud beta services groups list-members SERVICE GROUP \
--folder=FOLDER_ID
次のように置き換えます。
組織
gcloud beta services groups list-members SERVICE GROUP \
--organization=ORGANIZATION_ID
次のように置き換えます。
他のフラグを使用して、リストに表示されるメンバーをフィルタして制限できます。
展開された依存関係グループのメンバーを一覧表示する
プロジェクト、フォルダ、組織のサービス依存関係グループの展開されたメンバーを一覧表示するには、gcloud beta services groups list-expanded-members コマンドを使用します。
このコマンドは、ネストされたグループ内の依存関係を含むすべての依存関係のフラット化されたリストを返し、すべてのサービス依存関係の完全な結合リストを提供します。
プロジェクト
gcloud beta services groups list-expanded-members SERVICE GROUP \
--project=PROJECT_ID
次のように置き換えます。
フォルダ
gcloud beta services groups list-expanded-members SERVICE GROUP \
--folder=FOLDER_ID
次のように置き換えます。
組織
gcloud beta services groups list-expanded-members SERVICE GROUP \
--organization=ORGANIZATION_ID
次のように置き換えます。
他のフラグを使用して、リストに表示されるメンバーをフィルタして制限できます。