すべてのプロダクト
Search
ドキュメントセンター

Resource Orchestration Service:ALIYUN::KMS::Key

最終更新日:Mar 28, 2026

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

いいえ

はい

削除保護を有効にするかどうかを指定します。

有効値:

  • true: 削除保護を有効にします。

  • false: 削除保護を無効にします。

Description

String

いいえ

はい

キーの説明。

説明は 0~8192 文字である必要があります。

Enable

Boolean

いいえ

はい

キーを有効にするか無効にするかを指定します。

有効値:

  • true (デフォルト): キーを有効にします。

  • false: キーを無効にします。

KeyUsage

String

いいえ

いいえ

キーの用途。

有効値:

  • ENCRYPT/DECRYPT: データを暗号化および復号します。

  • SIGN/VERIFY: デジタル署名を生成および検証します。

デフォルト値: キーが署名検証をサポートしている場合は SIGN/VERIFY。それ以外の場合、デフォルト値は ENCRYPT/DECRYPT です。

EnableAutomaticRotation

Boolean

いいえ

はい

キーの自動ローテーションを有効にするかどうかを指定します。

有効値:

  • true: キーの自動ローテーションを有効にします。

  • false (デフォルト): キーの自動ローテーションを無効にします。

KeySpec

String

いいえ

いいえ

キーのタイプ。

有効値:

  • Aliyun_AES_256

  • Aliyun_SM4

  • RSA_2048

  • EC_P256

  • EC_P256K

  • EC_SM2

説明

中国本土では、マネージド HSM を使用して作成されたキーのデフォルトは Aliyun_SM4 です。それ以外のすべての場合、キーのデフォルトは Aliyun_AES_256 です。

PendingWindowInDays

Integer

いいえ

いいえ

削除保留期間。この期間中、削除保留中のキーの削除を取り消すことができます。この期間が終了すると、削除を取り消すことはできません。

有効値:7~30。

デフォルト値:30。

単位:日。

Policy

Map

いいえ

いいえ

キーポリシー。

JSON 形式。最大サイズ:32768 バイト。

キーポリシーの詳細については、「キーポリシーの概要」をご参照ください。このプロパティを指定しない場合、デフォルトの認証情報ポリシーが使用されます。

キーポリシーには、次の要素が含まれます:

  • Version: キーポリシーのバージョン。バージョン 1 のみがサポートされています。

  • Statement: キーポリシー内の 1 つ以上のステートメント。

キーポリシーの形式は次のとおりです:

{
    "Version": "1",
    "Statement": [
        {
            "Sid": "Enable RAM User Permissions",
            "Effect": "Allow",
            "Principal": {
              "RAM": "acs:ram::112890462****:root"
            }
            "Action": [
                "kms:*"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

ProtectionLevel

String

いいえ

いいえ

キーの保護レベル。

有効値:

  • SOFTWARE (デフォルト)

  • HSM

RotationInterval

String

いいえ

はい

キーの自動ローテーションの時間間隔。例:365d

形式は integer[unit] で、integer は期間、unit は時間単位を表します。

unit の有効値:

  • d: 日

  • h: 時間

  • m: 分

  • s: 秒

7d と 604800s はどちらも 7 日間の間隔を表します。

有効値:7~730 日。

Tags

List

いいえ

はい

ラベル。

最大 20 個のタグを追加できます。

詳細については、「Tags プロパティ」をご参照ください。

Tags 構文

"Tags": [
  {
    "Key": String,
    "Value": String
  }
]

Tags プロパティ

プロパティ名

タイプ

必須

更新を有効化する

説明

制約

Key

String

はい

いいえ

タグキー。

長さ:1~128 文字。aliyun または acs: で始めることはできません。http:// または https:// を含めることはできません。

Value

String

いいえ

いいえ

タグ値。

長さ:0~128 文字。aliyun または acs: で始めることはできません。http:// または https:// を含めることはできません。

戻り値

Fn::GetAtt

KeyId: キーのグローバル一意識別子。

シナリオ 1: 既存の KMS インスタンスを使用した KMS キーの作成

クイック作成

Metadata: {}
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  KMSInstance:
    Type: String
    Description:
      en: KMS インスタンス 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 インスタンス 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 インスタンスの商品タイプ (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 インスタンスの商品タイプ (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"
          ]
        }
      }
    }
  }
}

その他の例については、「このリソースを含むパブリックテンプレート」をご参照ください。