ALIYUN::KMS::Key類型用於建立一個主要金鑰。
文法
{
"Type": "ALIYUN::KMS::Key",
"Properties": {
"KeyUsage": String,
"Enable": Boolean,
"PendingWindowInDays": Integer,
"Description": String,
"KeySpec": String,
"EnableAutomaticRotation": Boolean,
"RotationInterval": String,
"ProtectionLevel": String,
"DKMSInstanceId": String,
"KeyUsage": String,
"Policy": Map,
"DeletionProtection": Boolean,
"Tags": List
}
}屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
DKMSInstanceId | String | 是 | 否 | 專屬KMS的執行個體ID。 | 原KMS升級為專屬KMS,具體升級變動資訊參見【升級公告】KMS升級為專屬KMS。 |
DeletionProtection | Boolean | 否 | 是 | 是否開啟刪除保護。 | 取值:
|
Description | String | 否 | 是 | 密鑰的描述。 | 長度為0~8192個字元。 |
Enable | Boolean | 否 | 是 | 將密鑰設定為啟用或禁用狀態。 | 取值:
|
KeyUsage | String | 否 | 否 | 密鑰的用途。 | 取值:
預設值:如果密鑰支援簽名驗簽,預設值為 SIGN/VERIFY,否則預設值為 ENCRYPT/DECRYPT。 |
EnableAutomaticRotation | Boolean | 否 | 是 | 是否開啟密鑰自動輪轉。 | 取值:
|
KeySpec | String | 否 | 否 | 密鑰的類型。 | 取值:
說明 在中國內地使用託管密碼機建立的密鑰,預設為Aliyun_SM4類型,其餘情況下預設為Aliyun_AES_256。 |
PendingWindowInDays | Integer | 否 | 否 | 密鑰預刪除周期。在這段時間內,您可以撤銷刪除處於待刪除狀態的密鑰;預刪除時間過後無法撤銷刪除。 | 取值範圍:7~30。 預設值:30。 單位:天。 |
Policy | Map | 否 | 否 | 密鑰策略。 | JSON格式。最大長度為32768個位元組。 關於密鑰策略的詳細介紹,請參見密鑰策略概述。不輸入該參數時,使用預設憑據策略。 密鑰策略內容包含:
密鑰策略格式為: |
ProtectionLevel | String | 否 | 否 | 密鑰的保護層級。 | 取值:
|
RotationInterval | String | 否 | 是 | 自動輪轉的時間周期。例如: | 格式為 合法的
7d或者604800s均表示7天的周期。 取值範圍:7~730天。 |
Tags | List | 否 | 是 | 標籤。 | 最多支援添加20個標籤。 更多資訊,請參見Tags屬性。 |
Tags文法
"Tags": [
{
"Key": String,
"Value": String
}
] Tags屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Key | String | 是 | 否 | 標籤鍵。 | 長度為1~128個字元,不能以 |
Value | String | 否 | 否 | 標籤值。 | 長度為0~128個字元,不能以 |
傳回值
Fn::GetAtt
KeyId:密鑰的通用唯一識別碼。
樣本
情境 1 :使用已有KMS建立KMS密鑰。
Metadata: {}
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
KMSInstance:
Type: String
Description:
en: KMS Instance Id.
Resources:
KMS-Key-bhs-registry-secret:
Type: ALIYUN::KMS::Key
Properties:
DKMSInstanceId:
Ref: KMSInstance
DeletionProtection: false
Enable: true
EnableAutomaticRotation: true
KeySpec: Aliyun_AES_256
KeyUsage: ENCRYPT/DECRYPT
PendingWindowInDays: 7
RotationInterval: 30d
{
"Metadata": {
},
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"KMSInstance": {
"Type": "String",
"Description": {
"en": "KMS Instance Id."
}
}
},
"Resources": {
"KMS-Key-bhs-registry-secret": {
"Type": "ALIYUN::KMS::Key",
"Properties": {
"DKMSInstanceId": {
"Ref": "KMSInstance"
},
"DeletionProtection": false,
"Enable": true,
"EnableAutomaticRotation": true,
"KeySpec": "Aliyun_AES_256",
"KeyUsage": "ENCRYPT/DECRYPT",
"PendingWindowInDays": 7,
"RotationInterval": "30d"
}
}
}
}情境 2 :建立KMS建立並建立KMS密鑰。
Metadata: {}
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
ProductVersion:
Type: String
Description:
en: KMS Instance commodity type (software/software-small/hardware/hardware-small).
AllowedValues:
- software
- software-small
- hardware
- hardware-small
Required: true
Resources:
KMSInstance:
Type: ALIYUN::KMS::Instance
Properties:
ProductVersion:
Ref: ProductVersion
KMSKey:
Type: ALIYUN::KMS::Key
Properties:
DKMSInstanceId:
Ref: KMSInstance
DeletionProtection: false
Enable: true
EnableAutomaticRotation: true
KeySpec: Aliyun_AES_256
KeyUsage: ENCRYPT/DECRYPT
PendingWindowInDays: 7
RotationInterval: 30d
KMSAlias:
Type: ALIYUN::KMS::Alias
Properties:
AliasName: bhs-registry-secretDev
KeyId:
Fn::GetAtt:
- KMSKey
- KeyId
{
"Metadata": {
},
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"ProductVersion": {
"Type": "String",
"Description": {
"en": "KMS Instance commodity type (software/software-small/hardware/hardware-small)."
},
"AllowedValues": [
"software",
"software-small",
"hardware",
"hardware-small"
],
"Required": true
}
},
"Resources": {
"KMSInstance": {
"Type": "ALIYUN::KMS::Instance",
"Properties": {
"ProductVersion": {
"Ref": "ProductVersion"
}
}
},
"KMSKey": {
"Type": "ALIYUN::KMS::Key",
"Properties": {
"DKMSInstanceId": {
"Ref": "KMSInstance"
},
"DeletionProtection": false,
"Enable": true,
"EnableAutomaticRotation": true,
"KeySpec": "Aliyun_AES_256",
"KeyUsage": "ENCRYPT/DECRYPT",
"PendingWindowInDays": 7,
"RotationInterval": "30d"
}
},
"KMSAlias": {
"Type": "ALIYUN::KMS::Alias",
"Properties": {
"AliasName": "bhs-registry-secretDev",
"KeyId": {
"Fn::GetAtt": [
"KMSKey",
"KeyId"
]
}
}
}
}
}更多樣本,請參考包含此資源的公用模板。