全部产品
Search
文档中心

资源编排:ALIYUN::KMS::Key

更新时间:Apr 06, 2023

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

密钥的用途。

取值:

  • ENCRYPT/DECRYPT:数据加密和解密。

  • SIGN/VERIFY:产生和验证数字签名。

Enable

Boolean

将密钥设置为启用或禁用状态。

取值:

  • true(默认值):将密钥设置为启用状态。

  • false:将密钥设置为禁用状态。

PendingWindowInDays

Integer

密钥预删除周期。在这段时间内,您可以撤销删除处于待删除状态的密钥;预删除时间过后无法撤销删除。

取值范围:7~30。

默认值:30。

单位:天。

Description

String

密钥的描述。

长度为0~8192个字符。

KeySpec

String

密钥的类型。

取值:

  • Aliyun_AES_256

  • Aliyun_SM4

  • RSA_2048

  • EC_P256

  • EC_P256K

  • EC_SM2

说明

在中国内地使用托管密码机创建的密钥,默认为Aliyun_SM4类型,其余情况下默认为Aliyun_AES_256。

EnableAutomaticRotation

Boolean

是否开启密钥自动轮转。

取值:

  • true:开启密钥自动轮转。

  • false(默认值):关闭密钥自动轮转。

RotationInterval

String

自动轮转的时间周期。例如:365d

格式为integer[unit],其中integer表示时间长度,unit表示时间单位。

合法的unit单位取值如下:

  • d:天

  • h:小时

  • m:分钟

  • s:秒

7d或者604800s均表示7天的周期。

取值范围:7~730天。

ProtectionLevel

String

密钥的保护级别。

取值:

  • SOFTWARE(默认值)

  • HSM

DKMSInstanceId

String

专属KMS的实例ID。

返回值

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
            - KeyId
  • JSON格式

    {
      "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"
            ]
          }
        }
      }
    }