{
  "typeName" : "AWS::EC2::KeyPair",
  "description" : "Specifies a key pair for use with an EC2long instance as follows:\n  +  To import an existing key pair, include the ``PublicKeyMaterial`` property.\n  +  To create a new key pair, omit the ``PublicKeyMaterial`` property.\n  \n When you import an existing key pair, you specify the public key material for the key. We assume that you have the private key material for the key. CFNlong does not create or return the private key material when you import a key pair.\n When you create a new key pair, the private key is saved to SYSlong Parameter Store, using a parameter with the following name: ``/ec2/keypair/{key_pair_id}``. For more information about retrieving private key, and the required permissions, see [Create a key pair using](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html#create-key-pair-cloudformation) in the *User Guide*.\n When CFN deletes a key pair that was created or imported by a stack, it also deletes the parameter that was used to store the private key material in Parameter Store.",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
  "definitions" : {
    "Tag" : {
      "description" : "Specifies a tag. For more information, see [Resource tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html).",
      "type" : "object",
      "properties" : {
        "Key" : {
          "type" : "string",
          "description" : "The tag key.",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "type" : "string",
          "description" : "The tag value.",
          "minLength" : 0,
          "maxLength" : 256
        }
      },
      "required" : [ "Key", "Value" ],
      "additionalProperties" : false
    }
  },
  "properties" : {
    "KeyName" : {
      "description" : "A unique name for the key pair.\n Constraints: Up to 255 ASCII characters",
      "type" : "string"
    },
    "KeyType" : {
      "description" : "The type of key pair. Note that ED25519 keys are not supported for Windows instances.\n If the ``PublicKeyMaterial`` property is specified, the ``KeyType`` property is ignored, and the key type is inferred from the ``PublicKeyMaterial`` value.\n Default: ``rsa``",
      "type" : "string",
      "default" : "rsa",
      "enum" : [ "rsa", "ed25519" ]
    },
    "KeyFormat" : {
      "description" : "The format of the key pair.\n Default: ``pem``",
      "type" : "string",
      "default" : "pem",
      "enum" : [ "pem", "ppk" ]
    },
    "PublicKeyMaterial" : {
      "description" : "The public key material. The ``PublicKeyMaterial`` property is used to import a key pair. If this property is not specified, then a new key pair will be created.",
      "type" : "string"
    },
    "KeyFingerprint" : {
      "description" : "",
      "type" : "string"
    },
    "KeyPairId" : {
      "description" : "",
      "type" : "string"
    },
    "Tags" : {
      "description" : "The tags to apply to the key pair.",
      "type" : "array",
      "uniqueItems" : true,
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    }
  },
  "additionalProperties" : false,
  "required" : [ "KeyName" ],
  "primaryIdentifier" : [ "/properties/KeyName" ],
  "additionalIdentifiers" : [ [ "/properties/KeyPairId" ] ],
  "createOnlyProperties" : [ "/properties/KeyName", "/properties/KeyType", "/properties/KeyFormat", "/properties/PublicKeyMaterial", "/properties/Tags" ],
  "writeOnlyProperties" : [ "/properties/KeyFormat" ],
  "readOnlyProperties" : [ "/properties/KeyPairId", "/properties/KeyFingerprint" ],
  "propertyTransform" : {
    "/properties/PublicKeyMaterial" : "$join([PublicKeyMaterial, \"\n\"])"
  },
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : false,
    "cloudFormationSystemTags" : false,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "ec2:CreateTags" ]
  },
  "handlers" : {
    "create" : {
      "permissions" : [ "ec2:CreateKeyPair", "ec2:ImportKeyPair", "ec2:CreateTags", "ssm:PutParameter" ]
    },
    "read" : {
      "permissions" : [ "ec2:DescribeKeyPairs" ]
    },
    "list" : {
      "permissions" : [ "ec2:DescribeKeyPairs" ]
    },
    "delete" : {
      "permissions" : [ "ec2:DeleteKeyPair", "ssm:DeleteParameter", "ec2:DescribeKeyPairs" ]
    }
  }
}