创建实例
您可以使用 IBM® Key Protect for IBM Cloud® 控制台或 IBM Cloud CLI 创建 IBM Cloud 实例。
概述
在 Key Protect中,instance (有时称为 service instance) 是名称空间。
名称空间将密钥组织到逻辑组中,并在名称空间之间提供隔离和保护。
- 例如,您可以选择有两个 Key Protect 实例-一个用于财务部门,一个用于制造。 两个实例提供了隔离,因此无法从其他业务单元访问一个业务单元中的密钥。
术语 instance 有时用于描述计算资源,例如
虚拟服务器 或
VPC 的虚拟服务器实例。 Key Protect 中的实例 不应 与计算资源等同。 A Key Protect 实例是名称空间。
从 IBM Cloud 控制台调配 Key Protect 标准或专用实例
要从 Key Protect 控制台供应 IBM Cloud 的实例,请完成以下步骤。
-
单击“目录”查看以下网站提供的服务列表 IBM Cloud.
-
在 搜索目录 ... 字段中搜索 "Key Protect",然后单击
Key Protect。 -
选择“标准”或“专用”计划,然后单击“创建”,在登录的账户、区域和资源组中配置 Key Protect 实例。 如需了解定价详情,请发送电子邮件 至 IBM Cloud,联系 Key Protect。
如果需要在不同账户或环境中重复相同的设置,可以使用精心策划的 Terraform IBM 模块实现自动化。 Key Protect 全包模块是一种可将实例与钥匙和钥匙圈一起提供的选项。 有关概述,请参阅 Terraform IBM 模块。
从 IBM Cloud CLI 供应 Key Protect
您也可以使用 Key Protect CLI 来供应 IBM Cloud 的实例。
以下示例使用了 tiered-pricing 计划,您也可以使用 cross-region-resiliency 计划 将资源部署到选定的区域,该计划提供了额外的故障转移支持。 提供该计划的地区包括:us-south (位于美国达拉斯)、jp-tok (位于日本东京)和 eu-de (位于德国法兰克福)。 您不能使用此计划部署到其他地区。
使用 CLI 登录
通过以下命令登录到 IBM Cloud IBM Cloud CLI。 这是用于此实例的帐户 Key Protect.
登录
使用 login 命令登录。 如果此操作失败,那么应尝试 --sso 选项以使用联合标识登录 (请参阅下一节)。
此示例失败,因为电子邮件地址属于联合标识。
ibmcloud login
示例
$ ibmcloud login
API endpoint: https://cloud.ibm.com
Region: us-south
Email> <email address>
Password>
Authenticating...
You are using a federated user ID, please use one time passcode ( ibmcloud login --sso ), or use API key ( ibmcloud --apikey key or @key_file ) to authenticate.
API endpoint: https://cloud.ibm.com
Region: us-south
Not logged in.
FAILED
使用联合标识登录
使用 --sso 选项登录将打开浏览器窗口 (需要登录) 并创建一次性密码。 验证码用于完成登录过程。
ibmcloud login --sso
示例
$ ibmcloud login --sso
API endpoint: https://cloud.ibm.com
Region: us-south
Get One Time Code from https://identity-2.us-south.iam.cloud.ibm.com/identity/passcode to proceed.
Open the URL in the default browser? [Y/n] > Y
One Time Code > <paste the one-time passcode from your browser>
Authenticating...
OK
Select an account:
1. Account name (ea988d3289c24739a0977651b46fb145)
Enter a number> 1
Targeted account Account name (ea988d3289c24739a0977651b46fb145)
API endpoint: https://cloud.ibm.com
Region: us-south
User: <email address>
Account: Account name (ea988d3289c24739a0977651b46fb145)
Resource group: No resource group targeted, use 'ibmcloud target -g RESOURCE_GROUP'
CF API endpoint:
Org:
Space:
选择区域和资源组
选择要创建的区域和资源组 Key Protect 实例。
<resource_group_name> 可以是 Default (区分大小写)。
ibmcloud target -r <region_name> -g <resource_group_name>
示例
$ ibmcloud target -r us-south -g Default
Targeted resource group Default
Switched to region us-south
API endpoint: https://cloud.ibm.com
Region: us-south
User: <email address>
Account: Account name (ea988d3289c24739a0977651b46fb145)
Resource group: Default
CF API endpoint:
Org:
Space:
供应公共实例
供应公共 Key Protect 实例。 下一节提供了供应 private 实例的示例。
-
公共端点 在 IBM Cloud外部。
-
专用端点 在 IBM Cloud中。
公共实例接受来自两个 public and private 端点的 API 请求。 公用网络访问是缺省设置,如果未设置策略,那么将使用此设置。
专用实例仅接受来自 private 端点的 API 请求。
请参阅 管理网络访问策略,以了解有关公共和专用访问的更多信息。
请注意 GUID 是实例标识。 在本例中,实例 ID 是
ea557753-a15b-4570-a9a3-1efefbd2d382.
ibmcloud resource service-instance-create <instance_name> kms tiered-pricing <region>
示例
# create a public service instance
$ ibmcloud resource service-instance-create <instance_name> kms tiered-pricing us-south
Creating service instance <instance_name> in resource group Default of account <account name> as <email address>...
OK
Service instance <instance_name> was created.
Name: <instance_name>
ID: crn:v1:bluemix:public:kms:us-south:a/ea988d3289c24739a0977651b46fb145:ea557753-a15b-4570-a9a3-1efefbd2d382::
GUID: ea557753-a15b-4570-a9a3-1efefbd2d382
Location: us-south
State: active
Type: service_instance
Sub Type: kms
Allow Cleanup: false
Locked: false
Created at: 2020-05-31T15:04:50Z
Updated at: 2020-05-31T15:04:50Z
Last Operation:
Status create succeeded
Message Completed create instance operation
# list the service instances
$ ibmcloud resource service-instances
Retrieving instances with type service_instance in resource group Default in all locations under account <account name> as <email address>...
OK
Name Location State Type
<instance_name> us-south active service_instance
# delete the public service instance
$ ibmcloud resource service-instance-delete <instance_name>
Deleting service instance <instance_name> in resource group Default under account <account name> as <email address>...
Really delete the service instance <instance_name> with ID crn:v1:bluemix:public:kms:us-south:a/ea988d3289c24739a0977651b46fb145:ea557753-a15b-4570-a9a3-1efefbd2d382::? [y/N] > y
OK
Service instance <instance_name> with ID crn:v1:bluemix:public:kms:us-south:a/ea988d3289c24739a0977651b46fb145:ea557753-a15b-4570-a9a3-1efefbd2d382:: is deleted successfully
供应专用实例
供应专用 Key Protect 实例。
请记住,专用实例仅接受来自专用端点的 API 请求,这些端点位于 IBM Cloud中。 如果您在外部,那么无法将 CLI 与专用实例配合使用。 IBM Cloud.
ibmcloud resource service-instance-create <instance_name> kms tiered-pricing <region> -p '{"allowed_network": "private-only"}'
示例
创建专用实例后,将发出创建密钥的请求。 请求失败,因为用户无权从 IBM Cloud外部访问 private 实例。
-p 选项指定用于创建服务实例的 JSON 文件或 JSON 参数字符串。
# create a private service instance
$ ibmcloud resource service-instance-create <service-name> kms tiered-pricing us-south -p '{"allowed_network": "private-only"}'
Creating service instance <service-name> in resource group Default of account <account name> as <email address>...
OK
Service instance <service-name> was created.
Name: <service-name>
ID: crn:v1:bluemix:public:kms:us-south:a/ea988d3289c24739a0977651b46fb145:a152eee4-262e-4a39-ae13-a71b9882dcb6::
GUID: a152eee4-262e-4a39-ae13-a71b9882dcb6
Location: us-south
State: active
Type: service_instance
Sub Type: kms
Allow Cleanup: false
Locked: false
Created at: 2020-05-31T15:10:23Z
Updated at: 2020-05-31T15:10:23Z
Last Operation:
Status create succeeded
Message Completed create instance operation
# list the service instances
$ ibmcloud resource service-instances
Retrieving instances with type service_instance in resource group Default in all locations under account <account name> as <email address>...
OK
Name Location State Type
<service-name> us-south active service_instance
# list the private service instance
$ ibmcloud resource service-instance <service-name>
Retrieving service instance <service-name> in resource group Default under account <account name> as <email address>...
OK
Name: <service-name>
ID: crn:v1:bluemix:public:kms:us-south:a/ea988d3289c24739a0977651b46fb145:a152eee4-262e-4a39-ae13-a71b9882dcb6::
GUID: a152eee4-262e-4a39-ae13-a71b9882dcb6
Location: us-south
Service Name: kms
Service Plan Name: tiered-pricing
Resource Group Name: Default
State: active
Type: service_instance
Sub Type: kms
Created at: 2020-05-31T15:10:23Z
Created by: <email address>
Updated at: 2020-05-31T15:10:23Z
Last Operation:
Status create succeeded
Message Completed create instance operation
# list keys in the private service instance
$ ibmcloud kp keys -i a152eee4-262e-4a39-ae13-a71b9882dcb6
Retrieving keys...
FAILED
kp.Error: correlation_id='59578794-2b5b-48ca-9074-bbe23760d94a', msg='Unauthorized: The user does not have access to the specified resource'
# delete the private service instance
$ ibmcloud resource service-instance-delete <service-name>
Deleting service instance <service-name> in resource group Default under account <account name> as <email address>...
Really delete the service instance <service-name> with ID crn:v1:bluemix:public:kms:us-south:a/ea988d3289c24739a0977651b46fb145:a152eee4-262e-4a39-ae13-a71b9882dcb6::? [y/N] > y
OK
Service instance <service-name> with ID crn:v1:bluemix:public:kms:us-south:a/ea988d3289c24739a0977651b46fb145:a152eee4-262e-4a39-ae13-a71b9882dcb6:: is deleted successfully
删除具有现有密钥的实例
无法删除包含密钥的服务实例。
示例
$ ibmcloud resource service-instance-delete <instance_name>
Deleting service instance <instance_name> in resource group Default under account <account name> as <email address>...
Really delete the service instance <instance_name> with ID crn:v1:bluemix:public:kms:us-south:a/ea988d3289c24739a0977651b46fb145:a152eee4-262e-4a39-ae13-a71b9882dcb6::? [y/N] > y
FAILED
Error Code: RC-ServiceBrokerErrorResponse
Message: [409, Conflict] Conflict: Instance contains 2 active keys. Remove all keys before de-provisioning
下一步
要了解更多有关以编程方式管理密钥的信息,请 查看Key Protect API 参考文档