This template creates a new key pair and specifies it when launching an EC2 instance. The `AWS::EC2::KeyPair` resource is used to create the key pair with the `KeyName` property set to 'MyKeyPair'. The `AWS::EC2::Instance` resource is used to launch the EC2 instance with the `ImageId` property set to 'ami-123456789012' and the `KeyName` property set to the `NewKeyPair` resource.

NewKeyPair
AWS::EC2::KeyPair


Ec2Instance
AWS::EC2::Instance


CloudFormation Template

Share Template