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,
    "Policy": Map,
    "DeletionProtection": Boolean
  }
}属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| KeyUsage | String | 否 | 否 | 密钥的用途。 | 取值: 
 | 
| Enable | Boolean | 否 | 是 | 将密钥设置为启用或禁用状态。 | 取值: 
 | 
| PendingWindowInDays | Integer | 否 | 否 | 密钥预删除周期。在这段时间内,您可以撤销删除处于待删除状态的密钥;预删除时间过后无法撤销删除。 | 取值范围:7~30。 默认值:30。 单位:天。 | 
| Description | String | 否 | 是 | 密钥的描述。 | 长度为0~8192个字符。 | 
| KeySpec | String | 否 | 否 | 密钥的类型。 | 取值: 
 说明  在中国内地使用托管密码机创建的密钥,默认为Aliyun_SM4类型,其余情况下默认为Aliyun_AES_256。 | 
| EnableAutomaticRotation | Boolean | 否 | 是 | 是否开启密钥自动轮转。 | 取值: 
 | 
| RotationInterval | String | 否 | 是 | 自动轮转的时间周期。例如: | 格式为 合法的 
 7d或者604800s均表示7天的周期。 取值范围:7~730天。 | 
| ProtectionLevel | String | 否 | 否 | 密钥的保护级别。 | 取值: 
 | 
| DKMSInstanceId | String | 否 | 否 | 专属KMS的实例ID。 | 无 | 
| Policy | Map | 否 | 否 | 密钥策略。 | JSON格式。最大长度为32768个字节。 关于密钥策略的详细介绍,请参见密钥策略概述。不输入该参数时,使用默认凭据策略。 密钥策略内容包含: 
 密钥策略格式为:  | 
| DeletionProtection | Boolean | 否 | 是 | 是否开启删除保护。 | 取值: 
 | 
返回值
Fn::GetAtt
KeyId:密钥的全局唯一标识符。
示例
YAML格式 
ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
  Key:
    Type: ALIYUN::KMS::Key
    Properties:
      KeyUsage: ENCRYPT/DECRYPT
      Enable: false
      PendingWindowInDays: 15
      Description: Test create key
Outputs:
  KeyId:
    Description: The globally unique identifier for the CMK.
    Value:
      Fn::GetAtt:
        - Key
        - KeyIdJSON格式 
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
  },
  "Resources": {
    "Key": {
      "Type": "ALIYUN::KMS::Key",
      "Properties": {
        "KeyUsage": "ENCRYPT/DECRYPT",
        "Enable": false,
        "PendingWindowInDays": 15,
        "Description": "Test create key"
      }
    }
  },
  "Outputs": {
    "KeyId": {
      "Description": "The globally unique identifier for the CMK.",
      "Value": {
        "Fn::GetAtt": [
          "Key",
          "KeyId"
        ]
      }
    }
  }
}