Deploying private key pairs with AWS CloudFormation
In AWS CloudFormation there is no way to generate a private key pair. As a result, you always have manual work. You need to generate a ssh key, import it into AWS and finally pass the name to your CloudFormation template. This is clumsy, manual work which prevents us to fully automate the deployment of our infrastructure.
In this blog we will show you how the provisioning of ssh keys and ec2 key pairs can be automated using Custom CloudFormation Resources.
read the full blog at https://binx.io/blog/2017/10/25/deploying-private-key-pairs-with-aws-cloudformation/