Use an existing Key Pair in the AWS CloudFormation when deploying an EC2 instance

Under the Parameters section include the Key Pair entry and then from the Resources section reference the Key Pair.

Parameters:
KeyName:
Description: "Name of an existing key pair"
Type: String
...
...
...
Resources:
EC2Instance:
Type: 'AWS::EC2::Instance'
Properties:
InstanceType: t3.micro
ImageId: 'ami-008677ef1baf82eaf'
KeyName:
Ref: KeyName
...
...


Comments