文档

ALIYUN::ENS::KeyPair

更新时间:

ALIYUN::ENS::KeyPair类型用于导入RSA密钥对公钥。

语法

{
  "Type": "ALIYUN::ENS::KeyPair",
  "Properties": {
    "KeyPairName": String,
    "PublicKeyBody": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

KeyPairName

String

密钥对名称。

命名规则如下所示:

  • 长度为2~128个英文或中文字符。

  • 必须以大小字母或中文开头,不能以http://https://开头。

  • 可以包含数字、半角冒号(:)、下划线(_)、或者连字符(-)。

仅支持传单个密钥对。

PublicKeyBody

String

密钥对的公钥内容。

仅支持传单个内容。

返回值

Fn::GetAtt

  • KeyPairFingerPrint:密钥对的指纹。根据RFC4716定义的公钥指纹格式,采用MD5信息摘要算法。

  • KeyPairName:密钥对名称。

  • PrivateKeyBody:密钥对的公钥内容。

示例

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  KeyPairName:
    Type: String
    Description:
      en: |-
        The name of the key pair. The name must conform to the following naming conventions:
        The name must be 2 to 128 characters in length, and can contain letters, digits, colons (:), underscores (_), and hyphens (-).
        It must start with a letter but cannot start with http:// or https://.
    Required: true
  PublicKeyBody:
    Type: String
    Description:
      en: SSH Public key. If PublicKeyBody is specified, existed public key body will be imported instead of creating new SSH key pair.
    Required: false
Resources:
  KeyPair:
    Type: ALIYUN::ENS::KeyPair
    Properties:
      KeyPairName:
        Ref: KeyPairName
      PublicKeyBody:
        Ref: PublicKeyBody
Outputs:
  KeyPairFingerPrint:
    Description: The fingerprint of the key pair. The message-digest algorithm 5 (MD5) is used based on the public key fingerprint format defined in RFC 4716. For more information, see RFC 4716.
    Value:
      Fn::GetAtt:
        - KeyPair
        - KeyPairFingerPrint
  KeyPairName:
    Description: SSH Key pair name.
    Value:
      Fn::GetAtt:
        - KeyPair
        - KeyPairName
  PrivateKeyBody:
    Description: The private key of the key pair. The private key is encoded with PEM in the PKCS#8 format.
    Value:
      Fn::GetAtt:
        - KeyPair
        - PrivateKeyBody

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "KeyPairName": {
      "Type": "String",
      "Description": {
        "en": "The name of the key pair. The name must conform to the following naming conventions:\nThe name must be 2 to 128 characters in length, and can contain letters, digits, colons (:), underscores (_), and hyphens (-).\nIt must start with a letter but cannot start with http:// or https://."
      },
      "Required": true
    },
    "PublicKeyBody": {
      "Type": "String",
      "Description": {
        "en": "SSH Public key. If PublicKeyBody is specified, existed public key body will be imported instead of creating new SSH key pair."
      },
      "Required": false
    }
  },
  "Resources": {
    "KeyPair": {
      "Type": "ALIYUN::ENS::KeyPair",
      "Properties": {
        "KeyPairName": {
          "Ref": "KeyPairName"
        },
        "PublicKeyBody": {
          "Ref": "PublicKeyBody"
        }
      }
    }
  },
  "Outputs": {
    "KeyPairFingerPrint": {
      "Description": "The fingerprint of the key pair. The message-digest algorithm 5 (MD5) is used based on the public key fingerprint format defined in RFC 4716. For more information, see RFC 4716.",
      "Value": {
        "Fn::GetAtt": [
          "KeyPair",
          "KeyPairFingerPrint"
        ]
      }
    },
    "KeyPairName": {
      "Description": "SSH Key pair name.",
      "Value": {
        "Fn::GetAtt": [
          "KeyPair",
          "KeyPairName"
        ]
      }
    },
    "PrivateKeyBody": {
      "Description": "The private key of the key pair. The private key is encoded with PEM in the PKCS#8 format.",
      "Value": {
        "Fn::GetAtt": [
          "KeyPair",
          "PrivateKeyBody"
        ]
      }
    }
  }
}