All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ENS::KeyPair

最終更新日:Jun 04, 2024

ALIYUN::ENS::KeyPair is used to import the public key of a Rivest-Shamir-Adleman (RSA)-encrypted key pair.

Syntax

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

Properties

Property

Type

Required

Editable

Description

Constraint

KeyPairName

String

Yes

No

The name of the key pair.

The name conforms to the following rules:

  • The name must be 2 to 128 characters in length.

  • It must start with a letter and cannot start with http:// or https://.

  • It can contain letters, digits, colons (:), underscores (_), and hyphens (-).

You can specify only one key pair.

PublicKeyBody

String

No

No

The public key of the key pair.

You can specify only one public key.

Return values

Fn::GetAtt

  • KeyPairFingerPrint: the fingerprint of the key pair. The message-digest algorithm 5 (MD5) is used based on the public key fingerprint format defined in Request for Comments (RFC) 4716.

  • KeyPairName: the name of the key pair.

  • PrivateKeyBody: the public key of the key pair.

Examples

YAML format

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 format

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