このトピックでは、Cloud KMS リソースへのアクセスを管理する方法について説明します。
概要
鍵やキーリングなどの Cloud KMS リソースへのアクセスを管理するには、Identity and Access Management(IAM)ロールを付与します。鍵のローテーションやデータの暗号化など、特定の暗号オペレーションの実行権限を付与または制限できます。次のとおり、IAM のロールを付与できます。
- 鍵に直接
- その鍵リング内のすべての鍵によって継承される鍵リング
- プロジェクトのすべての鍵によって継承されるプロジェクト Google Cloud
- Google Cloud フォルダ、フォルダ内のすべてのプロジェクトのすべての鍵によって継承される フォルダ
- 組織内のフォルダ内のすべての鍵によって継承される組織 Google Cloud
Cloud KMS のアクションおよび IAM のロールと権限の一覧については、 権限とロールをご覧ください。Cloud KMS リソースとリソース間の関係については、Cloud KMS リソースをご覧ください。
始める前に
これらのタスクを完了するには、プロジェクトの Cloud KMS
リソースを管理する権限が必要です。 Google Cloud Cloud KMS 管理者のロール(roles/cloudkms.admin)には、必要な権限が含まれています。
- アカウントにログインします。 Google Cloud を初めて使用する場合は、 Google Cloud、 アカウントを作成して、 実際のシナリオでプロダクトがどのように機能するかを評価してください。新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
-
In the Google Cloud console, on the project selector page, select or create 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.
-
Verify that billing is enabled for your Google Cloud project.
Enable the required API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Google Cloud CLI をインストールします。
-
外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。
-
gcloud CLI を初期化するには、次のコマンドを実行します:
gcloud init -
In the Google Cloud console, on the project selector page, select or create 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.
-
Verify that billing is enabled for your Google Cloud project.
Enable the required API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Google Cloud CLI をインストールします。
-
外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。
-
gcloud CLI を初期化するには、次のコマンドを実行します:
gcloud init - キーリングなどのリソースを作成します。
- 作成されたリソース(キーリング、鍵、鍵バージョンなど)のリソース IDを取得します。
Cloud KMS リソースへのアクセス権を付与または取り消すことができるのは、オーナー(roles/owner)または Cloud KMS 管理者(roles/cloudkms.admin)のロールを持つ IAM プリンシパルのみです。
リソースに対するロールの付与
次の例では、Cloud KMS 鍵へのアクセスを提供するロールを付与します。
gcloud
コマンドラインで Cloud KMS を使用するには、まず Google Cloud CLI の最新バージョンをインストールまたはアップグレードします。
gcloud kms keys add-iam-policy-binding key \
--keyring key-ring \
--location location \
--member principal-type:principal-email \
--role roles/role
key を鍵の名前に置き換えます。key-ring は、鍵が配置されている鍵リングの名前に置き換えます。location を鍵リングの Cloud KMS の場所に置き換えます。principal-type と principal-email は、プリンシパルの種類とプリンシパルのメールアドレスに置き換えます。role は、追加するロールの名前に置き換えます。
C#
このコードを実行するには、まず C# 開発環境を設定し、 Cloud KMS C# SDK をインストールします。