AWS Fundamentals Logo
AWS Fundamentals
AWS::EC2::KeyPair

EC2 KeyPair

Specifies a key pair for use with an EC2long instance as follows: + To import an existing key pair, include the PublicKeyMaterial property. + To create a new key pair, omit the PublicKeyMaterial property. 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. When you create a new key pair, the p...

Properties

5 configurable properties. 1 required. Click a row to see details.

Filter:
PropertyTypeFlags
KeyName
string
RequiredCreate-only
KeyFormat
string
Create-onlyWrite-only
KeyType
string
Create-only
PublicKeyMaterial
string
Create-only
Tags
Array<Tag>
Create-only

Return Values

Values returned after the resource is created. Access these with Fn::GetAtt.

AttributeTypeDescription
KeyFingerprintstring-
KeyPairIdstring-

Sample CloudFormation Template

A minimal template with required properties and common optional ones.

template.yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: Sample template for AWS::EC2::KeyPair

Resources:
  MyResource:
    Type: AWS::EC2::KeyPair
    Properties:
      KeyName: "my-keyname"
      Tags:
        - Key: Environment
          Value: Production

Required IAM Permissions

Permissions CloudFormation needs in your IAM role to manage this resource.

create

ec2:CreateKeyPairec2:ImportKeyPairec2:CreateTagsssm:PutParameter

read

ec2:DescribeKeyPairs

list

ec2:DescribeKeyPairs

delete

ec2:DeleteKeyPairssm:DeleteParameterec2:DescribeKeyPairs

Get the EC2 Cheat Sheet

Everything you need to know about EC2 on one page. HD quality, print-friendly.

Download Free Infographic

Quick Facts

ServiceEC2
Properties7
Required1
TaggingSupported
Primary IDKeyName

Supported Operations

CreateReadListDelete

Immutable After Creation

These properties cannot be changed after the resource is created. Updating them triggers a replacement.

KeyNameKeyTypeKeyFormatPublicKeyMaterialTags

External Links