建立實例

您可以使用 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 的實例,請完成下列步驟。

  1. 登入 IBM Cloud 帳戶

  2. 按一下「目錄」,以檢視下列服務的清單 IBM Cloud.

  3. 搜尋型錄 ... 欄位中搜尋 "Key Protect",然後按一下 Key Protect

  4. 選擇標準或專用計劃,然後按一下建立,以在您登入的帳戶、區域和資源群組中提供 Key Protect 的實例。 如需更多有關定價的資訊,請查看 Key Protect 上的 Pricing for IBM Cloud

如果您需要在不同帳戶或環境中重複相同的設定,您可以使用策劃好的 Terraform IBM 模組進行自動化。 Key Protect All-Inclusive 模組是一種選項,可將實體與鑰匙和鑰匙圈一起提供。 如需概覽,請參閱 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 選項,以聯合 ID 登入 (請參閱下一節)。

此範例失敗,因為電子郵件位址屬於聯合 ID。

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

使用聯合 ID 登入

使用 --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。 在此範例中,實例 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 參考文件