API キーを使用したアクセス制御¶
Confluent Cloud API キーは、Confluent Cloud コンポーネントおよびリソースへのアクセスを制御するために使用されます。各 API キーは、キーとシークレットで構成されます。ユーザーアカウントとサービスアカウントの使用およびその API キーの所有権の詳細については、「API キーの所有権」を参照してください。
リソース別 API キー を使用して、Confluent Cloud コンポーネントおよびサービスへのアクセスを制御します。以下は Confluent Cloud コンポーネントの API キーです。
Resource-specific API key | Description |
---|---|
Kafka | Required to access your Kafka clusters and Kafka resources. Each Kafka API key is valid for one specific Kafka cluster. |
スキーマレジストリ | Required to access the Confluent Cloud Schema Registry. Each スキーマレジストリ API key is valid for one specific スキーマレジストリ. |
ksqlDB | Required to interact with your ksqlDB applications in Confluent Cloud. Each ksqlDB API key is valid for one specific ksqlDB application. |
Use Cloud API keys to control access to Confluent Cloud resources and use the Confluent Cloud APIs available for environments, user accounts, service accounts, connectors, Metrics API, and other resources.
To create and manage API keys in Confluent Cloud, you can use the following tools:
API キーの使用に関する推奨事項については、「API キーを使用するためのベストプラクティス」を参照してください。
API キーの所有権¶
Each API key is associated with a specific service account or user account. The limit on the number of API keys that can be associated with user or service accounts is specified in Confluent Cloud のサービスクォータ.
- A best practice is to create a separate service accounts associated with an API keys for each applications or use case.
- Restrict access to an application that uses an API key associated with
a service account:
- For resource-specific API keys, use access control lists (ACLs).
- For Cloud API keys, use role-based access control (RBAC).
注意
ユーザーアカウントまたはサービスアカウントを削除すると、関連付けられている API キーもすべて削除されます。削除された API キーを使用しているクライアントアプリケーションはアクセスできなくなるので、ストリーミングアプリケーションが停止する可能性があります。ユーザーアカウントやサービスアカウントを削除する前に、必ず、そのアカウントが所有している API キーが使用されていないことを確認してください。
リソース別 API キー¶
Use the resource-specific API keys to control access to specific Confluent Cloud components and services. Resource-specific API keys are available for Kafka, スキーマレジストリ, and ksqlDB resources.
Each resource-specific API key is valid for one specific resource — one Kafka cluster, one スキーマレジストリ, or one ksqlDB application.
重要
リソース別 API キーは作成後すぐに(通常は数分以内)伝播されます。伝播が完了する前に API キーを使用しようとすると、認証が失敗します。ワークロードによっては、再試行するまでにさらに 2、3 分待たなければならない場合があります。
リソース別 API キーの作成¶
You can create resource-specific API keys for Kafka clusters, スキーマレジストリ, and ksqlDB applications.
- Prerequisites
- Access to Confluent Cloud with an active cluster.
- Confluent CLI がインストールされている。
- To create API keys, you must be granted the OrganizationAdmin, EnvironmentAdmin, or CloudClusterAdmin role. For details, see Confluent Cloud RBAC roles.
Verify that you have any required access control lists (ACLs) for the service account.
重要
Before creating a Kafka API key associated with a service account, you must have an ACL that restricts access. If you do not have an ACL configured, the API key will not have access.
For スキーマレジストリ and ksqlDB, no access control is available.
Sign in to your cluster using the confluent login CLI command.
confluent login
Enter your Confluent Cloud credentials: Email: susan@myemail.com Password:
Get the resource ID (
<resource-id>
) for Kafka, スキーマレジストリ, or ksqlDB. To find the resource ID, use the following Confluent CLI commands:- Kafka:
confluent kafka cluster list
- スキーマレジストリ:
confluent schema-registry cluster describe
- ksqlDB:
confluent ksql app list
- Kafka:
Create the API key and secret using the confluent api-key create command.
confluent api-key create --service-account <service-account-id> --resource <resource-id> --description <prod key>
Save the API key and secret output in a secure location. The secret cannot be retrieved later.
ちなみに
To register an API key and secret created by another process and store them locally, run the confluent api-key store command, specifying the API key (
<api-key>
), API secret (<api-secret>
), and resource ID (<resource-id>
).confluent api-key store <api-key> <api-secret> --resource <resource-id>
Use the confluent api-key use command to specify the API key and secret you will be using with Confluent CLI commands on the resource. For スキーマレジストリ resources only, you do not need to specify the API key to use.
confluent api-key use <api-key>
- Prerequisites
- Access to Confluent Cloud. Sign in with an active cluster. Log in to Confluent Cloud at https://confluent.cloud.
- To create API keys, you must be granted the OrganizationAdmin, EnvironmentAdmin, or CloudClusterAdmin role. For details, see Confluent Cloud RBAC roles.
Verify that you have any required access control lists (ACLs) for the service account.
重要
Before creating a Kafka API key associated with a service account, you must have an ACL that restricts access. If you do not have an ACL configured, the API key will not have access.
For スキーマレジストリ and ksqlDB, no access control is available.
If you have more than one environment, go to the Environments page at https://confluent.cloud/environments and select the environment.
Select the Confluent Cloud resource you want to create an API key for (Kafka or スキーマレジストリ). For ksqlDB API keys, you need to use the Confluent CLI — see the Confluent CLI tab in this section.
- Kafka cluster: In the Cloud Console, click the cluster and then under Data integration, click API keys.
- スキーマレジストリ: In the Cloud Console, click the Schema Registry tab, find the API credentials section, click Edit, and then Create key.
これが対象のリソースの初めての API キーである場合は、Create key をクリックします。API キーが既に存在している場合は、+ Add key をクリックします。
API キーとシークレットが生成され、表示されます。
Copy をクリックして、キーとシークレットをセキュアな場所にコピーします。
重要
The secret for the key is only exposed initially in the Create API key dialog and cannot be viewed or retrieved later. Store the API key and secret in a secure location. Do not share the secret for your API key.
(Optional, but recommended) Enter a description of the API key that describes how you intend to use it, so you can distinguish it from other API keys.
注釈
スキーマレジストリ リソースについては、使用する API キーを指定する必要はありません。
Confirm that you have saved your key and secret.
Click Continue. The key is added to the API keys table.
Edit a resource-specific API key description¶
Follow the procedures below to add, edit, or delete the optional description of an API key.
To edit the description of a resource-specific API key, use the confluent api-key update command.
confluent api-key update <api-key> --description <description-string>
- Kafka、スキーマレジストリ、または ksqlDB のリソースに対応する API Access タブで、編集するキーをクリックします。
- Edit description をクリックします。説明を入力するか、既存の説明を編集します。説明を削除するには、Description ボックスのテキストをクリアします。
- Save をクリックします。
Confluent Cloud Console を使用したリソース別 API キーの削除¶
You should delete API key if it no longer needed or if its secret is compromised.
Kafka、スキーマレジストリ、または ksqlDB のリソースに対応する API Access タブから、削除するキーをクリックします。
ごみ箱アイコンをクリックします。Confirm API key deletion ダイアログが表示されます。
Confirm をクリックします。
注意
API キーの削除操作は元に戻せません。
Create a Kafka API key associated with a user account¶
新規 Kafka API キーを作成して、既存のユーザーアカウントに関連付けることができます。
- Kafka API キーを作成するクラスターに移動します。
- API access タブ、+ Add key の順にクリックします。
- Create an API key associated with your account をクリックします。このオプションを指定すると、新規 API キーが、既存のユーザーアカウントに対して既に指定されているアクセス許可と同じアクセス許可を継承することになります。
- 説明を入力し、API キーとシークレットを安全な場所に保存してから、キーとシークレットを保存したことを示すチェックボックスをオンにします。Save をクリックします。
Cloud API キーの数¶
Use Cloud API keys to control access to Confluent Cloud resources and use the Confluent Cloud APIs available for environments, user accounts, service accounts, connectors, Metrics API, and other resources.
重要
Cloud API キーの対象範囲は、特定のリソースだけではなく、組織全体です。
Cloud API キーの作成¶
- Prerequisites
- Access to Confluent Cloud.
- Confluent CLI is installed.
- To create API keys, you must be granted the OrganizationAdmin. For details, see Confluent Cloud RBAC roles.
Sign in to your cluster using the confluent login command.
confluent login
Enter your Confluent Cloud credentials: Email: susan@myemail.com Password:
Before creating an Cloud API key associated with a service account, use RBAC to restrict access to applications that use the key.
Create the Cloud API key using the confluent api-key create command, specifying the service account (
--service-account
), the resource (--resource
) ascloud
, and, optionally, a description (--description
).confluent api-key --service-account <service-account-id> create --resource cloud --description <key-description>
API キーとシークレットの出力をセキュアな場所に保管します。このシークレットを後から取得することはできません。
ちなみに
既存の API キーとシークレットを使用するには、リソース ID(
cloud
)、API キー(<api-key>
)、および API シークレット(<api-secret>
)を指定して次のコマンドを実行します。このコマンドは、別のプロセスで作成された API キーとシークレットを登録し、ローカルに保管します。confluent api-key store <api-key> <api-secret> --resource cloud
重要
When you remove a user's role assignment on a cluster for which the user created an API key, then the API key will continue to work even after the user's role assignment has been removed. For example:
- Bob には OrganizationAdmin ロールが割り当てられています。
- Bob が
Prod_1
環境のcluster_1
に対する API キーを作成します。 - Bob のロールがアップデートされ、
Prod_1
の OrganizationAdmin ロールは、もう Bob にはありません。彼には、新たにDev_1
環境の EnvironmentAdmin ロールが割り当てられました。 cluster_1
に対しては、Bob が作成した API キーが引き続き機能します。
このようなケースで、意図しないアクセスを招く可能性がある場合には、API キーを削除する必要があります。
# List the API keys owned by Bob
confluent api-key list --"Bob"
# Delete the API key that Bob created
confluent api-key delete <api-key>
- Prerequisites
- Access to Confluent Cloud
- To create API keys, you must be granted the OrganizationAdmin role. For details, see Confluent Cloud RBAC roles.
Before creating an API key associated with a service account, use RBAC to restrict access to applications that use the key.
Administration メニューから Cloud API keys をクリックするか、https://confluent.cloud/settings/api-keys にアクセスします。
Add key をクリックします。
Choose whether to create the key associated with your user account or a service account.
API キーとシークレットが生成され、表示されます。
Copy をクリックして、キーとシークレットをセキュアな場所にコピーします。
重要
キーのシークレットは、最初に Create API key ダイアログに表示されるだけです。後からウェブインターフェイスで表示したり取得したりすることはできません。シークレットおよび対応するキーをセキュアな場所に保管してください。API キーのシークレットは誰にも教えないでください。
(Optional, but recommended) Enter a description of the API key that describes how you intend to use it, so you can distinguish it from other API keys.
キーとシークレットを保存したことを確認するチェックボックスをオンにします。
Save をクリックします。キーがキーテーブルに追加されます。